summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--AconfigFlags.bp1
-rw-r--r--Android.bp1
-rw-r--r--BROADCASTS_OWNERS4
-rw-r--r--android-sdk-flags/Android.bp30
-rw-r--r--android-sdk-flags/flags.aconfig12
-rw-r--r--apex/blobstore/OWNERS5
-rw-r--r--apex/jobscheduler/service/java/com/android/server/usage/TEST_MAPPING8
-rw-r--r--boot/hiddenapi/hiddenapi-unsupported.txt1
-rw-r--r--core/api/current.txt7
-rw-r--r--core/api/system-current.txt9
-rw-r--r--core/java/android/app/ActivityManager.java41
-rw-r--r--core/java/android/app/Notification.java45
-rw-r--r--core/java/android/app/NotificationChannel.java16
-rw-r--r--core/java/android/app/activity_manager.aconfig11
-rw-r--r--core/java/android/app/admin/flags/flags.aconfig10
-rw-r--r--core/java/android/app/appfunctions/AppFunctionRuntimeMetadata.java14
-rw-r--r--core/java/android/app/appfunctions/AppFunctionStaticMetadataHelper.java2
-rw-r--r--core/java/android/companion/virtual/flags/flags.aconfig11
-rw-r--r--core/java/android/content/pm/LauncherActivityInfo.java188
-rw-r--r--core/java/android/content/pm/PackageManager.java2
-rw-r--r--core/java/android/database/sqlite/SQLiteDatabase.java38
-rw-r--r--core/java/android/database/sqlite/SQLiteDebug.java10
-rw-r--r--core/java/android/hardware/biometrics/BiometricConstants.java6
-rw-r--r--core/java/android/hardware/biometrics/BiometricManager.java7
-rw-r--r--core/java/android/hardware/fingerprint/FingerprintSensorConfigurations.java42
-rw-r--r--core/java/android/hardware/input/input_framework.aconfig7
-rw-r--r--core/java/android/net/vcn/flags.aconfig10
-rw-r--r--core/java/android/os/Binder.java126
-rw-r--r--core/java/android/os/Build.java25
-rw-r--r--core/java/android/os/Parcel.java80
-rw-r--r--core/java/android/os/StrictMode.java5
-rw-r--r--core/java/android/os/SystemClock.java67
-rw-r--r--core/java/android/os/Vibrator.java82
-rw-r--r--core/java/android/os/VibratorInfo.java134
-rw-r--r--core/java/android/os/vibrator/MultiVibratorInfo.java8
-rw-r--r--core/java/android/os/vibrator/VibrationConfig.java68
-rw-r--r--core/java/android/permission/flags.aconfig8
-rw-r--r--core/java/android/text/ClientFlags.java21
-rw-r--r--core/java/android/text/MeasuredParagraph.java224
-rw-r--r--core/java/android/text/TextFlags.java6
-rw-r--r--core/java/android/text/flags/24Q3.aconfig54
-rw-r--r--core/java/android/text/flags/flags.aconfig73
-rw-r--r--core/java/android/util/Slog.java2
-rw-r--r--core/java/android/view/PointerIcon.java5
-rw-r--r--core/java/android/view/View.java10
-rw-r--r--core/java/android/view/ViewGroup.java5
-rw-r--r--core/java/android/view/WindowManager.java79
-rw-r--r--core/java/android/view/accessibility/AccessibilityManager.java31
-rw-r--r--core/java/android/view/accessibility/IAccessibilityManager.aidl2
-rw-r--r--core/java/android/webkit/UserPackage.java40
-rw-r--r--core/java/android/webkit/WebViewDelegate.java10
-rw-r--r--core/java/android/widget/ScrollView.java19
-rw-r--r--core/java/android/widget/flags/flags.aconfig11
-rw-r--r--core/java/android/window/flags/lse_desktop_experience.aconfig7
-rw-r--r--core/java/com/android/internal/accessibility/dialog/AccessibilityButtonChooserActivity.java7
-rw-r--r--core/java/com/android/internal/app/SetScreenLockDialogActivity.java6
-rw-r--r--core/java/com/android/internal/jank/flags.aconfig2
-rw-r--r--core/java/com/android/internal/pm/parsing/pkg/PackageImpl.java1
-rw-r--r--core/java/com/android/internal/widget/ViewGroupFader.java23
-rw-r--r--core/jni/android_database_SQLiteConnection.cpp15
-rw-r--r--core/jni/android_os_Parcel.cpp45
-rw-r--r--core/jni/android_util_Binder.cpp24
-rw-r--r--core/res/res/values-et-rEE/config.xml21
-rw-r--r--core/res/res/values-watch/config.xml4
-rw-r--r--core/res/res/values/config.xml4
-rw-r--r--core/res/res/values/strings.xml3
-rw-r--r--core/res/res/values/symbols.xml4
-rw-r--r--core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/RadioServiceUserControllerTest.java46
-rw-r--r--core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImplTest.java15
-rw-r--r--core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/RadioModuleTest.java7
-rw-r--r--core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/TunerSessionTest.java40
-rw-r--r--core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/BroadcastRadioServiceHidlTest.java15
-rw-r--r--core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/RadioModuleHidlTest.java7
-rw-r--r--core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/StartProgramListUpdatesFanoutTest.java20
-rw-r--r--core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/TunerSessionHidlTest.java46
-rw-r--r--core/tests/coretests/Android.bp38
-rw-r--r--core/tests/coretests/src/android/app/NotificationChannelTest.java26
-rw-r--r--core/tests/coretests/src/android/content/pm/LauncherActivityInfoTest.java218
-rw-r--r--core/tests/coretests/src/android/database/sqlite/SQLiteDatabaseTest.java54
-rw-r--r--core/tests/coretests/src/android/os/BinderTest.java6
-rw-r--r--core/tests/coretests/src/android/os/BundleTest.java13
-rw-r--r--core/tests/coretests/src/android/os/ParcelNullabilityTest.java6
-rw-r--r--core/tests/coretests/src/android/os/ParcelTest.java9
-rw-r--r--core/tests/coretests/src/android/text/TextLineLetterSpacingTest.kt4
-rw-r--r--core/tests/coretests/src/com/android/internal/widget/ViewGroupFaderTest.java107
-rw-r--r--core/tests/vibrator/src/android/os/VibratorInfoTest.java52
-rw-r--r--core/tests/vibrator/src/android/os/vibrator/VibrationConfigTest.java100
-rw-r--r--graphics/java/android/graphics/OWNERS1
-rw-r--r--graphics/java/android/graphics/Paint.java11
-rw-r--r--graphics/java/android/graphics/fonts/SystemFonts.java16
-rw-r--r--libs/WindowManager/Shell/res/values/dimen.xml2
-rw-r--r--libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeFlags.kt1
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java53
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java30
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java11
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java4
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionHandler.java21
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java33
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentTasks.aidl2
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentsAnimationController.aidl (renamed from core/java/android/view/IRecentsAnimationController.aidl)72
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentsAnimationRunner.aidl (renamed from core/java/android/view/IRecentsAnimationRunner.aidl)6
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java2
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java29
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitscreenEventLogger.java4
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java12
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java3
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java63
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java3
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskDragResizer.java2
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskPositioner.kt22
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java3
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java3
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java15
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt4
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java2
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt70
-rw-r--r--libs/hwui/FeatureFlags.h8
-rw-r--r--libs/hwui/hwui/MinikinUtils.cpp4
-rw-r--r--libs/hwui/renderthread/CanvasContext.cpp3
-rw-r--r--location/java/android/location/flags/location.aconfig8
-rw-r--r--nfc/java/android/nfc/cardemulation/ApduServiceInfo.java23
-rw-r--r--packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java79
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java73
-rw-r--r--packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java4
-rw-r--r--packages/SettingsLib/Android.bp2
-rw-r--r--packages/SettingsLib/Preference/Android.bp1
-rw-r--r--packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceFragment.kt2
-rw-r--r--packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/preference/MainSwitchPreference.kt9
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservablePreferenceFragment.java7
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt6
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt2
-rw-r--r--packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioRepositoryTest.kt23
-rw-r--r--packages/SystemUI/Android.bp1
-rw-r--r--packages/SystemUI/aconfig/systemui.aconfig20
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt4
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/PinInputDisplay.kt6
-rw-r--r--packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/TextExt.kt7
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt34
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt13
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Element.kt32
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/InterruptionHandler.kt5
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt10
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MovableElement.kt10
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt33
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/ObservableTransitionState.kt11
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/PredictiveBackHandler.kt4
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt2
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt4
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt14
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt16
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt2
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeToScene.kt8
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt15
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDslImpl.kt20
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/UserActionDistanceScopeImpl.kt10
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/content/Content.kt4
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/content/state/TransitionState.kt6
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/modifiers/SizeMatcher.kt24
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/AnchoredTranslate.kt10
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/EdgeTranslate.kt2
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Fade.kt6
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Transformation.kt8
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Translate.kt12
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transition/link/StateLink.kt4
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/grid/Grids.kt7
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/ui/util/MathHelpers.kt4
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt9
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/systemui/communal/ui/compose/CommunalSwipeDetector.kt2
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/AnimatedSharedAsStateTest.kt16
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt91
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt65
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/InterruptionHandlerTest.kt8
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MovableElementTest.kt4
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt9
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt4
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ObservableTransitionStateTest.kt11
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/OverlayTest.kt2
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/PredictiveBackHandlerTest.kt8
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutStateTest.kt40
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutTest.kt18
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt21
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/TransitionDslTest.kt30
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/subjects/TransitionStateSubject.kt22
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/transformation/AnchoredSizeTest.kt6
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/transformation/SharedElementTest.kt2
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnectionTest.kt10
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt15
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/test/SetContentAndCreateScope.kt2
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/test/subjects/DpOffsetSubject.kt6
-rw-r--r--packages/SystemUI/compose/scene/tests/utils/src/com/android/compose/animation/scene/TestTransition.kt24
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/BiometricTestExtensions.kt75
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorTest.kt174
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinderTest.kt255
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModelTest.kt65
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt32
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadStatsInteractorTest.kt125
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepositoryTest.kt5
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractorTest.kt6
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/EditTileListStateTest.kt6
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelTest.kt20
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/shared/model/GroupAndSortCategoryAndNameTest.kt87
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt10
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapperTest.kt4
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImplTest.kt126
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorImplTest.kt109
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/wifi/domain/interactor/WifiInteractorImplTest.kt18
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelTest.kt10
-rw-r--r--packages/SystemUI/res/layout/biometric_prompt_one_pane_layout.xml13
-rw-r--r--packages/SystemUI/res/layout/biometric_prompt_two_pane_layout.xml13
-rw-r--r--packages/SystemUI/res/values/strings.xml29
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/dagger/qualifiers/DisplaySpecific.kt5
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl5
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/RecentsTransition.java30
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationControllerCompat.java49
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationListener.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityButtonModeObserver.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityButtonTargetsObserver.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityGestureTargetsObserver.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/SecureSettingsContentObserver.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java12
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/qs/QSAccessibilityModule.kt8
-rw-r--r--packages/SystemUI/src/com/android/systemui/battery/BatterySaverModule.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/domain/BiometricsDomainLayerModule.kt8
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractor.kt82
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinder.kt111
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt14
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModel.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt39
-rw-r--r--packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduStatsInteractor.kt64
-rw-r--r--packages/SystemUI/src/com/android/systemui/haptics/msdl/dagger/MSDLModule.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialCoreStartable.kt36
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt16
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractor.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractor.kt45
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardDismissActionBinder.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardDismissBinder.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt26
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt29
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt1
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/BouncerToGoneFlows.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DozingToOccludedTransitionViewModel.kt15
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/SideFpsProgressBarViewModel.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/log/dagger/BouncerTableLog.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/log/dagger/MediaDeviceLog.kt26
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImpl.kt166
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceLogger.kt116
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManager.kt60
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/domain/resume/MediaResumeListener.kt19
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModel.kt34
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverLogger.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverRippleController.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt45
-rw-r--r--packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java27
-rw-r--r--packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/qrcodescanner/dagger/QRCodeScannerModule.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt127
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/composefragment/viewmodel/QSFragmentComposeViewModel.kt31
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java34
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepository.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractor.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/shared/model/EditTileData.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/Tile.kt50
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/ui/model/TileGridCell.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModel.kt72
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/EditTileViewModel.kt37
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/pipeline/dagger/QSTileListLog.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/shared/model/TileCategory.kt46
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfig.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProvider.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java21
-rw-r--r--packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueModule.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/rotationlock/RotationLockNewModule.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt24
-rw-r--r--packages/SystemUI/src/com/android/systemui/scene/domain/resolver/NotifShadeSceneFamilyResolver.kt14
-rw-r--r--packages/SystemUI/src/com/android/systemui/scene/domain/resolver/QuickSettingsSceneFamilyResolver.kt14
-rw-r--r--packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt70
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordModule.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/LegacyScreenshotController.java78
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/SaveImageInBackgroundTask.java399
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java78
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/appclips/AppClipsViewModel.java136
-rw-r--r--packages/SystemUI/src/com/android/systemui/screenshot/appclips/InternalBacklinksData.kt42
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/ShadeEmptyImplModule.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt18
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractor.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImpl.kt40
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractor.kt113
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java37
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/connectivity/ConnectivityModule.kt13
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt20
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java24
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/WifiRepository.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/demo/DemoWifiRepository.kt8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImpl.kt59
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/shared/model/WifiNetworkModel.kt150
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/PolicyModule.kt12
-rw-r--r--packages/SystemUI/src/com/android/systemui/wallet/dagger/WalletModule.java6
-rw-r--r--packages/SystemUI/tests/goldens/bouncerPredictiveBackMotion.json831
-rw-r--r--packages/SystemUI/tests/src/com/android/keyguard/CarrierTextManagerTest.java2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityButtonModeObserverTest.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityButtonTargetsObserverTest.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityGestureTargetsObserverTest.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/accessibility/SecureSettingsContentObserverTest.java3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/composable/BouncerPredictiveBackTest.kt348
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialCoreStartableTest.kt60
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorTest.kt13
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt49
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerTest.kt4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/resume/MediaResumeListenerTest.kt59
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/external/TileLifecycleManagerTest.java155
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt6
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileNewImplTest.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/screenshot/SaveImageInBackgroundTaskTest.kt278
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/screenshot/appclips/AppClipsViewModelTest.java83
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java5
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java19
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepositoryTest.kt18
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt12
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/domain/interactor/DeviceBasedSatelliteInteractorTest.kt2
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModelTest.kt4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModelTest.kt10
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImplTest.kt38
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/shared/model/WifiNetworkModelTest.kt116
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/view/ModernStatusBarWifiViewTest.kt4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelIconParameterizedTest.kt42
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorKosmos.kt32
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinderKosmos.kt20
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModelKosmos.kt8
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorKosmos.kt12
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/inputdevice/tutorial/InputDeviceTutorialKosmos.kt12
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorKosmos.kt11
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt2
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceLoggerKosmos.kt23
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerKosmos.kt1
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/qs/external/TileLifecycleManagerKosmos.kt2
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelKosmos.kt4
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/di/NewQSTileFactoryKosmos.kt2
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigTestBuilder.kt3
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/resolver/SceneResolverKosmos.kt6
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeInteractorKosmos.kt4
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorKosmos.kt29
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/FakeWifiRepository.kt2
-rw-r--r--packages/SystemUI/tests/utils/src/com/android/systemui/volume/data/repository/FakeAudioRepository.kt8
-rw-r--r--packages/services/CameraExtensionsProxy/src/com/android/cameraextensions/CameraExtensionsProxyService.java14
-rw-r--r--ravenwood/Android.bp7
-rw-r--r--ravenwood/TEST_MAPPING4
-rw-r--r--ravenwood/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodConfigTest.java50
-rw-r--r--ravenwood/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodMultipleRuleTest.java57
-rw-r--r--ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java104
-rw-r--r--ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRunnerState.java252
-rw-r--r--ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java (renamed from ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java)115
-rw-r--r--ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java10
-rw-r--r--ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodTestStats.java32
-rw-r--r--ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodAwareTestRunner.java361
-rw-r--r--ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java184
-rw-r--r--ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java129
-rw-r--r--ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java28
-rw-r--r--ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java37
-rw-r--r--ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java34
-rw-r--r--ravenwood/runtime-helper-src/framework/android/os/Parcel_host.java530
-rw-r--r--ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java34
-rw-r--r--ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java11
-rw-r--r--ravenwood/tests/coretest/Android.bp25
-rw-r--r--ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerCallbackTest.java356
-rw-r--r--ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerConfigValidationTest.java452
-rw-r--r--ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerTestBase.java220
-rw-r--r--ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/adapter/RunnerRewritingAdapter.kt8
-rw-r--r--services/accessibility/Android.bp13
-rw-r--r--services/accessibility/TEST_MAPPING32
-rw-r--r--services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java49
-rw-r--r--services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java12
-rw-r--r--services/accessibility/java/com/android/server/accessibility/a11ychecker/Android.bp31
-rw-r--r--services/appfunctions/TEST_MAPPING10
-rw-r--r--services/appfunctions/java/com/android/server/appfunctions/CallerValidatorImpl.java11
-rw-r--r--services/appfunctions/java/com/android/server/appfunctions/FutureAppSearchSession.java21
-rw-r--r--services/appfunctions/java/com/android/server/appfunctions/MetadataSyncAdapter.java191
-rw-r--r--services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java7
-rw-r--r--services/core/java/com/android/server/BatteryService.java62
-rw-r--r--services/core/java/com/android/server/am/BatteryStatsService.java6
-rw-r--r--services/core/java/com/android/server/am/CachedAppOptimizer.java2
-rw-r--r--services/core/java/com/android/server/am/OomAdjuster.java25
-rw-r--r--services/core/java/com/android/server/am/ProcessList.java41
-rw-r--r--services/core/java/com/android/server/am/SettingsToPropertiesMapper.java4
-rw-r--r--services/core/java/com/android/server/biometrics/AuthService.java26
-rw-r--r--services/core/java/com/android/server/biometrics/PreAuthInfo.java8
-rw-r--r--services/core/java/com/android/server/biometrics/Utils.java8
-rw-r--r--services/core/java/com/android/server/biometrics/sensors/fingerprint/FingerprintService.java25
-rw-r--r--services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/BiometricTestSessionImpl.java8
-rw-r--r--services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java27
-rw-r--r--services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/Sensor.java6
-rw-r--r--services/core/java/com/android/server/broadcastradio/BroadcastRadioService.java5
-rw-r--r--services/core/java/com/android/server/broadcastradio/IRadioServiceAidlImpl.java5
-rw-r--r--services/core/java/com/android/server/broadcastradio/IRadioServiceHidlImpl.java9
-rw-r--r--services/core/java/com/android/server/broadcastradio/RadioServiceUserController.java42
-rw-r--r--services/core/java/com/android/server/broadcastradio/RadioServiceUserControllerImpl.java62
-rw-r--r--services/core/java/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImpl.java10
-rw-r--r--services/core/java/com/android/server/broadcastradio/aidl/RadioModule.java14
-rw-r--r--services/core/java/com/android/server/broadcastradio/aidl/TunerSession.java27
-rw-r--r--services/core/java/com/android/server/broadcastradio/hal1/BroadcastRadioService.java7
-rw-r--r--services/core/java/com/android/server/broadcastradio/hal1/Tuner.java22
-rw-r--r--services/core/java/com/android/server/broadcastradio/hal2/BroadcastRadioService.java14
-rw-r--r--services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java16
-rw-r--r--services/core/java/com/android/server/broadcastradio/hal2/TunerSession.java31
-rw-r--r--services/core/java/com/android/server/camera/CameraServiceProxy.java13
-rw-r--r--services/core/java/com/android/server/display/BrightnessRangeController.java3
-rw-r--r--services/core/java/com/android/server/display/DisplayManagerService.java22
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java5
-rw-r--r--services/core/java/com/android/server/display/HighBrightnessModeController.java2
-rw-r--r--services/core/java/com/android/server/flags/services.aconfig11
-rw-r--r--services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java12
-rw-r--r--services/core/java/com/android/server/input/InputManagerService.java8
-rw-r--r--services/core/java/com/android/server/input/debug/TouchpadDebugView.java88
-rw-r--r--services/core/java/com/android/server/input/debug/TouchpadDebugViewController.java32
-rw-r--r--services/core/java/com/android/server/input/debug/TouchpadVisualizationView.java130
-rw-r--r--services/core/java/com/android/server/location/gnss/GnssConfiguration.java7
-rw-r--r--services/core/java/com/android/server/location/gnss/GnssLocationProvider.java89
-rw-r--r--services/core/java/com/android/server/locksettings/LockSettingsService.java18
-rw-r--r--services/core/java/com/android/server/logcat/TEST_MAPPING7
-rw-r--r--services/core/java/com/android/server/notification/BubbleExtractor.java38
-rw-r--r--services/core/java/com/android/server/notification/ManagedServices.java8
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java1
-rw-r--r--services/core/java/com/android/server/notification/NotificationRecord.java15
-rw-r--r--services/core/java/com/android/server/notification/VibratorHelper.java31
-rw-r--r--services/core/java/com/android/server/notification/flags.aconfig7
-rw-r--r--services/core/java/com/android/server/om/OverlayManagerService.java13
-rw-r--r--services/core/java/com/android/server/pm/InstallPackageHelper.java101
-rw-r--r--services/core/java/com/android/server/pm/PackageArchiver.java42
-rw-r--r--services/core/java/com/android/server/pm/PackageSetting.java12
-rw-r--r--services/core/java/com/android/server/power/stats/PowerStatsCollector.java3
-rw-r--r--services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java10
-rw-r--r--services/core/java/com/android/server/statusbar/StatusBarManagerService.java149
-rw-r--r--services/core/java/com/android/server/vcn/routeselection/IpSecPacketLossDetector.java4
-rw-r--r--services/core/java/com/android/server/wallpaper/WallpaperManagerService.java51
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java9
-rw-r--r--services/core/java/com/android/server/wm/AppCompatAspectRatioPolicy.java7
-rw-r--r--services/core/java/com/android/server/wm/AppCompatCameraOverrides.java30
-rw-r--r--services/core/java/com/android/server/wm/AppCompatCameraPolicy.java12
-rw-r--r--services/core/java/com/android/server/wm/AppCompatOrientationPolicy.java7
-rw-r--r--services/core/java/com/android/server/wm/BackNavigationController.java83
-rw-r--r--services/core/java/com/android/server/wm/DesktopAppCompatAspectRatioPolicy.java6
-rw-r--r--services/core/java/com/android/server/wm/Dimmer.java31
-rw-r--r--services/core/java/com/android/server/wm/DimmerAnimationHelper.java41
-rw-r--r--services/core/java/com/android/server/wm/DisplayPolicy.java8
-rw-r--r--services/core/java/com/android/server/wm/DisplayRotation.java10
-rw-r--r--services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java21
-rw-r--r--services/core/java/com/android/server/wm/LockTaskController.java2
-rw-r--r--services/core/java/com/android/server/wm/Task.java14
-rw-r--r--services/core/java/com/android/server/wm/Transition.java62
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java54
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java33
-rw-r--r--services/core/jni/com_android_server_vibrator_VibratorController.cpp33
-rw-r--r--services/tests/appfunctions/src/android/app/appfunctions/AppFunctionRuntimeMetadataTest.kt104
-rw-r--r--services/tests/appfunctions/src/com/android/server/appfunctions/FutureAppSearchSessionTest.kt57
-rw-r--r--services/tests/appfunctions/src/com/android/server/appfunctions/MetadataSyncAdapterTest.kt274
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java40
-rw-r--r--services/tests/mockingservicestests/Android.bp14
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java65
-rw-r--r--services/tests/servicestests/Android.bp61
-rw-r--r--services/tests/servicestests/src/com/android/server/accessibility/AccessibilityManagerServiceTest.java93
-rw-r--r--services/tests/servicestests/src/com/android/server/accessibility/AccessibilityUserStateTest.java47
-rw-r--r--services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java27
-rw-r--r--services/tests/servicestests/src/com/android/server/biometrics/PreAuthInfoTest.java24
-rw-r--r--services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTest.java24
-rw-r--r--services/tests/servicestests/src/com/android/server/webkit/TestSystemImpl.java8
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java179
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java2
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java87
-rw-r--r--services/tests/uiservicestests/src/com/android/server/notification/VibratorHelperTest.java59
-rw-r--r--services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorControllerProvider.java28
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java5
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/AppCompatCameraOverridesTest.java52
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/AppCompatCameraPolicyTest.java79
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DimmerTests.java151
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java34
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/LockTaskControllerTest.java4
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TransitionTests.java59
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java8
-rw-r--r--telecomm/java/com/android/internal/telecom/ITelecomService.aidl3
-rw-r--r--telephony/java/android/telephony/CarrierConfigManager.java15
-rw-r--r--tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/GameActivity.java4
-rw-r--r--tests/Input/src/com/android/server/input/debug/TouchpadDebugViewControllerTests.java4
-rw-r--r--tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java36
-rw-r--r--tests/Internal/src/com/android/internal/protolog/PerfettoProtoLogImplTest.java25
-rw-r--r--tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java1
501 files changed, 12046 insertions, 5863 deletions
diff --git a/AconfigFlags.bp b/AconfigFlags.bp
index df4a3e5c3b35..bd17d6d2ece5 100644
--- a/AconfigFlags.bp
+++ b/AconfigFlags.bp
@@ -20,6 +20,7 @@ aconfig_declarations_group {
java_aconfig_libraries: [
// !!! KEEP THIS LIST ALPHABETICAL !!!
"aconfig_mediacodec_flags_java_lib",
+ "android-sdk-flags-java",
"android.adaptiveauth.flags-aconfig-java",
"android.app.appfunctions.flags-aconfig-java",
"android.app.contextualsearch.flags-aconfig-java",
diff --git a/Android.bp b/Android.bp
index f8907f3d82e8..258440f24084 100644
--- a/Android.bp
+++ b/Android.bp
@@ -98,6 +98,7 @@ filegroup {
":android.frameworks.location.altitude-V2-java-source",
":android.hardware.biometrics.common-V4-java-source",
":android.hardware.biometrics.fingerprint-V5-java-source",
+ ":android.hardware.biometrics.fingerprint.virtualhal-java-source",
":android.hardware.biometrics.face-V4-java-source",
":android.hardware.gnss-V2-java-source",
":android.hardware.graphics.common-V3-java-source",
diff --git a/BROADCASTS_OWNERS b/BROADCASTS_OWNERS
index 01f1f8a6ba57..f0cbe46ea402 100644
--- a/BROADCASTS_OWNERS
+++ b/BROADCASTS_OWNERS
@@ -1,5 +1,5 @@
# Bug component: 316181
-ctate@android.com
-jsharkey@google.com
+set noparent
+
sudheersai@google.com
yamasani@google.com #{LAST_RESORT_SUGGESTION}
diff --git a/android-sdk-flags/Android.bp b/android-sdk-flags/Android.bp
new file mode 100644
index 000000000000..79a0b9a4f273
--- /dev/null
+++ b/android-sdk-flags/Android.bp
@@ -0,0 +1,30 @@
+// Copyright (C) 2024 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 {
+ default_applicable_licenses: ["frameworks_base_license"],
+}
+
+aconfig_declarations {
+ name: "android-sdk-flags",
+ package: "android.sdk",
+ container: "system",
+ srcs: ["flags.aconfig"],
+}
+
+java_aconfig_library {
+ name: "android-sdk-flags-java",
+ aconfig_declarations: "android-sdk-flags",
+ defaults: ["framework-minus-apex-aconfig-java-defaults"],
+}
diff --git a/android-sdk-flags/flags.aconfig b/android-sdk-flags/flags.aconfig
new file mode 100644
index 000000000000..cfe298e187d1
--- /dev/null
+++ b/android-sdk-flags/flags.aconfig
@@ -0,0 +1,12 @@
+package: "android.sdk"
+container: "system"
+
+flag {
+ name: "major_minor_versioning_scheme"
+ namespace: "android_sdk"
+ description: "Use the new SDK major.minor versioning scheme (e.g. Android 40.1) which replaces the old single-integer scheme (e.g. Android 15)."
+ bug: "350458259"
+
+ # Use is_fixed_read_only because DeviceConfig may not be available when Build.VERSION_CODES is first accessed
+ is_fixed_read_only: true
+}
diff --git a/apex/blobstore/OWNERS b/apex/blobstore/OWNERS
index a53bbeaa8601..676cbc7eb2a3 100644
--- a/apex/blobstore/OWNERS
+++ b/apex/blobstore/OWNERS
@@ -1,2 +1,5 @@
+# Bug component: 25692
+set noparent
+
sudheersai@google.com
-yamasani@google.com
+yamasani@google.com #{LAST_RESORT_SUGGESTION}
diff --git a/apex/jobscheduler/service/java/com/android/server/usage/TEST_MAPPING b/apex/jobscheduler/service/java/com/android/server/usage/TEST_MAPPING
index 52670a2570d3..dd0d1b6285de 100644
--- a/apex/jobscheduler/service/java/com/android/server/usage/TEST_MAPPING
+++ b/apex/jobscheduler/service/java/com/android/server/usage/TEST_MAPPING
@@ -10,14 +10,10 @@
]
},
{
- "name": "CtsBRSTestCases",
- "options": [
- {"exclude-annotation": "androidx.test.filters.FlakyTest"},
- {"exclude-annotation": "org.junit.Ignore"}
- ]
+ "name": "CtsBRSTestCases"
},
{
- "name": "FrameworksServicesTests_com_android_server_usage_Presubmit"
+ "name": "FrameworksServicesTests_com_android_server_usage"
}
],
"postsubmit": [
diff --git a/boot/hiddenapi/hiddenapi-unsupported.txt b/boot/hiddenapi/hiddenapi-unsupported.txt
index adcc3df2d7fe..70e5a68745bc 100644
--- a/boot/hiddenapi/hiddenapi-unsupported.txt
+++ b/boot/hiddenapi/hiddenapi-unsupported.txt
@@ -183,7 +183,6 @@ Landroid/view/autofill/IAutoFillManager$Stub$Proxy;-><init>(Landroid/os/IBinder;
Landroid/view/autofill/IAutoFillManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/view/autofill/IAutoFillManager;
Landroid/view/IAppTransitionAnimationSpecsFuture$Stub;-><init>()V
Landroid/view/IDockedStackListener$Stub;-><init>()V
-Landroid/view/IRecentsAnimationRunner$Stub;-><init>()V
Landroid/view/IRemoteAnimationRunner$Stub;-><init>()V
Landroid/view/IRotationWatcher$Stub;-><init>()V
Landroid/view/IWindow$Stub;-><init>()V
diff --git a/core/api/current.txt b/core/api/current.txt
index 5e8febebee0e..14e749344247 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -32771,6 +32771,7 @@ package android.os {
field @NonNull public static final String RELEASE_OR_PREVIEW_DISPLAY;
field @Deprecated public static final String SDK;
field public static final int SDK_INT;
+ field @FlaggedApi("android.sdk.major_minor_versioning_scheme") public static final int SDK_MINOR_INT;
field public static final String SECURITY_PATCH;
}
@@ -34265,9 +34266,14 @@ package android.os {
method public final int areAllEffectsSupported(@NonNull int...);
method public final boolean areAllPrimitivesSupported(@NonNull int...);
method @NonNull public int[] areEffectsSupported(@NonNull int...);
+ method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public boolean areEnvelopeEffectsSupported();
method @NonNull public boolean[] arePrimitivesSupported(@NonNull int...);
method @RequiresPermission(android.Manifest.permission.VIBRATE) public abstract void cancel();
method public int getId();
+ method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public int getMaxEnvelopeEffectControlPointDurationMillis();
+ method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public int getMaxEnvelopeEffectDurationMillis();
+ method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public int getMaxEnvelopeEffectSize();
+ method @FlaggedApi("android.os.vibrator.normalized_pwle_effects") public int getMinEnvelopeEffectControlPointDurationMillis();
method @NonNull public int[] getPrimitiveDurations(@NonNull int...);
method public float getQFactor();
method public float getResonantFrequency();
@@ -44066,6 +44072,7 @@ package android.telephony {
}
public static final class CarrierConfigManager.Gps {
+ field @FlaggedApi("android.location.flags.enable_ni_supl_message_injection_by_carrier_config") public static final String KEY_ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL = "gps.enable_ni_supl_message_injection_bool";
field public static final String KEY_PERSIST_LPP_MODE_BOOL = "gps.persist_lpp_mode_bool";
field public static final String KEY_PREFIX = "gps.";
}
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 60dc52b655d6..fb425a99732a 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -10561,6 +10561,7 @@ package android.nfc.cardemulation {
method @FlaggedApi("android.nfc.nfc_observe_mode") public boolean shouldDefaultToObserveMode();
method @FlaggedApi("android.nfc.enable_nfc_mainline") public void writeToParcel(@NonNull android.os.Parcel, int);
field @FlaggedApi("android.nfc.enable_nfc_mainline") @NonNull public static final android.os.Parcelable.Creator<android.nfc.cardemulation.ApduServiceInfo> CREATOR;
+ field @FlaggedApi("android.permission.flags.wallet_role_icon_property_enabled") public static final String PROPERTY_WALLET_PREFERRED_BANNER_AND_LABEL = "android.nfc.cardemulation.PROPERTY_WALLET_PREFERRED_BANNER_AND_LABEL";
}
@FlaggedApi("android.nfc.enable_nfc_mainline") public final class NfcFServiceInfo implements android.os.Parcelable {
@@ -18155,9 +18156,17 @@ package android.view {
field public static final int DISPLAY_IME_POLICY_LOCAL = 0; // 0x0
}
+ @FlaggedApi("android.companion.virtualdevice.flags.status_bar_and_insets") public static class WindowManager.InsetsParams {
+ ctor public WindowManager.InsetsParams(int);
+ method @Nullable public android.graphics.Insets getInsetsSize();
+ method public int getType();
+ method @NonNull public android.view.WindowManager.InsetsParams setInsetsSize(@Nullable android.graphics.Insets);
+ }
+
public static class WindowManager.LayoutParams extends android.view.ViewGroup.LayoutParams implements android.os.Parcelable {
method public final long getUserActivityTimeout();
method public boolean isSystemApplicationOverlay();
+ method @FlaggedApi("android.companion.virtualdevice.flags.status_bar_and_insets") public void setInsetsParams(@NonNull java.util.List<android.view.WindowManager.InsetsParams>);
method @RequiresPermission(android.Manifest.permission.SYSTEM_APPLICATION_OVERLAY) public void setSystemApplicationOverlay(boolean);
method public final void setUserActivityTimeout(long);
field @RequiresPermission(android.Manifest.permission.HIDE_NON_SYSTEM_OVERLAY_WINDOWS) public static final int SYSTEM_FLAG_HIDE_NON_SYSTEM_OVERLAY_WINDOWS = 524288; // 0x80000
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index b4fb4803a2b9..7273e64846c0 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -247,6 +247,14 @@ public class ActivityManager {
@GuardedBy("mMemoryInfoCache")
private static final MemoryInfo mRateLimitedMemInfo = new MemoryInfo();
+ /** Rate-Limiting cache that allows no more than 200 calls to the service per second. */
+ @GuardedBy("mMyMemoryStateCache")
+ private static final RateLimitingCache<RunningAppProcessInfo> mMyMemoryStateCache =
+ new RateLimitingCache<>(10, 2);
+ /** Used to store cached results for rate-limited calls to getMyMemoryState(). */
+ @GuardedBy("mMyMemoryStateCache")
+ private static final RunningAppProcessInfo mRateLimitedMemState = new RunningAppProcessInfo();
+
/**
* Query handler for mGetCurrentUserIdCache - returns a cached value of the current foreground
* user id if the backstage_power/android.app.cache_get_current_user_id flag is enabled.
@@ -4223,6 +4231,23 @@ public class ActivityManager {
lastActivityTime = source.readLong();
}
+ /**
+ * Note: only fields that are updated in ProcessList.fillInProcMemInfoLOSP() are copied.
+ * @hide
+ */
+ public void copyTo(RunningAppProcessInfo other) {
+ other.pid = pid;
+ other.uid = uid;
+ other.flags = flags;
+ other.lastTrimLevel = lastTrimLevel;
+ other.importance = importance;
+ other.lru = lru;
+ other.importanceReasonCode = importanceReasonCode;
+ other.processState = processState;
+ other.isFocused = isFocused;
+ other.lastActivityTime = lastActivityTime;
+ }
+
public static final @android.annotation.NonNull Creator<RunningAppProcessInfo> CREATOR =
new Creator<RunningAppProcessInfo>() {
public RunningAppProcessInfo createFromParcel(Parcel source) {
@@ -4854,7 +4879,21 @@ public class ActivityManager {
* {@link RunningAppProcessInfo#lru}, and
* {@link RunningAppProcessInfo#importanceReasonCode}.
*/
- static public void getMyMemoryState(RunningAppProcessInfo outState) {
+ public static void getMyMemoryState(RunningAppProcessInfo outState) {
+ if (Flags.rateLimitGetMyMemoryState()) {
+ synchronized (mMyMemoryStateCache) {
+ mMyMemoryStateCache.get(() -> {
+ getMyMemoryStateInternal(mRateLimitedMemState);
+ return mRateLimitedMemState;
+ });
+ mRateLimitedMemState.copyTo(outState);
+ }
+ } else {
+ getMyMemoryStateInternal(outState);
+ }
+ }
+
+ private static void getMyMemoryStateInternal(RunningAppProcessInfo outState) {
try {
getService().getMyMemoryState(outState);
} catch (RemoteException e) {
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 7a36fbb55dc4..7a33ab748597 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -1593,6 +1593,17 @@ public class Notification implements Parcelable
*/
@FlaggedApi(Flags.FLAG_API_RICH_ONGOING)
public static final String EXTRA_ENROUTE_LARGE_ICON_SUBTEXT = "android.enrouteLargeIconSubText";
+
+ /**
+ * {@link #extras} key: {@link Icon} of an image used as a thumb icon on
+ * {@link Notification} progress bar for {@link EnRouteStyle} notifications.
+ * This extra is an {@code Icon}.
+ * @hide
+ */
+ @FlaggedApi(Flags.FLAG_API_RICH_ONGOING)
+ public static final String EXTRA_ENROUTE_PROGRESS_THUMB_ICON =
+ "android.enrouteProgressThumbIcon";
+
/**
* {@link #extras} key: whether the notification should be colorized as
* supplied to {@link Builder#setColorized(boolean)}.
@@ -3052,6 +3063,8 @@ public class Notification implements Parcelable
if (Flags.apiRichOngoing()) {
visitIconUri(visitor, extras.getParcelable(EXTRA_ENROUTE_OVERLAY_ICON, Icon.class));
+ visitIconUri(visitor, extras.getParcelable(EXTRA_ENROUTE_PROGRESS_THUMB_ICON,
+ Icon.class));
}
if (mBubbleMetadata != null) {
@@ -11015,6 +11028,9 @@ public class Notification implements Parcelable
@Nullable
private CharSequence mLargeIconSubText = null;
+ @Nullable
+ private Icon mProgressThumbIcon = null;
+
public EnRouteStyle() {
}
@@ -11058,6 +11074,25 @@ public class Notification implements Parcelable
return this;
}
+ /**
+ * Returns the progress thumb icon.
+ * @see EnRouteStyle#setProgressThumbIcon
+ */
+ @Nullable
+ public Icon getProgressThumbIcon() {
+ return mProgressThumbIcon;
+ }
+
+ /**
+ * Optional icon to be used as a progress thumb.
+ */
+ @NonNull
+ public EnRouteStyle setProgressThumbIcon(@Nullable Icon progressThumbIcon) {
+ mProgressThumbIcon = progressThumbIcon;
+ return this;
+ }
+
+
/**
* @hide
*/
@@ -11069,7 +11104,8 @@ public class Notification implements Parcelable
final EnRouteStyle enRouteStyle = (EnRouteStyle) other;
return !Objects.equals(mOverlayIcon, enRouteStyle.mOverlayIcon)
- || !Objects.equals(mLargeIconSubText, enRouteStyle.mLargeIconSubText);
+ || !Objects.equals(mLargeIconSubText, enRouteStyle.mLargeIconSubText)
+ || !Objects.equals(mProgressThumbIcon, enRouteStyle.mProgressThumbIcon);
}
/**
@@ -11080,6 +11116,7 @@ public class Notification implements Parcelable
super.addExtras(extras);
extras.putParcelable(EXTRA_ENROUTE_OVERLAY_ICON, mOverlayIcon);
extras.putCharSequence(EXTRA_ENROUTE_LARGE_ICON_SUBTEXT, mLargeIconSubText);
+ extras.putParcelable(EXTRA_ENROUTE_PROGRESS_THUMB_ICON, mProgressThumbIcon);
}
/**
@@ -11090,6 +11127,8 @@ public class Notification implements Parcelable
super.restoreFromExtras(extras);
mOverlayIcon = extras.getParcelable(EXTRA_ENROUTE_OVERLAY_ICON, Icon.class);
mLargeIconSubText = extras.getCharSequence(EXTRA_ENROUTE_LARGE_ICON_SUBTEXT);
+ mProgressThumbIcon =
+ extras.getParcelable(EXTRA_ENROUTE_PROGRESS_THUMB_ICON, Icon.class);
}
/**
@@ -11101,6 +11140,10 @@ public class Notification implements Parcelable
if (mOverlayIcon != null) {
mOverlayIcon.convertToAshmem();
}
+
+ if (mProgressThumbIcon != null) {
+ mProgressThumbIcon.convertToAshmem();
+ }
}
/**
diff --git a/core/java/android/app/NotificationChannel.java b/core/java/android/app/NotificationChannel.java
index 1b29b7a294df..32e9542e91a7 100644
--- a/core/java/android/app/NotificationChannel.java
+++ b/core/java/android/app/NotificationChannel.java
@@ -761,14 +761,22 @@ public final class NotificationChannel implements Parcelable {
this.mVibrationEnabled = effect != null;
this.mVibrationEffect = effect;
if (Flags.notifChannelCropVibrationEffects() && effect != null) {
- // Try converting to a vibration pattern and trimming that array. If not convertible
- // to a pattern directly, try trimming the vibration effect if possible and storing
- // that version instead.
long[] pattern = effect.computeCreateWaveformOffOnTimingsOrNull();
if (pattern != null) {
- setVibrationPattern(pattern);
+ // If this effect has an equivalent pattern, AND the pattern needs to be truncated
+ // due to being too long, we delegate to setVibrationPattern to re-generate the
+ // effect as well. Otherwise, we use the effect (already set above) and converted
+ // pattern directly.
+ if (pattern.length > MAX_VIBRATION_LENGTH) {
+ setVibrationPattern(pattern);
+ } else {
+ this.mVibrationPattern = pattern;
+ }
} else {
+ // If not convertible to a pattern directly, try trimming the vibration effect if
+ // possible and storing that version instead.
this.mVibrationEffect = getTrimmedVibrationEffect(mVibrationEffect);
+ this.mVibrationPattern = null;
}
} else {
this.mVibrationPattern =
diff --git a/core/java/android/app/activity_manager.aconfig b/core/java/android/app/activity_manager.aconfig
index c0c81df465e2..38bd576d607a 100644
--- a/core/java/android/app/activity_manager.aconfig
+++ b/core/java/android/app/activity_manager.aconfig
@@ -136,3 +136,14 @@ flag {
purpose: PURPOSE_BUGFIX
}
}
+
+flag {
+ namespace: "backstage_power"
+ name: "rate_limit_get_my_memory_state"
+ description: "Rate limit calls to getMyMemoryState using a cache"
+ is_fixed_read_only: true
+ bug: "365182205"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
diff --git a/core/java/android/app/admin/flags/flags.aconfig b/core/java/android/app/admin/flags/flags.aconfig
index 8e08a95dad70..081dfe60d28c 100644
--- a/core/java/android/app/admin/flags/flags.aconfig
+++ b/core/java/android/app/admin/flags/flags.aconfig
@@ -152,6 +152,16 @@ flag {
}
flag {
+ name: "fix_race_condition_in_tie_profile_lock"
+ namespace: "enterprise"
+ description: "Fix race condition in tieProfileLockIfNecessary()"
+ bug: "355905501"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "quiet_mode_credential_bug_fix"
namespace: "enterprise"
description: "Guards a bugfix that ends the credential input flow if the managed user has not stopped."
diff --git a/core/java/android/app/appfunctions/AppFunctionRuntimeMetadata.java b/core/java/android/app/appfunctions/AppFunctionRuntimeMetadata.java
index c4bfae98e33d..f5c5a11f45fb 100644
--- a/core/java/android/app/appfunctions/AppFunctionRuntimeMetadata.java
+++ b/core/java/android/app/appfunctions/AppFunctionRuntimeMetadata.java
@@ -61,6 +61,20 @@ public class AppFunctionRuntimeMetadata extends GenericDocument {
return RUNTIME_SCHEMA_TYPE + RUNTIME_SCHEMA_TYPE_SEPARATOR + Objects.requireNonNull(pkg);
}
+ /** Returns the package name from the runtime metadata schema name. */
+ @NonNull
+ public static String getPackageNameFromSchema(String metadataSchemaType) {
+ String[] split = metadataSchemaType.split(RUNTIME_SCHEMA_TYPE_SEPARATOR);
+ if (split.length > 2) {
+ throw new IllegalArgumentException(
+ "Invalid schema type: " + metadataSchemaType + " for app function runtime");
+ }
+ if (split.length < 2) {
+ return APP_FUNCTION_INDEXER_PACKAGE;
+ }
+ return split[1];
+ }
+
/** Returns the document id for an app function's runtime metadata. */
public static String getDocumentIdForAppFunction(
@NonNull String pkg, @NonNull String functionId) {
diff --git a/core/java/android/app/appfunctions/AppFunctionStaticMetadataHelper.java b/core/java/android/app/appfunctions/AppFunctionStaticMetadataHelper.java
index 926cc9a3642c..085e0a47d356 100644
--- a/core/java/android/app/appfunctions/AppFunctionStaticMetadataHelper.java
+++ b/core/java/android/app/appfunctions/AppFunctionStaticMetadataHelper.java
@@ -39,6 +39,8 @@ public class AppFunctionStaticMetadataHelper {
public static final String STATIC_PROPERTY_ENABLED_BY_DEFAULT = "enabledByDefault";
public static final String APP_FUNCTION_STATIC_NAMESPACE = "app_functions";
+ public static final String PROPERTY_FUNCTION_ID = "functionId";
+ public static final String PROPERTY_PACKAGE_NAME = "packageName";
// These are constants that has to be kept the same with {@code
// com.android.server.appsearch.appsindexer.appsearchtypes.AppSearchHelper}.
diff --git a/core/java/android/companion/virtual/flags/flags.aconfig b/core/java/android/companion/virtual/flags/flags.aconfig
index 748260bc8d5f..e9fa3e15fe05 100644
--- a/core/java/android/companion/virtual/flags/flags.aconfig
+++ b/core/java/android/companion/virtual/flags/flags.aconfig
@@ -43,6 +43,7 @@ flag {
name: "virtual_display_insets"
description: "APIs for specifying virtual display insets (via cutout)"
bug: "350007135"
+ is_exported: true
}
flag {
@@ -88,6 +89,7 @@ flag {
name: "virtual_display_rotation_api"
description: "API for on-demand rotation of virtual displays"
bug: "291748430"
+ is_exported: true
}
flag {
@@ -110,6 +112,7 @@ flag {
name: "device_aware_display_power"
description: "Device awareness in power and display APIs"
bug: "285020111"
+ is_exported: true
}
flag {
@@ -125,4 +128,12 @@ flag {
namespace: "virtual_devices"
description: "Allow for status bar and insets on virtual devices"
bug: "350007866"
+ is_exported: true
+}
+
+flag {
+ namespace: "virtual_devices"
+ name: "camera_timestamp_from_surface"
+ description: "Pass the surface timestamp to the capture result"
+ bug: "351341245"
}
diff --git a/core/java/android/content/pm/LauncherActivityInfo.java b/core/java/android/content/pm/LauncherActivityInfo.java
index cb3455b266cd..bb91a37825e6 100644
--- a/core/java/android/content/pm/LauncherActivityInfo.java
+++ b/core/java/android/content/pm/LauncherActivityInfo.java
@@ -43,9 +43,11 @@ public class LauncherActivityInfo {
private final PackageManager mPm;
private final LauncherActivityInfoInternal mInternal;
- private static final UnicodeSet TRIMMABLE_CHARACTERS =
+ private static final UnicodeSet INVISIBLE_CHARACTERS =
new UnicodeSet("[[:White_Space:][:Default_Ignorable_Code_Point:][:gc=Cc:]]",
/* ignoreWhitespace= */ false).freeze();
+ // Only allow 3 consecutive invisible characters in the prefix of the string.
+ private static final int PREFIX_CONSECUTIVE_INVISIBLE_CHARACTERS_MAXIMUM = 3;
/**
* Create a launchable activity object for a given ResolveInfo and user.
@@ -93,17 +95,21 @@ public class LauncherActivityInfo {
return getActivityInfo().loadLabel(mPm);
}
- CharSequence label = trim(getActivityInfo().loadLabel(mPm));
- // If the trimmed label is empty, use application's label instead
- if (TextUtils.isEmpty(label)) {
- label = trim(getApplicationInfo().loadLabel(mPm));
- // If the trimmed label is still empty, use package name instead
- if (TextUtils.isEmpty(label)) {
- label = getComponentName().getPackageName();
- }
+ CharSequence label = getActivityInfo().loadLabel(mPm).toString().trim();
+ // If the activity label is visible to the user, return the original activity label
+ if (isVisible(label)) {
+ return label;
}
- // TODO: Go through LauncherAppsService
- return label;
+
+ // Use application label instead
+ label = getApplicationInfo().loadLabel(mPm).toString().trim();
+ // If the application label is visible to the user, return the original application label
+ if (isVisible(label)) {
+ return label;
+ }
+
+ // Use package name instead
+ return getComponentName().getPackageName();
}
/**
@@ -207,147 +213,75 @@ public class LauncherActivityInfo {
}
/**
- * If the {@code ch} is trimmable, return {@code true}. Otherwise, return
- * {@code false}. If the count of the code points of {@code ch} doesn't
- * equal 1, return {@code false}.
+ * Check whether the {@code sequence} is visible to the user or not.
+ * <p>
+ * Return {@code false} when one of these conditions are satisfied:
+ * 1. The {@code sequence} starts with at least consecutive three invisible characters.
+ * 2. The sequence is composed of the invisible characters and non-glyph characters.
* <p>
- * There are two types of the trimmable characters.
- * 1. The character is one of the Default_Ignorable_Code_Point in
+ * Invisible character is one of the Default_Ignorable_Code_Point in
* <a href="
* https://www.unicode.org/Public/UCD/latest/ucd/DerivedCoreProperties.txt">
* DerivedCoreProperties.txt</a>, the White_Space in <a href=
* "https://www.unicode.org/Public/UCD/latest/ucd/PropList.txt">PropList.txt
* </a> or category Cc.
* <p>
- * 2. The character is not supported in the current system font.
+ * Non-glyph character means the character is not supported in the current system font.
* {@link android.graphics.Paint#hasGlyph(String)}
* <p>
*
- */
- private static boolean isTrimmable(@NonNull Paint paint, @NonNull CharSequence ch) {
- Objects.requireNonNull(paint);
- Objects.requireNonNull(ch);
-
- // if ch is empty or it is not a character (i,e, the count of code
- // point doesn't equal one), return false
- if (TextUtils.isEmpty(ch)
- || Character.codePointCount(ch, /* beginIndex= */ 0, ch.length()) != 1) {
- return false;
- }
-
- // Return true for the cases as below:
- // 1. The character is in the TRIMMABLE_CHARACTERS set
- // 2. The character is not supported in the system font
- return TRIMMABLE_CHARACTERS.contains(ch) || !paint.hasGlyph(ch.toString());
- }
-
- /**
- * If the {@code sequence} has some leading trimmable characters, creates a new copy
- * and removes the trimmable characters from the copy. Otherwise the given
- * {@code sequence} is returned as it is. Use {@link #isTrimmable(Paint, CharSequence)}
- * to determine whether the character is trimmable or not.
- *
- * @return the trimmed string or the original string that has no
- * leading trimmable characters.
- * @see #isTrimmable(Paint, CharSequence)
- * @see #trim(CharSequence)
- * @see #trimEnd(CharSequence)
- *
* @hide
*/
@VisibleForTesting
- @NonNull
- public static CharSequence trimStart(@NonNull CharSequence sequence) {
+ public static boolean isVisible(@NonNull CharSequence sequence) {
Objects.requireNonNull(sequence);
-
if (TextUtils.isEmpty(sequence)) {
- return sequence;
+ return false;
}
final Paint paint = new Paint();
- int trimCount = 0;
+ int invisibleCharCount = 0;
+ int notSupportedCharCount = 0;
final int[] codePoints = sequence.codePoints().toArray();
for (int i = 0, length = codePoints.length; i < length; i++) {
String ch = new String(new int[]{codePoints[i]}, /* offset= */ 0, /* count= */ 1);
- if (!isTrimmable(paint, ch)) {
- break;
- }
- trimCount += ch.length();
- }
- if (trimCount == 0) {
- return sequence;
- }
- return sequence.subSequence(trimCount, sequence.length());
- }
- /**
- * If the {@code sequence} has some trailing trimmable characters, creates a new copy
- * and removes the trimmable characters from the copy. Otherwise the given
- * {@code sequence} is returned as it is. Use {@link #isTrimmable(Paint, CharSequence)}
- * to determine whether the character is trimmable or not.
- *
- * @return the trimmed sequence or the original sequence that has no
- * trailing trimmable characters.
- * @see #isTrimmable(Paint, CharSequence)
- * @see #trimStart(CharSequence)
- * @see #trim(CharSequence)
- *
- * @hide
- */
- @VisibleForTesting
- @NonNull
- public static CharSequence trimEnd(@NonNull CharSequence sequence) {
- Objects.requireNonNull(sequence);
-
- if (TextUtils.isEmpty(sequence)) {
- return sequence;
- }
-
- final Paint paint = new Paint();
- int trimCount = 0;
- final int[] codePoints = sequence.codePoints().toArray();
- for (int i = codePoints.length - 1; i >= 0; i--) {
- String ch = new String(new int[]{codePoints[i]}, /* offset= */ 0, /* count= */ 1);
- if (!isTrimmable(paint, ch)) {
- break;
+ // The check steps:
+ // 1. If the character is contained in INVISIBLE_CHARACTERS, invisibleCharCount++.
+ // 1.1 Check whether the invisibleCharCount is larger or equal to
+ // PREFIX_INVISIBLE_CHARACTERS_MAXIMUM when notSupportedCharCount is zero.
+ // It means that there are three consecutive invisible characters at the
+ // start of the string, return false.
+ // Otherwise, continue.
+ // 2. If the character is not supported on the system:
+ // notSupportedCharCount++, continue
+ // 3. If it does not continue or return on the above two cases, it means the
+ // character is visible and supported on the system, break.
+ // After going through the whole string, if the sum of invisibleCharCount
+ // and notSupportedCharCount is smaller than the length of the string, it
+ // means the string has the other visible characters, return true.
+ // Otherwise, return false.
+ if (INVISIBLE_CHARACTERS.contains(ch)) {
+ invisibleCharCount++;
+ // If there are three successive invisible characters at the start of the
+ // string, it is hard to visible to the user.
+ if (notSupportedCharCount == 0
+ && invisibleCharCount >= PREFIX_CONSECUTIVE_INVISIBLE_CHARACTERS_MAXIMUM) {
+ return false;
+ }
+ continue;
}
- trimCount += ch.length();
- }
-
- if (trimCount == 0) {
- return sequence;
- }
- return sequence.subSequence(0, sequence.length() - trimCount);
- }
- /**
- * If the {@code sequence} has some leading or trailing trimmable characters, creates
- * a new copy and removes the trimmable characters from the copy. Otherwise the given
- * {@code sequence} is returned as it is. Use {@link #isTrimmable(Paint, CharSequence)}
- * to determine whether the character is trimmable or not.
- *
- * @return the trimmed sequence or the original sequence that has no leading or
- * trailing trimmable characters.
- * @see #isTrimmable(Paint, CharSequence)
- * @see #trimStart(CharSequence)
- * @see #trimEnd(CharSequence)
- *
- * @hide
- */
- @VisibleForTesting
- @NonNull
- public static CharSequence trim(@NonNull CharSequence sequence) {
- Objects.requireNonNull(sequence);
-
- if (TextUtils.isEmpty(sequence)) {
- return sequence;
- }
-
- CharSequence result = trimStart(sequence);
- if (TextUtils.isEmpty(result)) {
- return result;
+ // The character is not supported on the system, but it may not be an invisible
+ // character. E.g. tofu (a rectangle).
+ if (!paint.hasGlyph(ch)) {
+ notSupportedCharCount++;
+ continue;
+ }
+ // The character is visible and supported on the system, break the for loop
+ break;
}
- return trimEnd(result);
+ return (invisibleCharCount + notSupportedCharCount < codePoints.length);
}
}
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 8c56a9d443ab..26bb6e4df325 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -8847,6 +8847,8 @@ public abstract class PackageManager {
} catch (PackageParserException e) {
Log.w(TAG, "Failure to parse package archive apkFile= " +apkFile);
return null;
+ } finally {
+ parser2.close();
}
}
diff --git a/core/java/android/database/sqlite/SQLiteDatabase.java b/core/java/android/database/sqlite/SQLiteDatabase.java
index f54be00c9e69..60fd0ce59209 100644
--- a/core/java/android/database/sqlite/SQLiteDatabase.java
+++ b/core/java/android/database/sqlite/SQLiteDatabase.java
@@ -236,15 +236,21 @@ public final class SQLiteDatabase extends SQLiteClosable {
*
* {@more} Note that the value of this flag is 0, so it is the default.
*/
- public static final int OPEN_READWRITE = 0x00000000; // update native code if changing
+ // LINT.IfChange
+ public static final int OPEN_READWRITE = 0x00000000;
+ // LINT.ThenChange(/core/jni/android_database_SQLiteConnection.cpp)
/**
* Open flag: Flag for {@link #openDatabase} to open the database for reading only.
* This is the only reliable way to open a database if the disk may be full.
*/
- public static final int OPEN_READONLY = 0x00000001; // update native code if changing
+ // LINT.IfChange
+ public static final int OPEN_READONLY = 0x00000001;
+ // LINT.ThenChange(/core/jni/android_database_SQLiteConnection.cpp)
- private static final int OPEN_READ_MASK = 0x00000001; // update native code if changing
+ // LINT.IfChange
+ private static final int OPEN_READ_MASK = 0x00000001;
+ // LINT.ThenChange(/core/jni/android_database_SQLiteConnection.cpp)
/**
* Open flag: Flag for {@link #openDatabase} to open the database without support for
@@ -254,13 +260,31 @@ public final class SQLiteDatabase extends SQLiteClosable {
* You must be consistent when using this flag to use the setting the database was
* created with. If this is set, {@link #setLocale} will do nothing.
*/
- public static final int NO_LOCALIZED_COLLATORS = 0x00000010; // update native code if changing
+ // LINT.IfChange
+ public static final int NO_LOCALIZED_COLLATORS = 0x00000010;
+ // LINT.ThenChange(/core/jni/android_database_SQLiteConnection.cpp)
+
+ /**
+ * Open flag: Flag for {@link #openDatabase} to open a database, disallowing double-quoted
+ * strings.
+ *
+ * This causes sqlite to reject SQL statements with double-quoted string literals. String
+ * literals must be enclosed in single quotes; double-quotes are reserved for identifiers like
+ * column names.
+ * See https://www.sqlite.org/quirks.html#double_quoted_string_literals_are_accepted
+ * @hide
+ */
+ // LINT.IfChange
+ public static final int NO_DOUBLE_QUOTED_STRS = 0x00000020;
+ // LINT.ThenChange(/core/jni/android_database_SQLiteConnection.cpp)
/**
* Open flag: Flag for {@link #openDatabase} to create the database file if it does not
* already exist.
*/
- public static final int CREATE_IF_NECESSARY = 0x10000000; // update native code if changing
+ // LINT.IfChange
+ public static final int CREATE_IF_NECESSARY = 0x10000000;
+ // LINT.ThenChange(/core/jni/android_database_SQLiteConnection.cpp)
/**
* Open flag: Flag for {@link #openDatabase} to open the database file with
@@ -490,6 +514,9 @@ public final class SQLiteDatabase extends SQLiteClosable {
if (SQLiteCompatibilityWalFlags.isLegacyCompatibilityWalEnabled()) {
mConfigurationLocked.openFlags |= ENABLE_LEGACY_COMPATIBILITY_WAL;
}
+ if (SQLiteDebug.NoPreloadHolder.NO_DOUBLE_QUOTED_STRS) {
+ mConfigurationLocked.openFlags |= NO_DOUBLE_QUOTED_STRS;
+ }
mConfigurationLocked.journalMode = journalMode;
mConfigurationLocked.syncMode = syncMode;
}
@@ -3275,6 +3302,7 @@ public final class SQLiteDatabase extends SQLiteClosable {
OPEN_READONLY,
CREATE_IF_NECESSARY,
NO_LOCALIZED_COLLATORS,
+ NO_DOUBLE_QUOTED_STRS,
ENABLE_WRITE_AHEAD_LOGGING
})
@Retention(RetentionPolicy.SOURCE)
diff --git a/core/java/android/database/sqlite/SQLiteDebug.java b/core/java/android/database/sqlite/SQLiteDebug.java
index 93d74b1fbdff..b648e053eea0 100644
--- a/core/java/android/database/sqlite/SQLiteDebug.java
+++ b/core/java/android/database/sqlite/SQLiteDebug.java
@@ -66,7 +66,6 @@ public final class SQLiteDebug {
public static final boolean DEBUG_SQL_TIME =
Log.isLoggable("SQLiteTime", Log.VERBOSE);
-
/**
* True to enable database performance testing instrumentation.
*/
@@ -83,6 +82,15 @@ public final class SQLiteDebug {
*/
public static final boolean DEBUG_LOG_DETAILED = Build.IS_DEBUGGABLE
&& SystemProperties.getBoolean("db.log.detailed", false);
+
+ /**
+ * Whether to accept double-quoted strings in SQL statements. Double-quoted strings are a
+ * syntax error but are accepted by sqlite in compatibility mode (the default). If the
+ * property is set to true, double-quoted strings will be treated by sqlite as a syntax
+ * error.
+ */
+ public static final boolean NO_DOUBLE_QUOTED_STRS =
+ SystemProperties.getBoolean("debug.sqlite.no_double_quoted_strs", false);
}
private SQLiteDebug() {
diff --git a/core/java/android/hardware/biometrics/BiometricConstants.java b/core/java/android/hardware/biometrics/BiometricConstants.java
index 8975191b54c1..9355937b0963 100644
--- a/core/java/android/hardware/biometrics/BiometricConstants.java
+++ b/core/java/android/hardware/biometrics/BiometricConstants.java
@@ -170,6 +170,12 @@ public interface BiometricConstants {
int BIOMETRIC_ERROR_MANDATORY_NOT_ACTIVE = 20;
/**
+ * Biometrics is not allowed to verify in apps.
+ * @hide
+ */
+ int BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS = 21;
+
+ /**
* This constant is only used by SystemUI. It notifies SystemUI that authentication was paused
* because the authentication attempt was unsuccessful.
* @hide
diff --git a/core/java/android/hardware/biometrics/BiometricManager.java b/core/java/android/hardware/biometrics/BiometricManager.java
index 9bc46b9f382a..a4f7485fcaa5 100644
--- a/core/java/android/hardware/biometrics/BiometricManager.java
+++ b/core/java/android/hardware/biometrics/BiometricManager.java
@@ -94,6 +94,13 @@ public class BiometricManager {
BiometricConstants.BIOMETRIC_ERROR_MANDATORY_NOT_ACTIVE;
/**
+ * Biometrics is not allowed to verify in apps.
+ * @hide
+ */
+ public static final int BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS =
+ BiometricConstants.BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS;
+
+ /**
* A security vulnerability has been discovered and the sensor is unavailable until a
* security update has addressed this issue. This error can be received if for example,
* authentication was requested with {@link Authenticators#BIOMETRIC_STRONG}, but the
diff --git a/core/java/android/hardware/fingerprint/FingerprintSensorConfigurations.java b/core/java/android/hardware/fingerprint/FingerprintSensorConfigurations.java
index 43c0da9bd8ed..48c5887d80d0 100644
--- a/core/java/android/hardware/fingerprint/FingerprintSensorConfigurations.java
+++ b/core/java/android/hardware/fingerprint/FingerprintSensorConfigurations.java
@@ -23,12 +23,14 @@ import android.annotation.Nullable;
import android.content.Context;
import android.hardware.biometrics.fingerprint.IFingerprint;
import android.hardware.biometrics.fingerprint.SensorProps;
+import android.hardware.biometrics.fingerprint.virtualhal.IVirtualHal;
import android.os.Binder;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.util.Log;
+import android.util.Slog;
import java.util.ArrayList;
import java.util.HashMap;
@@ -162,6 +164,43 @@ public class FingerprintSensorConfigurations implements Parcelable {
dest.writeMap(mSensorPropsMap);
}
+
+ /**
+ * Remap fqName of VHAL because the `virtual` instance is registered
+ * with IVirtulalHal now (IFingerprint previously)
+ * @param fqName fqName to be translated
+ * @return real fqName
+ */
+ public static String remapFqName(String fqName) {
+ if (!fqName.contains(IFingerprint.DESCRIPTOR + "/virtual")) {
+ return fqName; //no remap needed for real hardware HAL
+ } else {
+ //new Vhal instance name
+ return fqName.replace("IFingerprint", "virtualhal.IVirtualHal");
+ }
+ }
+
+ /**
+ * @param fqName aidl interface instance name
+ * @return aidl interface
+ */
+ public static IFingerprint getIFingerprint(String fqName) {
+ if (fqName.contains("virtual")) {
+ String fqNameMapped = remapFqName(fqName);
+ Slog.i(TAG, "getIFingerprint fqName is mapped: " + fqName + "->" + fqNameMapped);
+ try {
+ IVirtualHal vhal = IVirtualHal.Stub.asInterface(
+ Binder.allowBlocking(ServiceManager.waitForService(fqNameMapped)));
+ return vhal.getFingerprintHal();
+ } catch (RemoteException e) {
+ Slog.e(TAG, "Remote exception in vhal.getFingerprintHal() call" + fqNameMapped);
+ }
+ }
+
+ return IFingerprint.Stub.asInterface(
+ Binder.allowBlocking(ServiceManager.waitForDeclaredService(fqName)));
+ }
+
/**
* Returns fingerprint sensor props for the HAL {@param instance}.
*/
@@ -176,8 +215,7 @@ public class FingerprintSensorConfigurations implements Parcelable {
try {
final String fqName = IFingerprint.DESCRIPTOR + "/" + instance;
- final IFingerprint fp = IFingerprint.Stub.asInterface(Binder.allowBlocking(
- ServiceManager.waitForDeclaredService(fqName)));
+ final IFingerprint fp = getIFingerprint(fqName);
if (fp != null) {
props = fp.getSensorProps();
} else {
diff --git a/core/java/android/hardware/input/input_framework.aconfig b/core/java/android/hardware/input/input_framework.aconfig
index fcd6c31d7d18..4478592ae8a5 100644
--- a/core/java/android/hardware/input/input_framework.aconfig
+++ b/core/java/android/hardware/input/input_framework.aconfig
@@ -117,3 +117,10 @@ flag {
description: "Allow configurable timeout before key repeat and repeat delay rate for key repeats"
bug: "336585002"
}
+
+flag {
+ name: "mouse_reverse_vertical_scrolling"
+ namespace: "input"
+ description: "Controls whether external mouse vertical scrolling can be reversed"
+ bug: "352598211"
+}
diff --git a/core/java/android/net/vcn/flags.aconfig b/core/java/android/net/vcn/flags.aconfig
index d4d1ed22dd4e..dcb363ccf535 100644
--- a/core/java/android/net/vcn/flags.aconfig
+++ b/core/java/android/net/vcn/flags.aconfig
@@ -55,14 +55,4 @@ flag{
metadata {
purpose: PURPOSE_BUGFIX
}
-}
-
-flag{
- name: "allow_disable_ipsec_loss_detector"
- namespace: "vcn"
- description: "Allow disabling IPsec packet loss detector"
- bug: "336638836"
- metadata {
- purpose: PURPOSE_BUGFIX
- }
} \ No newline at end of file
diff --git a/core/java/android/os/Binder.java b/core/java/android/os/Binder.java
index 4bc3dbedeb94..97e9f34064ba 100644
--- a/core/java/android/os/Binder.java
+++ b/core/java/android/os/Binder.java
@@ -21,6 +21,8 @@ import android.annotation.Nullable;
import android.annotation.SystemApi;
import android.app.AppOpsManager;
import android.compat.annotation.UnsupportedAppUsage;
+import android.ravenwood.annotation.RavenwoodClassLoadHook;
+import android.ravenwood.annotation.RavenwoodKeepWholeClass;
import android.util.ExceptionUtils;
import android.util.Log;
import android.util.Slog;
@@ -30,11 +32,9 @@ import com.android.internal.os.BinderCallHeavyHitterWatcher;
import com.android.internal.os.BinderCallHeavyHitterWatcher.BinderCallHeavyHitterListener;
import com.android.internal.os.BinderInternal;
import com.android.internal.os.BinderInternal.CallSession;
-import com.android.internal.os.SomeArgs;
import com.android.internal.util.FastPrintWriter;
import com.android.internal.util.FunctionalUtils.ThrowingRunnable;
import com.android.internal.util.FunctionalUtils.ThrowingSupplier;
-import com.android.internal.util.Preconditions;
import dalvik.annotation.optimization.CriticalNative;
@@ -48,7 +48,6 @@ import java.io.IOException;
import java.io.PrintWriter;
import java.lang.reflect.Modifier;
import java.util.concurrent.atomic.AtomicReferenceArray;
-import java.util.function.Supplier;
/**
* Base class for a remotable object, the core part of a lightweight
@@ -82,6 +81,8 @@ import java.util.function.Supplier;
*
* @see IBinder
*/
+@RavenwoodKeepWholeClass
+@RavenwoodClassLoadHook(RavenwoodClassLoadHook.LIBANDROID_LOADING_HOOK)
public class Binder implements IBinder {
/*
* Set this flag to true to detect anonymous, local or member classes
@@ -292,33 +293,6 @@ public class Binder implements IBinder {
sWarnOnBlockingOnCurrentThread.set(sWarnOnBlocking);
}
- private static volatile ThreadLocal<SomeArgs> sIdentity$ravenwood;
-
- @android.ravenwood.annotation.RavenwoodKeepWholeClass
- private static class IdentitySupplier implements Supplier<SomeArgs> {
- @Override
- public SomeArgs get() {
- final SomeArgs args = SomeArgs.obtain();
- // Match IPCThreadState behavior
- args.arg1 = Boolean.FALSE;
- args.argi1 = android.os.Process.myUid();
- args.argi2 = android.os.Process.myPid();
- return args;
- }
- }
-
- /** @hide */
- @android.ravenwood.annotation.RavenwoodKeep
- public static void init$ravenwood() {
- sIdentity$ravenwood = ThreadLocal.withInitial(new IdentitySupplier());
- }
-
- /** @hide */
- @android.ravenwood.annotation.RavenwoodKeep
- public static void reset$ravenwood() {
- sIdentity$ravenwood = null;
- }
-
/**
* Raw native pointer to JavaBBinderHolder object. Owned by this Java object. Not null.
*/
@@ -346,14 +320,8 @@ public class Binder implements IBinder {
* 0 for a synchronous call.
*/
@CriticalNative
- @android.ravenwood.annotation.RavenwoodReplace
public static final native int getCallingPid();
- /** @hide */
- public static final int getCallingPid$ravenwood() {
- return Preconditions.requireNonNullViaRavenwoodRule(sIdentity$ravenwood).get().argi2;
- }
-
/**
* Return the Linux UID assigned to the process that sent you the
* current transaction that is being processed. This UID can be used with
@@ -362,14 +330,8 @@ public class Binder implements IBinder {
* incoming transaction, then its own UID is returned.
*/
@CriticalNative
- @android.ravenwood.annotation.RavenwoodReplace
public static final native int getCallingUid();
- /** @hide */
- public static final int getCallingUid$ravenwood() {
- return Preconditions.requireNonNullViaRavenwoodRule(sIdentity$ravenwood).get().argi1;
- }
-
/**
* Returns {@code true} if the current thread is currently executing an
* incoming transaction.
@@ -377,21 +339,13 @@ public class Binder implements IBinder {
* @hide
*/
@CriticalNative
- @android.ravenwood.annotation.RavenwoodReplace
public static final native boolean isDirectlyHandlingTransactionNative();
- /** @hide */
- public static final boolean isDirectlyHandlingTransactionNative$ravenwood() {
- // Ravenwood doesn't support IPC
- return false;
- }
-
private static boolean sIsHandlingBinderTransaction = false;
/**
* @hide
*/
- @android.ravenwood.annotation.RavenwoodKeep
public static final boolean isDirectlyHandlingTransaction() {
return sIsHandlingBinderTransaction || isDirectlyHandlingTransactionNative();
}
@@ -400,7 +354,6 @@ public class Binder implements IBinder {
* This is Test API which will be used to override output of isDirectlyHandlingTransactionNative
* @hide
*/
- @android.ravenwood.annotation.RavenwoodKeep
public static void setIsDirectlyHandlingTransactionOverride(boolean isInTransaction) {
sIsHandlingBinderTransaction = isInTransaction;
}
@@ -412,15 +365,8 @@ public class Binder implements IBinder {
* @hide
*/
@CriticalNative
- @android.ravenwood.annotation.RavenwoodReplace
private static native boolean hasExplicitIdentity();
- /** @hide */
- private static boolean hasExplicitIdentity$ravenwood() {
- return Preconditions.requireNonNullViaRavenwoodRule(sIdentity$ravenwood).get().arg1
- == Boolean.TRUE;
- }
-
/**
* Return the Linux UID assigned to the process that sent the transaction
* currently being processed.
@@ -429,7 +375,6 @@ public class Binder implements IBinder {
* executing an incoming transaction and the calling identity has not been
* explicitly set with {@link #clearCallingIdentity()}
*/
- @android.ravenwood.annotation.RavenwoodKeep
public static final int getCallingUidOrThrow() {
if (!isDirectlyHandlingTransaction() && !hasExplicitIdentity()) {
throw new IllegalStateException(
@@ -491,26 +436,8 @@ public class Binder implements IBinder {
* @see #restoreCallingIdentity(long)
*/
@CriticalNative
- @android.ravenwood.annotation.RavenwoodReplace
public static final native long clearCallingIdentity();
- /** @hide */
- public static final long clearCallingIdentity$ravenwood() {
- final SomeArgs args = Preconditions.requireNonNullViaRavenwoodRule(
- sIdentity$ravenwood).get();
- long res = ((long) args.argi1 << 32) | args.argi2;
- if (args.arg1 == Boolean.TRUE) {
- res |= (0x1 << 30);
- } else {
- res &= ~(0x1 << 30);
- }
- // Match IPCThreadState behavior
- args.arg1 = Boolean.TRUE;
- args.argi1 = android.os.Process.myUid();
- args.argi2 = android.os.Process.myPid();
- return res;
- }
-
/**
* Restore the identity of the incoming IPC on the current thread
* back to a previously identity that was returned by {@link
@@ -522,18 +449,8 @@ public class Binder implements IBinder {
* @see #clearCallingIdentity
*/
@CriticalNative
- @android.ravenwood.annotation.RavenwoodReplace
public static final native void restoreCallingIdentity(long token);
- /** @hide */
- public static final void restoreCallingIdentity$ravenwood(long token) {
- final SomeArgs args = Preconditions.requireNonNullViaRavenwoodRule(
- sIdentity$ravenwood).get();
- args.arg1 = ((token & (0x1 << 30)) != 0) ? Boolean.TRUE : Boolean.FALSE;
- args.argi1 = (int) (token >> 32);
- args.argi2 = (int) (token & ~(0x1 << 30));
- }
-
/**
* Convenience method for running the provided action enclosed in
* {@link #clearCallingIdentity}/{@link #restoreCallingIdentity}.
@@ -708,16 +625,9 @@ public class Binder implements IBinder {
*
* @hide
*/
- @android.ravenwood.annotation.RavenwoodReplace
@SystemApi(client = SystemApi.Client.PRIVILEGED_APPS)
public final native void markVintfStability();
- /** @hide */
- private void markVintfStability$ravenwood() {
- // This is not useful for Ravenwood which uses local binder.
- // TODO(b/361785059): Use real native libbinder.
- }
-
/**
* Use a VINTF-stability binder w/o VINTF requirements. Should be called
* on a binder before it is sent out of process.
@@ -736,14 +646,8 @@ public class Binder implements IBinder {
* in order to prevent the process from holding on to objects longer than
* it needs to.
*/
- @android.ravenwood.annotation.RavenwoodReplace
public static final native void flushPendingCommands();
- /** @hide */
- public static final void flushPendingCommands$ravenwood() {
- // Ravenwood doesn't support IPC; ignored
- }
-
/**
* Add the calling thread to the IPC thread pool. This function does
* not return until the current process is exiting.
@@ -801,7 +705,6 @@ public class Binder implements IBinder {
* <p>If you're creating a Binder token (a Binder object without an attached interface),
* you should use {@link #Binder(String)} instead.
*/
- @android.ravenwood.annotation.RavenwoodKeep
public Binder() {
this(null);
}
@@ -818,12 +721,9 @@ public class Binder implements IBinder {
* Instead of creating multiple tokens with the same descriptor, consider adding a suffix to
* help identify them.
*/
- @android.ravenwood.annotation.RavenwoodKeep
public Binder(@Nullable String descriptor) {
mObject = getNativeBBinderHolder();
- if (mObject != 0L) {
- NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mObject);
- }
+ NoImagePreloadHolder.sRegistry.registerNativeAllocation(this, mObject);
if (FIND_POTENTIAL_LEAKS) {
final Class<? extends Binder> klass = getClass();
@@ -842,7 +742,6 @@ public class Binder implements IBinder {
* will be implemented for you to return the given owner IInterface when
* the corresponding descriptor is requested.
*/
- @android.ravenwood.annotation.RavenwoodKeep
public void attachInterface(@Nullable IInterface owner, @Nullable String descriptor) {
mOwner = owner;
mDescriptor = descriptor;
@@ -851,7 +750,6 @@ public class Binder implements IBinder {
/**
* Default implementation returns an empty interface name.
*/
- @android.ravenwood.annotation.RavenwoodKeep
public @Nullable String getInterfaceDescriptor() {
return mDescriptor;
}
@@ -860,7 +758,6 @@ public class Binder implements IBinder {
* Default implementation always returns true -- if you got here,
* the object is alive.
*/
- @android.ravenwood.annotation.RavenwoodKeep
public boolean pingBinder() {
return true;
}
@@ -871,7 +768,6 @@ public class Binder implements IBinder {
* Note that if you're calling on a local binder, this always returns true
* because your process is alive if you're calling it.
*/
- @android.ravenwood.annotation.RavenwoodKeep
public boolean isBinderAlive() {
return true;
}
@@ -881,7 +777,6 @@ public class Binder implements IBinder {
* to return the associated {@link IInterface} if it matches the requested
* descriptor.
*/
- @android.ravenwood.annotation.RavenwoodKeep
public @Nullable IInterface queryLocalInterface(@NonNull String descriptor) {
if (mDescriptor != null && mDescriptor.equals(descriptor)) {
return mOwner;
@@ -1080,7 +975,6 @@ public class Binder implements IBinder {
*
* @hide
*/
- @android.ravenwood.annotation.RavenwoodKeep
public @Nullable String getTransactionName(int transactionCode) {
return null;
}
@@ -1089,7 +983,6 @@ public class Binder implements IBinder {
* @hide
*/
@VisibleForTesting
- @android.ravenwood.annotation.RavenwoodKeep
public final @Nullable String getTransactionTraceName(int transactionCode) {
final boolean isInterfaceUserDefined = getMaxTransactionId() == 0;
if (mTransactionTraceNames == null) {
@@ -1127,7 +1020,6 @@ public class Binder implements IBinder {
return transactionTraceName;
}
- @android.ravenwood.annotation.RavenwoodKeep
private @NonNull String getSimpleDescriptor() {
String descriptor = mDescriptor;
if (descriptor == null) {
@@ -1147,7 +1039,6 @@ public class Binder implements IBinder {
* @return The highest user-defined transaction id of all transactions.
* @hide
*/
- @android.ravenwood.annotation.RavenwoodKeep
public int getMaxTransactionId() {
return 0;
}
@@ -1359,14 +1250,12 @@ public class Binder implements IBinder {
/**
* Local implementation is a no-op.
*/
- @android.ravenwood.annotation.RavenwoodKeep
public void linkToDeath(@NonNull DeathRecipient recipient, int flags) {
}
/**
* Local implementation is a no-op.
*/
- @android.ravenwood.annotation.RavenwoodKeep
public boolean unlinkToDeath(@NonNull DeathRecipient recipient, int flags) {
return true;
}
@@ -1394,13 +1283,8 @@ public class Binder implements IBinder {
}
}
- @android.ravenwood.annotation.RavenwoodReplace
private static native long getNativeBBinderHolder();
- private static long getNativeBBinderHolder$ravenwood() {
- return 0L;
- }
-
/**
* By default, we use the calling UID since we can always trust it.
*/
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index 30d2dec8b4c4..a8267d1c9d8c 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -17,6 +17,7 @@
package android.os;
import android.Manifest;
+import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.RequiresPermission;
@@ -28,6 +29,7 @@ import android.app.Application;
import android.compat.annotation.UnsupportedAppUsage;
import android.content.Context;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;
+import android.sdk.Flags;
import android.sysprop.DeviceProperties;
import android.sysprop.SocProperties;
import android.sysprop.TelephonyProperties;
@@ -399,12 +401,35 @@ public class Build {
* device. This value never changes while a device is booted, but it may
* increase when the hardware manufacturer provides an OTA update.
* <p>
+ * Together with {@link SDK_MINOR_INT}, this constant defines the
+ * <pre>major.minor</pre> version of Android. <pre>SDK_INT</pre> is
+ * increased and <pre>SDK_MINOR_INT</pre> is set to 0 on new Android
+ * dessert releases. Between these, Android may also release so called
+ * minor releases where <pre>SDK_INT</pre> remains unchanged and
+ * <pre>SDK_MINOR_INT</pre> is increased. Minor releases can add new
+ * APIs, and have stricter guarantees around backwards compatibility
+ * (e.g. no changes gated by <pre>targetSdkVersion</pre>) compared to
+ * major releases.
+ * <p>
* Possible values are defined in {@link Build.VERSION_CODES}.
*/
public static final int SDK_INT = SystemProperties.getInt(
"ro.build.version.sdk", 0);
/**
+ * The minor SDK version of the software currently running on this hardware
+ * device. This value never changes while a device is booted, but it may
+ * increase when the hardware manufacturer provides an OTA update.
+ * <p>
+ * Together with {@link SDK_INT}, this constant defines the
+ * <pre>major.minor</pre> version of Android. See {@link SDK_INT} for
+ * more information.
+ */
+ @FlaggedApi(Flags.FLAG_MAJOR_MINOR_VERSIONING_SCHEME)
+ public static final int SDK_MINOR_INT = SystemProperties.getInt(
+ "ro.build.version.sdk_minor", 0);
+
+ /**
* The SDK version of the software that <em>initially</em> shipped on
* this hardware device. It <em>never</em> changes during the lifetime
* of the device, even when {@link #SDK_INT} increases due to an OTA
diff --git a/core/java/android/os/Parcel.java b/core/java/android/os/Parcel.java
index 2ac2ae916e58..f7285523c01a 100644
--- a/core/java/android/os/Parcel.java
+++ b/core/java/android/os/Parcel.java
@@ -27,9 +27,8 @@ import android.annotation.SuppressLint;
import android.annotation.TestApi;
import android.app.AppOpsManager;
import android.compat.annotation.UnsupportedAppUsage;
+import android.ravenwood.annotation.RavenwoodClassLoadHook;
import android.ravenwood.annotation.RavenwoodKeepWholeClass;
-import android.ravenwood.annotation.RavenwoodRedirect;
-import android.ravenwood.annotation.RavenwoodRedirectionClass;
import android.ravenwood.annotation.RavenwoodReplace;
import android.ravenwood.annotation.RavenwoodThrow;
import android.text.TextUtils;
@@ -234,7 +233,7 @@ import java.util.function.IntFunction;
* {@link #readSparseArray(ClassLoader, Class)}.
*/
@RavenwoodKeepWholeClass
-@RavenwoodRedirectionClass("Parcel_host")
+@RavenwoodClassLoadHook(RavenwoodClassLoadHook.LIBANDROID_LOADING_HOOK)
public final class Parcel {
private static final boolean DEBUG_RECYCLE = false;
@@ -387,148 +386,98 @@ public final class Parcel {
private static final int SIZE_COMPLEX_TYPE = 1;
@CriticalNative
- @RavenwoodRedirect
private static native void nativeMarkSensitive(long nativePtr);
@FastNative
- @RavenwoodThrow
private static native void nativeMarkForBinder(long nativePtr, IBinder binder);
@CriticalNative
- @RavenwoodThrow
private static native boolean nativeIsForRpc(long nativePtr);
@CriticalNative
- @RavenwoodRedirect
private static native int nativeDataSize(long nativePtr);
@CriticalNative
- @RavenwoodRedirect
private static native int nativeDataAvail(long nativePtr);
@CriticalNative
- @RavenwoodRedirect
private static native int nativeDataPosition(long nativePtr);
@CriticalNative
- @RavenwoodRedirect
private static native int nativeDataCapacity(long nativePtr);
@FastNative
- @RavenwoodRedirect
private static native void nativeSetDataSize(long nativePtr, int size);
@CriticalNative
- @RavenwoodRedirect
private static native void nativeSetDataPosition(long nativePtr, int pos);
@FastNative
- @RavenwoodRedirect
private static native void nativeSetDataCapacity(long nativePtr, int size);
@CriticalNative
- @RavenwoodRedirect
private static native boolean nativePushAllowFds(long nativePtr, boolean allowFds);
@CriticalNative
- @RavenwoodRedirect
private static native void nativeRestoreAllowFds(long nativePtr, boolean lastValue);
- @RavenwoodRedirect
private static native void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len);
- @RavenwoodRedirect
private static native void nativeWriteBlob(long nativePtr, byte[] b, int offset, int len);
@CriticalNative
- @RavenwoodRedirect
private static native int nativeWriteInt(long nativePtr, int val);
@CriticalNative
- @RavenwoodRedirect
private static native int nativeWriteLong(long nativePtr, long val);
@CriticalNative
- @RavenwoodRedirect
private static native int nativeWriteFloat(long nativePtr, float val);
@CriticalNative
- @RavenwoodRedirect
private static native int nativeWriteDouble(long nativePtr, double val);
- @RavenwoodThrow
private static native void nativeSignalExceptionForError(int error);
@FastNative
- @RavenwoodRedirect
private static native void nativeWriteString8(long nativePtr, String val);
@FastNative
- @RavenwoodRedirect
private static native void nativeWriteString16(long nativePtr, String val);
@FastNative
- @RavenwoodThrow
private static native void nativeWriteStrongBinder(long nativePtr, IBinder val);
@FastNative
- @RavenwoodRedirect
private static native void nativeWriteFileDescriptor(long nativePtr, FileDescriptor val);
- @RavenwoodRedirect
private static native byte[] nativeCreateByteArray(long nativePtr);
- @RavenwoodRedirect
private static native boolean nativeReadByteArray(long nativePtr, byte[] dest, int destLen);
- @RavenwoodRedirect
private static native byte[] nativeReadBlob(long nativePtr);
@CriticalNative
- @RavenwoodRedirect
private static native int nativeReadInt(long nativePtr);
@CriticalNative
- @RavenwoodRedirect
private static native long nativeReadLong(long nativePtr);
@CriticalNative
- @RavenwoodRedirect
private static native float nativeReadFloat(long nativePtr);
@CriticalNative
- @RavenwoodRedirect
private static native double nativeReadDouble(long nativePtr);
@FastNative
- @RavenwoodRedirect
private static native String nativeReadString8(long nativePtr);
@FastNative
- @RavenwoodRedirect
private static native String nativeReadString16(long nativePtr);
@FastNative
- @RavenwoodThrow
private static native IBinder nativeReadStrongBinder(long nativePtr);
@FastNative
- @RavenwoodRedirect
private static native FileDescriptor nativeReadFileDescriptor(long nativePtr);
- @RavenwoodRedirect
private static native long nativeCreate();
- @RavenwoodRedirect
private static native void nativeFreeBuffer(long nativePtr);
- @RavenwoodRedirect
private static native void nativeDestroy(long nativePtr);
- @RavenwoodRedirect
private static native byte[] nativeMarshall(long nativePtr);
- @RavenwoodRedirect
private static native void nativeUnmarshall(
long nativePtr, byte[] data, int offset, int length);
- @RavenwoodRedirect
private static native int nativeCompareData(long thisNativePtr, long otherNativePtr);
- @RavenwoodRedirect
private static native boolean nativeCompareDataInRange(
long ptrA, int offsetA, long ptrB, int offsetB, int length);
- @RavenwoodRedirect
private static native void nativeAppendFrom(
long thisNativePtr, long otherNativePtr, int offset, int length);
@CriticalNative
- @RavenwoodRedirect
private static native boolean nativeHasFileDescriptors(long nativePtr);
- @RavenwoodRedirect
private static native boolean nativeHasFileDescriptorsInRange(
long nativePtr, int offset, int length);
- @RavenwoodRedirect
private static native boolean nativeHasBinders(long nativePtr);
- @RavenwoodRedirect
private static native boolean nativeHasBindersInRange(
long nativePtr, int offset, int length);
- @RavenwoodThrow
private static native void nativeWriteInterfaceToken(long nativePtr, String interfaceName);
- @RavenwoodThrow
private static native void nativeEnforceInterface(long nativePtr, String interfaceName);
@CriticalNative
- @RavenwoodThrow
private static native boolean nativeReplaceCallingWorkSourceUid(
long nativePtr, int workSourceUid);
@CriticalNative
- @RavenwoodThrow
private static native int nativeReadCallingWorkSourceUid(long nativePtr);
/** Last time exception with a stack trace was written */
@@ -537,7 +486,6 @@ public final class Parcel {
private static final int WRITE_EXCEPTION_STACK_TRACE_THRESHOLD_MS = 1000;
@CriticalNative
- @RavenwoodThrow
private static native long nativeGetOpenAshmemSize(long nativePtr);
public final static Parcelable.Creator<String> STRING_CREATOR
@@ -701,12 +649,10 @@ public final class Parcel {
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
- @RavenwoodThrow
public static native long getGlobalAllocSize();
/** @hide */
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
- @RavenwoodThrow
public static native long getGlobalAllocCount();
/**
@@ -1298,6 +1244,7 @@ public final class Parcel {
* @hide
*/
@UnsupportedAppUsage
+ @RavenwoodThrow(blockedBy = android.text.Spanned.class)
public final void writeCharSequence(@Nullable CharSequence val) {
TextUtils.writeToParcel(val, this, 0);
}
@@ -3037,7 +2984,7 @@ public final class Parcel {
* @see #writeNoException
* @see #readException
*/
- @RavenwoodReplace
+ @RavenwoodReplace(blockedBy = AppOpsManager.class)
public final void writeException(@NonNull Exception e) {
AppOpsManager.prefixParcelWithAppOpsIfNeeded(this);
@@ -3076,10 +3023,15 @@ public final class Parcel {
}
}
- /** @hide */
- public final void writeException$ravenwood(@NonNull Exception e) {
- // Ravenwood doesn't support IPC, no transaction headers needed
- writeInt(getExceptionCode(e));
+ private void writeException$ravenwood(@NonNull Exception e) {
+ int code = getExceptionCode(e);
+ writeInt(code);
+ if (code == 0) {
+ if (e instanceof RuntimeException) {
+ throw (RuntimeException) e;
+ }
+ throw new RuntimeException(e);
+ }
writeString(e.getMessage());
writeInt(0);
}
@@ -3137,7 +3089,7 @@ public final class Parcel {
* @see #writeException
* @see #readException
*/
- @RavenwoodReplace
+ @RavenwoodReplace(blockedBy = AppOpsManager.class)
public final void writeNoException() {
AppOpsManager.prefixParcelWithAppOpsIfNeeded(this);
@@ -3168,9 +3120,7 @@ public final class Parcel {
}
}
- /** @hide */
- public final void writeNoException$ravenwood() {
- // Ravenwood doesn't support IPC, no transaction headers needed
+ private void writeNoException$ravenwood() {
writeInt(0);
}
diff --git a/core/java/android/os/StrictMode.java b/core/java/android/os/StrictMode.java
index 50b73a9d3f66..81dc46ecbd3a 100644
--- a/core/java/android/os/StrictMode.java
+++ b/core/java/android/os/StrictMode.java
@@ -2605,10 +2605,15 @@ public final class StrictMode {
* (Java) thread-local policy value.
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.R, trackingBug = 170729553)
+ @android.ravenwood.annotation.RavenwoodReplace
private static void onBinderStrictModePolicyChange(@ThreadPolicyMask int newPolicy) {
setBlockGuardPolicy(newPolicy);
}
+ private static void onBinderStrictModePolicyChange$ravenwood(@ThreadPolicyMask int newPolicy) {
+ /* no-op */
+ }
+
/**
* A tracked, critical time span. (e.g. during an animation.)
*
diff --git a/core/java/android/os/SystemClock.java b/core/java/android/os/SystemClock.java
index 0ed1ab6c8d72..4c9a02c1fc49 100644
--- a/core/java/android/os/SystemClock.java
+++ b/core/java/android/os/SystemClock.java
@@ -109,6 +109,7 @@ public final class SystemClock {
private static final String TAG = "SystemClock";
private static volatile IAlarmManager sIAlarmManager;
+ private static volatile ITimeDetectorService sITimeDetectorService;
/**
* Since {@code nanoTime()} is arbitrary, anchor our Ravenwood clocks against it.
@@ -188,6 +189,14 @@ public final class SystemClock {
return sIAlarmManager;
}
+ private static ITimeDetectorService getITimeDetectorService() {
+ if (sITimeDetectorService == null) {
+ sITimeDetectorService = ITimeDetectorService.Stub
+ .asInterface(ServiceManager.getService(Context.TIME_DETECTOR_SERVICE));
+ }
+ return sITimeDetectorService;
+ }
+
/**
* Returns milliseconds since boot, not counting time spent in deep sleep.
*
@@ -314,15 +323,6 @@ public final class SystemClock {
}
/**
- * @see #currentNetworkTimeMillis(ITimeDetectorService)
- * @hide
- */
- public static long currentNetworkTimeMillis() {
- return currentNetworkTimeMillis(ITimeDetectorService.Stub
- .asInterface(ServiceManager.getService(Context.TIME_DETECTOR_SERVICE)));
- }
-
- /**
* Returns milliseconds since January 1, 1970 00:00:00.0 UTC, synchronized
* using a remote network source outside the device.
* <p>
@@ -346,29 +346,29 @@ public final class SystemClock {
* @throws DateTimeException when no network time can be provided.
* @hide
*/
- public static long currentNetworkTimeMillis(
- ITimeDetectorService timeDetectorService) {
- if (timeDetectorService != null) {
- UnixEpochTime time;
- try {
- time = timeDetectorService.latestNetworkTime();
- } catch (ParcelableException e) {
- e.maybeRethrow(DateTimeException.class);
- throw new RuntimeException(e);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
-
- if (time == null) {
- // This is not expected.
- throw new DateTimeException("Network based time is not available.");
- }
- long currentMillis = elapsedRealtime();
- long deltaMs = currentMillis - time.getElapsedRealtimeMillis();
- return time.getUnixEpochTimeMillis() + deltaMs;
- } else {
+ public static long currentNetworkTimeMillis() {
+ ITimeDetectorService timeDetectorService = getITimeDetectorService();
+ if (timeDetectorService == null) {
throw new RuntimeException(new DeadSystemException());
}
+
+ UnixEpochTime time;
+ try {
+ time = timeDetectorService.latestNetworkTime();
+ } catch (ParcelableException e) {
+ e.maybeRethrow(DateTimeException.class);
+ throw new RuntimeException(e);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ if (time == null) {
+ // This is not expected.
+ throw new DateTimeException("Network based time is not available.");
+ }
+
+ long currentMillis = elapsedRealtime();
+ long deltaMs = currentMillis - time.getElapsedRealtimeMillis();
+ return time.getUnixEpochTimeMillis() + deltaMs;
}
/**
@@ -396,14 +396,9 @@ public final class SystemClock {
*/
public static @NonNull Clock currentNetworkTimeClock() {
return new SimpleClock(ZoneOffset.UTC) {
- private ITimeDetectorService mSvc;
@Override
public long millis() {
- if (mSvc == null) {
- mSvc = ITimeDetectorService.Stub
- .asInterface(ServiceManager.getService(Context.TIME_DETECTOR_SERVICE));
- }
- return SystemClock.currentNetworkTimeMillis(mSvc);
+ return SystemClock.currentNetworkTimeMillis();
}
};
}
diff --git a/core/java/android/os/Vibrator.java b/core/java/android/os/Vibrator.java
index 36233b7be2bb..84325b7c2874 100644
--- a/core/java/android/os/Vibrator.java
+++ b/core/java/android/os/Vibrator.java
@@ -17,6 +17,7 @@
package android.os;
import android.annotation.CallbackExecutor;
+import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -30,6 +31,7 @@ import android.content.Context;
import android.content.res.Resources;
import android.hardware.vibrator.IVibrator;
import android.media.AudioAttributes;
+import android.os.vibrator.Flags;
import android.os.vibrator.VibrationConfig;
import android.os.vibrator.VibratorFrequencyProfile;
import android.util.Log;
@@ -313,6 +315,86 @@ public abstract class Vibrator {
}
/**
+ * Checks whether the vibrator supports the creation of envelope effects.
+ *
+ * Envelope effects are defined by a series of frequency-amplitude pairs with specified
+ * transition times, allowing the creation of more complex vibration patterns.
+ *
+ * @return True if the hardware supports creating envelope effects, false otherwise.
+ */
+ @FlaggedApi(Flags.FLAG_NORMALIZED_PWLE_EFFECTS)
+ public boolean areEnvelopeEffectsSupported() {
+ return getInfo().areEnvelopeEffectsSupported();
+ }
+
+ /**
+ * Retrieves the maximum duration supported for an envelope effect, in milliseconds.
+ *
+ * <p>If the device supports envelope effects (check {@link #areEnvelopeEffectsSupported}),
+ * this value will be positive. Devices with envelope effects capabilities guarantees a
+ * maximum duration equivalent to the product of {@link #getMaxEnvelopeEffectSize()} and
+ * {@link #getMaxEnvelopeEffectControlPointDurationMillis()}. If the device does not support
+ * envelope effects, this method will return 0.
+ *
+ * @return The maximum duration (in milliseconds) allowed for an envelope effect, or 0 if
+ * envelope effects are not supported.
+ */
+ @FlaggedApi(Flags.FLAG_NORMALIZED_PWLE_EFFECTS)
+ public int getMaxEnvelopeEffectDurationMillis() {
+ return getInfo().getMaxEnvelopeEffectDurationMillis();
+ }
+
+ /**
+ * Retrieves the maximum number of control points supported for an envelope effect.
+ *
+ * <p>If the device supports envelope effects (check {@link #areEnvelopeEffectsSupported}),
+ * this value will be positive. Devices with envelope effects capabilities guarantee support
+ * for a minimum of 16 control points. If the device does not support envelope effects,
+ * this method will return 0.
+ *
+ * @return the maximum number of control points allowed for an envelope effect, or 0 if
+ * envelope effects are not supported.
+ */
+ @FlaggedApi(Flags.FLAG_NORMALIZED_PWLE_EFFECTS)
+ public int getMaxEnvelopeEffectSize() {
+ return getInfo().getMaxEnvelopeEffectSize();
+ }
+
+ /**
+ * Retrieves the minimum duration supported between two control points within an envelope
+ * effect, in milliseconds.
+ *
+ * <p>If the device supports envelope effects (check {@link #areEnvelopeEffectsSupported}),
+ * this value will be positive. Devices with envelope effects capabilities guarantee
+ * support for durations down to at least 20 milliseconds. If the device does
+ * not support envelope effects, this method will return 0.
+ *
+ * @return the minimum allowed duration between two control points in an envelope effect,
+ * or 0 if envelope effects are not supported.
+ */
+ @FlaggedApi(Flags.FLAG_NORMALIZED_PWLE_EFFECTS)
+ public int getMinEnvelopeEffectControlPointDurationMillis() {
+ return getInfo().getMinEnvelopeEffectControlPointDurationMillis();
+ }
+
+ /**
+ * Retrieves the maximum duration supported between two control points within an envelope
+ * effect, in milliseconds.
+ *
+ * <p>If the device supports envelope effects (check {@link #areEnvelopeEffectsSupported}),
+ * this value will be positive. Devices with envelope effects capabilities guarantee support
+ * for durations up to at least 1 second. If the device does not support envelope effects,
+ * this method will return 0.
+ *
+ * @return the maximum allowed duration between two control points in an envelope effect,
+ * or 0 if envelope effects are not supported.
+ */
+ @FlaggedApi(Flags.FLAG_NORMALIZED_PWLE_EFFECTS)
+ public int getMaxEnvelopeEffectControlPointDurationMillis() {
+ return getInfo().getMaxEnvelopeEffectControlPointDurationMillis();
+ }
+
+ /**
* Configure an always-on haptics effect.
*
* @param alwaysOnId The board-specific always-on ID to configure.
diff --git a/core/java/android/os/VibratorInfo.java b/core/java/android/os/VibratorInfo.java
index 4f8c24d1f905..5378295e3720 100644
--- a/core/java/android/os/VibratorInfo.java
+++ b/core/java/android/os/VibratorInfo.java
@@ -60,6 +60,9 @@ public class VibratorInfo implements Parcelable {
private final int mPwleSizeMax;
private final float mQFactor;
private final FrequencyProfile mFrequencyProfile;
+ private final int mMaxEnvelopeEffectSize;
+ private final int mMinEnvelopeEffectControlPointDurationMillis;
+ private final int mMaxEnvelopeEffectControlPointDurationMillis;
VibratorInfo(Parcel in) {
mId = in.readInt();
@@ -73,6 +76,9 @@ public class VibratorInfo implements Parcelable {
mPwleSizeMax = in.readInt();
mQFactor = in.readFloat();
mFrequencyProfile = FrequencyProfile.CREATOR.createFromParcel(in);
+ mMaxEnvelopeEffectSize = in.readInt();
+ mMinEnvelopeEffectControlPointDurationMillis = in.readInt();
+ mMaxEnvelopeEffectControlPointDurationMillis = in.readInt();
}
public VibratorInfo(int id, @NonNull VibratorInfo baseVibratorInfo) {
@@ -80,7 +86,10 @@ public class VibratorInfo implements Parcelable {
baseVibratorInfo.mSupportedBraking, baseVibratorInfo.mSupportedPrimitives,
baseVibratorInfo.mPrimitiveDelayMax, baseVibratorInfo.mCompositionSizeMax,
baseVibratorInfo.mPwlePrimitiveDurationMax, baseVibratorInfo.mPwleSizeMax,
- baseVibratorInfo.mQFactor, baseVibratorInfo.mFrequencyProfile);
+ baseVibratorInfo.mQFactor, baseVibratorInfo.mFrequencyProfile,
+ baseVibratorInfo.mMaxEnvelopeEffectSize,
+ baseVibratorInfo.mMinEnvelopeEffectControlPointDurationMillis,
+ baseVibratorInfo.mMaxEnvelopeEffectControlPointDurationMillis);
}
/**
@@ -111,7 +120,9 @@ public class VibratorInfo implements Parcelable {
@Nullable SparseBooleanArray supportedBraking,
@NonNull SparseIntArray supportedPrimitives, int primitiveDelayMax,
int compositionSizeMax, int pwlePrimitiveDurationMax, int pwleSizeMax,
- float qFactor, @NonNull FrequencyProfile frequencyProfile) {
+ float qFactor, @NonNull FrequencyProfile frequencyProfile,
+ int maxEnvelopeEffectSize, int minEnvelopeEffectControlPointDurationMillis,
+ int maxEnvelopeEffectControlPointDurationMillis) {
Preconditions.checkNotNull(supportedPrimitives);
Preconditions.checkNotNull(frequencyProfile);
mId = id;
@@ -125,6 +136,11 @@ public class VibratorInfo implements Parcelable {
mPwleSizeMax = pwleSizeMax;
mQFactor = qFactor;
mFrequencyProfile = frequencyProfile;
+ mMaxEnvelopeEffectSize = maxEnvelopeEffectSize;
+ mMinEnvelopeEffectControlPointDurationMillis =
+ minEnvelopeEffectControlPointDurationMillis;
+ mMaxEnvelopeEffectControlPointDurationMillis =
+ maxEnvelopeEffectControlPointDurationMillis;
}
@Override
@@ -140,6 +156,9 @@ public class VibratorInfo implements Parcelable {
dest.writeInt(mPwleSizeMax);
dest.writeFloat(mQFactor);
mFrequencyProfile.writeToParcel(dest, flags);
+ dest.writeInt(mMaxEnvelopeEffectSize);
+ dest.writeInt(mMinEnvelopeEffectControlPointDurationMillis);
+ dest.writeInt(mMaxEnvelopeEffectControlPointDurationMillis);
}
@Override
@@ -186,7 +205,12 @@ public class VibratorInfo implements Parcelable {
&& Objects.equals(mSupportedEffects, that.mSupportedEffects)
&& Objects.equals(mSupportedBraking, that.mSupportedBraking)
&& Objects.equals(mQFactor, that.mQFactor)
- && Objects.equals(mFrequencyProfile, that.mFrequencyProfile);
+ && Objects.equals(mFrequencyProfile, that.mFrequencyProfile)
+ && mMaxEnvelopeEffectSize == that.mMaxEnvelopeEffectSize
+ && mMinEnvelopeEffectControlPointDurationMillis
+ == that.mMinEnvelopeEffectControlPointDurationMillis
+ && mMaxEnvelopeEffectControlPointDurationMillis
+ == that.mMaxEnvelopeEffectControlPointDurationMillis;
}
@Override
@@ -215,6 +239,11 @@ public class VibratorInfo implements Parcelable {
+ ", mPwleSizeMax=" + mPwleSizeMax
+ ", mQFactor=" + mQFactor
+ ", mFrequencyProfile=" + mFrequencyProfile
+ + ", mMaxEnvelopeEffectSize=" + mMaxEnvelopeEffectSize
+ + ", mMinEnvelopeEffectControlPointDurationMillis="
+ + mMinEnvelopeEffectControlPointDurationMillis
+ + ", mMaxEnvelopeEffectControlPointDurationMillis="
+ + mMaxEnvelopeEffectControlPointDurationMillis
+ '}';
}
@@ -234,6 +263,11 @@ public class VibratorInfo implements Parcelable {
pw.println("pwleSizeMax = " + mPwleSizeMax);
pw.println("q-factor = " + mQFactor);
pw.println("frequencyProfile = " + mFrequencyProfile);
+ pw.println("mMaxEnvelopeEffectSize = " + mMaxEnvelopeEffectSize);
+ pw.println("mMinEnvelopeEffectControlPointDurationMillis = "
+ + mMinEnvelopeEffectControlPointDurationMillis);
+ pw.println("mMaxEnvelopeEffectControlPointDurationMillis = "
+ + mMaxEnvelopeEffectControlPointDurationMillis);
pw.decreaseIndent();
}
@@ -414,6 +448,58 @@ public class VibratorInfo implements Parcelable {
}
/**
+ * Check whether the vibrator supports the creation of envelope effects.
+ *
+ * <p>See {@link Vibrator#areEnvelopeEffectsSupported()} for more information on envelope
+ * effects.
+ *
+ * @return True if the hardware supports creating envelope effects, false otherwise.
+ */
+ public boolean areEnvelopeEffectsSupported() {
+ return hasCapability(IVibrator.CAP_COMPOSE_PWLE_EFFECTS_V2);
+ }
+
+ /**
+ * Calculates the maximum allowed duration for an envelope effect, measured in milliseconds.
+ *
+ * @return The maximum duration (in milliseconds) that an envelope effect can have.
+ */
+ public int getMaxEnvelopeEffectDurationMillis() {
+ return mMaxEnvelopeEffectSize * mMaxEnvelopeEffectControlPointDurationMillis;
+ }
+
+ /**
+ * Gets the maximum number of control points supported for envelope effects on this device.
+ *
+ * @return The maximum number of control points that can be used to define an envelope effect.
+ */
+ public int getMaxEnvelopeEffectSize() {
+ return mMaxEnvelopeEffectSize;
+ }
+
+ /**
+ * Gets the minimum allowed duration for any individual segment within an envelope effect,
+ * measured in milliseconds.
+ *
+ * @return The minimum duration (in milliseconds) that a segment within an envelope effect
+ * can have.
+ */
+ public int getMinEnvelopeEffectControlPointDurationMillis() {
+ return mMinEnvelopeEffectControlPointDurationMillis;
+ }
+
+ /**
+ * Gets the maximum allowed duration for any individual segment within an envelope effect,
+ * measured in milliseconds.
+ *
+ * @return The maximum duration (in milliseconds) that a segment within an envelope effect
+ * can have.
+ */
+ public int getMaxEnvelopeEffectControlPointDurationMillis() {
+ return mMaxEnvelopeEffectControlPointDurationMillis;
+ }
+
+ /**
* Check against this vibrator capabilities.
*
* @param capability one of IVibrator.CAP_*
@@ -489,6 +575,9 @@ public class VibratorInfo implements Parcelable {
if (hasCapability(IVibrator.CAP_EXTERNAL_AMPLITUDE_CONTROL)) {
names.add("EXTERNAL_AMPLITUDE_CONTROL");
}
+ if (hasCapability(IVibrator.CAP_COMPOSE_PWLE_EFFECTS_V2)) {
+ names.add("CAP_COMPOSE_PWLE_EFFECTS_V2");
+ }
return names.toArray(new String[names.size()]);
}
@@ -745,6 +834,9 @@ public class VibratorInfo implements Parcelable {
private float mQFactor = Float.NaN;
private FrequencyProfile mFrequencyProfile =
new FrequencyProfile(Float.NaN, Float.NaN, Float.NaN, null);
+ private int mMaxEnvelopeEffectSize;
+ private int mMinEnvelopeEffectControlPointDurationMillis;
+ private int mMaxEnvelopeEffectControlPointDurationMillis;
/** A builder class for a {@link VibratorInfo}. */
public Builder(int id) {
@@ -821,12 +913,46 @@ public class VibratorInfo implements Parcelable {
return this;
}
+ /**
+ * Configure the maximum number of control points supported for envelope effects on this
+ * device.
+ */
+ @NonNull
+ public Builder setMaxEnvelopeEffectSize(int maxEnvelopeEffectSize) {
+ mMaxEnvelopeEffectSize = maxEnvelopeEffectSize;
+ return this;
+ }
+
+ /**
+ * Configure the minimum supported duration for any individual segment within an
+ * envelope effect in milliseconds.
+ */
+ @NonNull
+ public Builder setMinEnvelopeEffectControlPointDurationMillis(
+ int minEnvelopeEffectControlPointDuration) {
+ mMinEnvelopeEffectControlPointDurationMillis = minEnvelopeEffectControlPointDuration;
+ return this;
+ }
+
+ /**
+ * Configure the maximum supported duration for any individual segment within an
+ * envelope effect in milliseconds.
+ */
+ @NonNull
+ public Builder setMaxEnvelopeEffectControlPointDurationMillis(
+ int maxEnvelopeEffectControlPointDuration) {
+ mMaxEnvelopeEffectControlPointDurationMillis = maxEnvelopeEffectControlPointDuration;
+ return this;
+ }
+
/** Build the configured {@link VibratorInfo}. */
@NonNull
public VibratorInfo build() {
return new VibratorInfo(mId, mCapabilities, mSupportedEffects, mSupportedBraking,
mSupportedPrimitives, mPrimitiveDelayMax, mCompositionSizeMax,
- mPwlePrimitiveDurationMax, mPwleSizeMax, mQFactor, mFrequencyProfile);
+ mPwlePrimitiveDurationMax, mPwleSizeMax, mQFactor, mFrequencyProfile,
+ mMaxEnvelopeEffectSize, mMinEnvelopeEffectControlPointDurationMillis,
+ mMaxEnvelopeEffectControlPointDurationMillis);
}
/**
diff --git a/core/java/android/os/vibrator/MultiVibratorInfo.java b/core/java/android/os/vibrator/MultiVibratorInfo.java
index 5f3273129213..9c2b9782ffb3 100644
--- a/core/java/android/os/vibrator/MultiVibratorInfo.java
+++ b/core/java/android/os/vibrator/MultiVibratorInfo.java
@@ -59,7 +59,13 @@ public final class MultiVibratorInfo extends VibratorInfo {
integerLimitIntersection(vibrators, VibratorInfo::getPwlePrimitiveDurationMax),
integerLimitIntersection(vibrators, VibratorInfo::getPwleSizeMax),
floatPropertyIntersection(vibrators, VibratorInfo::getQFactor),
- mergedProfile);
+ mergedProfile,
+ integerLimitIntersection(vibrators,
+ VibratorInfo::getMaxEnvelopeEffectSize),
+ integerLimitIntersection(vibrators,
+ VibratorInfo::getMinEnvelopeEffectControlPointDurationMillis),
+ integerLimitIntersection(vibrators,
+ VibratorInfo::getMaxEnvelopeEffectControlPointDurationMillis));
}
private static int capabilitiesIntersection(VibratorInfo[] infos,
diff --git a/core/java/android/os/vibrator/VibrationConfig.java b/core/java/android/os/vibrator/VibrationConfig.java
index e6e5a27bd731..bc6c5706f6fd 100644
--- a/core/java/android/os/vibrator/VibrationConfig.java
+++ b/core/java/android/os/vibrator/VibrationConfig.java
@@ -30,13 +30,17 @@ import static android.os.VibrationAttributes.USAGE_UNKNOWN;
import android.annotation.Nullable;
import android.content.res.Resources;
+import android.os.SystemProperties;
import android.os.VibrationAttributes;
import android.os.Vibrator;
import android.os.Vibrator.VibrationIntensity;
import android.util.IndentingPrintWriter;
+import com.android.internal.annotations.VisibleForTesting;
+
import java.io.PrintWriter;
import java.util.Arrays;
+import java.util.function.Function;
/**
* List of device-specific internal vibration configuration loaded from platform config.xml.
@@ -50,6 +54,37 @@ import java.util.Arrays;
public class VibrationConfig {
/**
+ * The default gain to be applied between vibration scale levels.
+ *
+ * <p>Scale levels are defined as the difference between the user vibration intensity setting
+ * and the device default config for each usage. The intensity values are defined as one of
+ * Vibrator.VIBRATION_INTENSITY_*.
+ *
+ * <p>A user setting HIGH set on a device with default value LOW will cause the vibration
+ * intensity to be scaled up 2 levels, i.e. scale with a factor of gain^2. A system with 3
+ * intensities LOW, MEDIUM and HIGH has the following 5 scale levels:
+ *
+ * <ol>
+ * <li>VERY_HIGH: user(HIGH) - device(LOW)
+ * <li>HIGH: user(HIGH) - device(MEDIUM) / user(MEDIUM) - device(LOW)
+ * <li>NONE: user == device
+ * <li>LOW: user(MEDIUM) - device(HIGH) / user(LOW) - device(MEDIUM)
+ * <li>VERY_LOW: user(LOW) - device(HIGH)
+ * </ol>
+ *
+ * <p>A device will only ever apply 3 out of these 5 levels based on the default intensity
+ * config set for each usage (e.g. config_default[Alarm|Ring|Notification]VibrationIntensity).
+ *
+ * <p>This value must be greater than 1. The {@link #DEFAULT_SCALE_LEVEL_GAIN} will be used if
+ * this property is undefined or invalid.
+ *
+ * @hide
+ */
+ @VisibleForTesting
+ static final String SCALE_LEVEL_GAIN_SYSTEM_PROPERTY =
+ "vendor.vibrator.scale.level.gain";
+
+ /**
* Hardcoded default scale level gain to be applied between each scale level to define their
* scale factor value.
*
@@ -69,7 +104,7 @@ public class VibrationConfig {
private final int mRampDownDurationMs;
private final int mRequestVibrationParamsTimeoutMs;
private final int[] mRequestVibrationParamsForUsages;
-
+ private final float mDefaultVibrationScaleLevelGain;
private final boolean mIgnoreVibrationsOnWirelessCharger;
@VibrationIntensity
@@ -89,8 +124,18 @@ public class VibrationConfig {
/** @hide */
public VibrationConfig(@Nullable Resources resources) {
- mDefaultVibrationAmplitude = resources.getInteger(
- com.android.internal.R.integer.config_defaultVibrationAmplitude);
+ this(resources, SystemProperties::get);
+ }
+
+ /** @hide */
+ @VisibleForTesting
+ public VibrationConfig(@Nullable Resources resources,
+ Function<String, String> systemPropertiesGetter) {
+ mDefaultVibrationAmplitude = loadInteger(resources,
+ com.android.internal.R.integer.config_defaultVibrationAmplitude,
+ DEFAULT_AMPLITUDE);
+ mDefaultVibrationScaleLevelGain = loadFloat(systemPropertiesGetter,
+ SCALE_LEVEL_GAIN_SYSTEM_PROPERTY, DEFAULT_SCALE_LEVEL_GAIN);
mHapticChannelMaxVibrationAmplitude = loadFloat(resources,
com.android.internal.R.dimen.config_hapticChannelMaxVibrationAmplitude);
mRampDownDurationMs = loadInteger(resources,
@@ -135,6 +180,15 @@ public class VibrationConfig {
return res != null ? res.getFloat(resId) : 0f;
}
+ private static float loadFloat(Function<String, String> systemPropertiesGetter,
+ String propertyKey, float defaultValue) {
+ try {
+ return Float.parseFloat(systemPropertiesGetter.apply(propertyKey));
+ } catch (Exception e) {
+ return defaultValue;
+ }
+ }
+
private static int loadInteger(@Nullable Resources res, int resId, int defaultValue) {
return res != null ? res.getInteger(resId) : defaultValue;
}
@@ -176,8 +230,10 @@ public class VibrationConfig {
* for each level.
*/
public float getDefaultVibrationScaleLevelGain() {
- // TODO(b/356407380): add device config for this
- return DEFAULT_SCALE_LEVEL_GAIN;
+ if (mDefaultVibrationScaleLevelGain <= 1) {
+ return DEFAULT_SCALE_LEVEL_GAIN;
+ }
+ return mDefaultVibrationScaleLevelGain;
}
/**
@@ -270,6 +326,7 @@ public class VibrationConfig {
return "VibrationConfig{"
+ "mIgnoreVibrationsOnWirelessCharger=" + mIgnoreVibrationsOnWirelessCharger
+ ", mDefaultVibrationAmplitude=" + mDefaultVibrationAmplitude
+ + ", mDefaultVibrationScaleLevelGain=" + mDefaultVibrationScaleLevelGain
+ ", mHapticChannelMaxVibrationAmplitude=" + mHapticChannelMaxVibrationAmplitude
+ ", mRampStepDurationMs=" + mRampStepDurationMs
+ ", mRampDownDurationMs=" + mRampDownDurationMs
@@ -296,6 +353,7 @@ public class VibrationConfig {
pw.increaseIndent();
pw.println("ignoreVibrationsOnWirelessCharger = " + mIgnoreVibrationsOnWirelessCharger);
pw.println("defaultVibrationAmplitude = " + mDefaultVibrationAmplitude);
+ pw.println("defaultVibrationScaleLevelGain = " + mDefaultVibrationScaleLevelGain);
pw.println("hapticChannelMaxAmplitude = " + mHapticChannelMaxVibrationAmplitude);
pw.println("rampStepDurationMs = " + mRampStepDurationMs);
pw.println("rampDownDurationMs = " + mRampDownDurationMs);
diff --git a/core/java/android/permission/flags.aconfig b/core/java/android/permission/flags.aconfig
index 5174005a8175..6c486dbfd7a2 100644
--- a/core/java/android/permission/flags.aconfig
+++ b/core/java/android/permission/flags.aconfig
@@ -241,3 +241,11 @@ flag {
purpose: PURPOSE_BUGFIX
}
}
+
+flag {
+ name: "wallet_role_icon_property_enabled"
+ is_exported: true
+ namespace: "wallet_integration"
+ description: "This flag is used to enabled the Wallet Role s icon fetching from manifest property"
+ bug: "349942654"
+}
diff --git a/core/java/android/text/ClientFlags.java b/core/java/android/text/ClientFlags.java
index bbe9cdbbce9f..c2ad508c2b44 100644
--- a/core/java/android/text/ClientFlags.java
+++ b/core/java/android/text/ClientFlags.java
@@ -28,27 +28,6 @@ import com.android.text.flags.Flags;
*/
public class ClientFlags {
/**
- * @see Flags#noBreakNoHyphenationSpan()
- */
- public static boolean noBreakNoHyphenationSpan() {
- return TextFlags.isFeatureEnabled(Flags.FLAG_NO_BREAK_NO_HYPHENATION_SPAN);
- }
-
- /**
- * @see Flags#fixLineHeightForLocale()
- */
- public static boolean fixLineHeightForLocale() {
- return TextFlags.isFeatureEnabled(Flags.FLAG_FIX_LINE_HEIGHT_FOR_LOCALE);
- }
-
- /**
- * @see Flags#icuBidiMigration()
- */
- public static boolean icuBidiMigration() {
- return TextFlags.isFeatureEnabled(Flags.FLAG_ICU_BIDI_MIGRATION);
- }
-
- /**
* @see Flags#fixMisalignedContextMenu()
*/
public static boolean fixMisalignedContextMenu() {
diff --git a/core/java/android/text/MeasuredParagraph.java b/core/java/android/text/MeasuredParagraph.java
index 896e08726419..31a226341907 100644
--- a/core/java/android/text/MeasuredParagraph.java
+++ b/core/java/android/text/MeasuredParagraph.java
@@ -42,8 +42,6 @@ import android.text.style.MetricAffectingSpan;
import android.text.style.ReplacementSpan;
import android.util.Pools.SynchronizedPool;
-import com.android.text.flags.Flags;
-
import java.util.Arrays;
/**
@@ -201,14 +199,11 @@ public class MeasuredParagraph {
* @hide
*/
public @Layout.Direction int getParagraphDir() {
- if (Flags.icuBidiMigration()) {
- if (mBidi == null) {
- return Layout.DIR_LEFT_TO_RIGHT;
- }
- return (mBidi.getParaLevel() & 0x01) == 0
- ? Layout.DIR_LEFT_TO_RIGHT : Layout.DIR_RIGHT_TO_LEFT;
+ if (mBidi == null) {
+ return Layout.DIR_LEFT_TO_RIGHT;
}
- return mParaDir;
+ return (mBidi.getParaLevel() & 0x01) == 0
+ ? Layout.DIR_LEFT_TO_RIGHT : Layout.DIR_RIGHT_TO_LEFT;
}
/**
@@ -219,71 +214,62 @@ public class MeasuredParagraph {
*/
public Directions getDirections(@IntRange(from = 0) int start, // inclusive
@IntRange(from = 0) int end) { // exclusive
- if (Flags.icuBidiMigration()) {
- // Easy case: mBidi == null means the text is all LTR and no bidi suppot is needed.
- if (mBidi == null) {
- return Layout.DIRS_ALL_LEFT_TO_RIGHT;
- }
+ // Easy case: mBidi == null means the text is all LTR and no bidi suppot is needed.
+ if (mBidi == null) {
+ return Layout.DIRS_ALL_LEFT_TO_RIGHT;
+ }
- // Easy case: If the original text only contains single directionality run, the
- // substring is only single run.
- if (start == end) {
- if ((mBidi.getParaLevel() & 0x01) == 0) {
- return Layout.DIRS_ALL_LEFT_TO_RIGHT;
- } else {
- return Layout.DIRS_ALL_RIGHT_TO_LEFT;
- }
+ // Easy case: If the original text only contains single directionality run, the
+ // substring is only single run.
+ if (start == end) {
+ if ((mBidi.getParaLevel() & 0x01) == 0) {
+ return Layout.DIRS_ALL_LEFT_TO_RIGHT;
+ } else {
+ return Layout.DIRS_ALL_RIGHT_TO_LEFT;
}
+ }
- // Okay, now we need to generate the line instance.
- Bidi bidi = mBidi.createLineBidi(start, end);
-
- // Easy case: If the line instance only contains single directionality run, no need
- // to reorder visually.
- if (bidi.getRunCount() == 1) {
- if (bidi.getRunLevel(0) == 1) {
- return Layout.DIRS_ALL_RIGHT_TO_LEFT;
- } else if (bidi.getRunLevel(0) == 0) {
- return Layout.DIRS_ALL_LEFT_TO_RIGHT;
- } else {
- return new Directions(new int[] {
- 0, bidi.getRunLevel(0) << Layout.RUN_LEVEL_SHIFT | (end - start)});
- }
- }
+ // Okay, now we need to generate the line instance.
+ Bidi bidi = mBidi.createLineBidi(start, end);
- // Reorder directionality run visually.
- byte[] levels = new byte[bidi.getRunCount()];
- for (int i = 0; i < bidi.getRunCount(); ++i) {
- levels[i] = (byte) bidi.getRunLevel(i);
+ // Easy case: If the line instance only contains single directionality run, no need
+ // to reorder visually.
+ if (bidi.getRunCount() == 1) {
+ if (bidi.getRunLevel(0) == 1) {
+ return Layout.DIRS_ALL_RIGHT_TO_LEFT;
+ } else if (bidi.getRunLevel(0) == 0) {
+ return Layout.DIRS_ALL_LEFT_TO_RIGHT;
+ } else {
+ return new Directions(new int[] {
+ 0, bidi.getRunLevel(0) << Layout.RUN_LEVEL_SHIFT | (end - start)});
}
- int[] visualOrders = Bidi.reorderVisual(levels);
-
- int[] dirs = new int[bidi.getRunCount() * 2];
- for (int i = 0; i < bidi.getRunCount(); ++i) {
- int vIndex;
- if ((mBidi.getBaseLevel() & 0x01) == 1) {
- // For the historical reasons, if the base directionality is RTL, the Android
- // draws from the right, i.e. the visually reordered run needs to be reversed.
- vIndex = visualOrders[bidi.getRunCount() - i - 1];
- } else {
- vIndex = visualOrders[i];
- }
+ }
- // Special packing of dire
- dirs[i * 2] = bidi.getRunStart(vIndex);
- dirs[i * 2 + 1] = bidi.getRunLevel(vIndex) << Layout.RUN_LEVEL_SHIFT
- | (bidi.getRunLimit(vIndex) - dirs[i * 2]);
+ // Reorder directionality run visually.
+ byte[] levels = new byte[bidi.getRunCount()];
+ for (int i = 0; i < bidi.getRunCount(); ++i) {
+ levels[i] = (byte) bidi.getRunLevel(i);
+ }
+ int[] visualOrders = Bidi.reorderVisual(levels);
+
+ int[] dirs = new int[bidi.getRunCount() * 2];
+ for (int i = 0; i < bidi.getRunCount(); ++i) {
+ int vIndex;
+ if ((mBidi.getBaseLevel() & 0x01) == 1) {
+ // For the historical reasons, if the base directionality is RTL, the Android
+ // draws from the right, i.e. the visually reordered run needs to be reversed.
+ vIndex = visualOrders[bidi.getRunCount() - i - 1];
+ } else {
+ vIndex = visualOrders[i];
}
- return new Directions(dirs);
- }
- if (mLtrWithoutBidi) {
- return Layout.DIRS_ALL_LEFT_TO_RIGHT;
+ // Special packing of dire
+ dirs[i * 2] = bidi.getRunStart(vIndex);
+ dirs[i * 2 + 1] = bidi.getRunLevel(vIndex) << Layout.RUN_LEVEL_SHIFT
+ | (bidi.getRunLimit(vIndex) - dirs[i * 2]);
}
- final int length = end - start;
- return AndroidBidi.directions(mParaDir, mLevels.getRawArray(), start, mCopiedBuffer, start,
- length);
+ return new Directions(dirs);
}
/**
@@ -681,84 +667,56 @@ public class MeasuredParagraph {
}
}
- if (Flags.icuBidiMigration()) {
- if ((textDir == TextDirectionHeuristics.LTR
- || textDir == TextDirectionHeuristics.FIRSTSTRONG_LTR
- || textDir == TextDirectionHeuristics.ANYRTL_LTR)
- && TextUtils.doesNotNeedBidi(mCopiedBuffer, 0, mTextLength)) {
- mLevels.clear();
- mLtrWithoutBidi = true;
- return;
- }
- final int bidiRequest;
- if (textDir == TextDirectionHeuristics.LTR) {
- bidiRequest = Bidi.LTR;
- } else if (textDir == TextDirectionHeuristics.RTL) {
- bidiRequest = Bidi.RTL;
- } else if (textDir == TextDirectionHeuristics.FIRSTSTRONG_LTR) {
- bidiRequest = Bidi.LEVEL_DEFAULT_LTR;
- } else if (textDir == TextDirectionHeuristics.FIRSTSTRONG_RTL) {
- bidiRequest = Bidi.LEVEL_DEFAULT_RTL;
- } else {
- final boolean isRtl = textDir.isRtl(mCopiedBuffer, 0, mTextLength);
- bidiRequest = isRtl ? Bidi.RTL : Bidi.LTR;
- }
- mBidi = new Bidi(mCopiedBuffer, 0, null, 0, mCopiedBuffer.length, bidiRequest);
-
- if (mCopiedBuffer.length > 0
- && mBidi.getParagraphIndex(mCopiedBuffer.length - 1) != 0) {
- // Historically, the MeasuredParagraph does not treat the CR letters as paragraph
- // breaker but ICU BiDi treats it as paragraph breaker. In the MeasureParagraph,
- // the given range always represents a single paragraph, so if the BiDi object has
- // multiple paragraph, it should contains a CR letters in the text. Using CR is not
- // common in Android and also it should not penalize the easy case, e.g. all LTR,
- // check the paragraph count here and replace the CR letters and re-calculate
- // BiDi again.
- for (int i = 0; i < mTextLength; ++i) {
- if (Character.isSurrogate(mCopiedBuffer[i])) {
- // All block separators are in BMP.
- continue;
- }
- if (UCharacter.getDirection(mCopiedBuffer[i])
- == UCharacterDirection.BLOCK_SEPARATOR) {
- mCopiedBuffer[i] = OBJECT_REPLACEMENT_CHARACTER;
- }
- }
- mBidi = new Bidi(mCopiedBuffer, 0, null, 0, mCopiedBuffer.length, bidiRequest);
- }
- mLevels.resize(mTextLength);
- byte[] rawArray = mLevels.getRawArray();
- for (int i = 0; i < mTextLength; ++i) {
- rawArray[i] = mBidi.getLevelAt(i);
- }
- mLtrWithoutBidi = false;
- return;
- }
if ((textDir == TextDirectionHeuristics.LTR
|| textDir == TextDirectionHeuristics.FIRSTSTRONG_LTR
|| textDir == TextDirectionHeuristics.ANYRTL_LTR)
&& TextUtils.doesNotNeedBidi(mCopiedBuffer, 0, mTextLength)) {
mLevels.clear();
- mParaDir = Layout.DIR_LEFT_TO_RIGHT;
mLtrWithoutBidi = true;
+ return;
+ }
+ final int bidiRequest;
+ if (textDir == TextDirectionHeuristics.LTR) {
+ bidiRequest = Bidi.LTR;
+ } else if (textDir == TextDirectionHeuristics.RTL) {
+ bidiRequest = Bidi.RTL;
+ } else if (textDir == TextDirectionHeuristics.FIRSTSTRONG_LTR) {
+ bidiRequest = Bidi.LEVEL_DEFAULT_LTR;
+ } else if (textDir == TextDirectionHeuristics.FIRSTSTRONG_RTL) {
+ bidiRequest = Bidi.LEVEL_DEFAULT_RTL;
} else {
- final int bidiRequest;
- if (textDir == TextDirectionHeuristics.LTR) {
- bidiRequest = Layout.DIR_REQUEST_LTR;
- } else if (textDir == TextDirectionHeuristics.RTL) {
- bidiRequest = Layout.DIR_REQUEST_RTL;
- } else if (textDir == TextDirectionHeuristics.FIRSTSTRONG_LTR) {
- bidiRequest = Layout.DIR_REQUEST_DEFAULT_LTR;
- } else if (textDir == TextDirectionHeuristics.FIRSTSTRONG_RTL) {
- bidiRequest = Layout.DIR_REQUEST_DEFAULT_RTL;
- } else {
- final boolean isRtl = textDir.isRtl(mCopiedBuffer, 0, mTextLength);
- bidiRequest = isRtl ? Layout.DIR_REQUEST_RTL : Layout.DIR_REQUEST_LTR;
+ final boolean isRtl = textDir.isRtl(mCopiedBuffer, 0, mTextLength);
+ bidiRequest = isRtl ? Bidi.RTL : Bidi.LTR;
+ }
+ mBidi = new Bidi(mCopiedBuffer, 0, null, 0, mCopiedBuffer.length, bidiRequest);
+
+ if (mCopiedBuffer.length > 0
+ && mBidi.getParagraphIndex(mCopiedBuffer.length - 1) != 0) {
+ // Historically, the MeasuredParagraph does not treat the CR letters as paragraph
+ // breaker but ICU BiDi treats it as paragraph breaker. In the MeasureParagraph,
+ // the given range always represents a single paragraph, so if the BiDi object has
+ // multiple paragraph, it should contains a CR letters in the text. Using CR is not
+ // common in Android and also it should not penalize the easy case, e.g. all LTR,
+ // check the paragraph count here and replace the CR letters and re-calculate
+ // BiDi again.
+ for (int i = 0; i < mTextLength; ++i) {
+ if (Character.isSurrogate(mCopiedBuffer[i])) {
+ // All block separators are in BMP.
+ continue;
+ }
+ if (UCharacter.getDirection(mCopiedBuffer[i])
+ == UCharacterDirection.BLOCK_SEPARATOR) {
+ mCopiedBuffer[i] = OBJECT_REPLACEMENT_CHARACTER;
+ }
}
- mLevels.resize(mTextLength);
- mParaDir = AndroidBidi.bidi(bidiRequest, mCopiedBuffer, mLevels.getRawArray());
- mLtrWithoutBidi = false;
+ mBidi = new Bidi(mCopiedBuffer, 0, null, 0, mCopiedBuffer.length, bidiRequest);
+ }
+ mLevels.resize(mTextLength);
+ byte[] rawArray = mLevels.getRawArray();
+ for (int i = 0; i < mTextLength; ++i) {
+ rawArray[i] = mBidi.getLevelAt(i);
}
+ mLtrWithoutBidi = false;
}
private void applyReplacementRun(@NonNull ReplacementSpan replacement,
diff --git a/core/java/android/text/TextFlags.java b/core/java/android/text/TextFlags.java
index 0f1b031a8fad..076721f629ed 100644
--- a/core/java/android/text/TextFlags.java
+++ b/core/java/android/text/TextFlags.java
@@ -55,9 +55,6 @@ public final class TextFlags {
* List of text flags to be transferred to the application process.
*/
public static final String[] TEXT_ACONFIGS_FLAGS = {
- Flags.FLAG_NO_BREAK_NO_HYPHENATION_SPAN,
- Flags.FLAG_FIX_LINE_HEIGHT_FOR_LOCALE,
- Flags.FLAG_ICU_BIDI_MIGRATION,
Flags.FLAG_FIX_MISALIGNED_CONTEXT_MENU,
};
@@ -67,9 +64,6 @@ public final class TextFlags {
* The order must be the same to the TEXT_ACONFIG_FLAGS.
*/
public static final boolean[] TEXT_ACONFIG_DEFAULT_VALUE = {
- Flags.noBreakNoHyphenationSpan(),
- Flags.fixLineHeightForLocale(),
- Flags.icuBidiMigration(),
Flags.fixMisalignedContextMenu(),
};
diff --git a/core/java/android/text/flags/24Q3.aconfig b/core/java/android/text/flags/24Q3.aconfig
new file mode 100644
index 000000000000..7035fc842a48
--- /dev/null
+++ b/core/java/android/text/flags/24Q3.aconfig
@@ -0,0 +1,54 @@
+package: "com.android.text.flags"
+container: "system"
+
+# This aconfig file contains released flags in 24Q3 those cannot be removed.
+
+flag {
+ name: "use_bounds_for_width"
+ is_exported: true
+ namespace: "text"
+ description: "Feature flag for preventing horizontal clipping."
+ bug: "63938206"
+}
+
+flag {
+ name: "word_style_auto"
+ is_exported: true
+ namespace: "text"
+ description: "A feature flag that implements line break word style auto."
+ bug: "280005585"
+}
+
+flag {
+ name: "letter_spacing_justification"
+ is_exported: true
+ namespace: "text"
+ description: "A feature flag that implement inter character justification."
+ bug: "283193133"
+}
+
+flag {
+ name: "fix_line_height_for_locale"
+ is_exported: true
+ namespace: "text"
+ description: "Feature flag that preserve the line height of the TextView and EditText even if the the locale is different from Latin"
+ bug: "303326708"
+}
+
+flag {
+ name: "new_fonts_fallback_xml"
+ is_exported: true
+ namespace: "text"
+ description: "Feature flag for deprecating fonts.xml. By setting true for this feature flag, the new font configuration XML, /system/etc/font_fallback.xml is used. The new XML has a new syntax and flexibility of variable font declarations, but it is not compatible with the apps that reads fonts.xml. So, fonts.xml is maintained as a subset of the font_fallback.xml"
+ # Make read only, as it could be used before the Settings provider is initialized.
+ is_fixed_read_only: true
+ bug: "281769620"
+}
+
+flag {
+ name: "no_break_no_hyphenation_span"
+ is_exported: true
+ namespace: "text"
+ description: "A feature flag that adding new spans that prevents line breaking and hyphenation."
+ bug: "283193586"
+}
diff --git a/core/java/android/text/flags/flags.aconfig b/core/java/android/text/flags/flags.aconfig
index b2be1a7ef351..3c61f4f5a33c 100644
--- a/core/java/android/text/flags/flags.aconfig
+++ b/core/java/android/text/flags/flags.aconfig
@@ -2,32 +2,6 @@ package: "com.android.text.flags"
container: "system"
flag {
- name: "new_fonts_fallback_xml"
- is_exported: true
- namespace: "text"
- description: "Feature flag for deprecating fonts.xml. By setting true for this feature flag, the new font configuration XML, /system/etc/font_fallback.xml is used. The new XML has a new syntax and flexibility of variable font declarations, but it is not compatible with the apps that reads fonts.xml. So, fonts.xml is maintained as a subset of the font_fallback.xml"
- # Make read only, as it could be used before the Settings provider is initialized.
- is_fixed_read_only: true
- bug: "281769620"
-}
-
-flag {
- name: "fix_line_height_for_locale"
- is_exported: true
- namespace: "text"
- description: "Feature flag that preserve the line height of the TextView and EditText even if the the locale is different from Latin"
- bug: "303326708"
-}
-
-flag {
- name: "no_break_no_hyphenation_span"
- is_exported: true
- namespace: "text"
- description: "A feature flag that adding new spans that prevents line breaking and hyphenation."
- bug: "283193586"
-}
-
-flag {
name: "use_optimized_boottime_font_loading"
namespace: "text"
description: "Feature flag ensuring that font is loaded once and asynchronously."
@@ -51,37 +25,6 @@ flag {
}
flag {
- name: "use_bounds_for_width"
- is_exported: true
- namespace: "text"
- description: "Feature flag for preventing horizontal clipping."
- bug: "63938206"
-}
-
-flag {
- name: "deprecate_ui_fonts"
- namespace: "text"
- description: "Feature flag for deprecating UI fonts. By setting true for this feature flag, the elegant text height of will be turned on by default unless explicitly setting it to false by attribute or Java API call."
- bug: "279646685"
-}
-
-flag {
- name: "word_style_auto"
- is_exported: true
- namespace: "text"
- description: "A feature flag that implements line break word style auto."
- bug: "280005585"
-}
-
-flag {
- name: "letter_spacing_justification"
- is_exported: true
- namespace: "text"
- description: "A feature flag that implement inter character justification."
- bug: "283193133"
-}
-
-flag {
name: "escape_clears_focus"
namespace: "text"
description: "Feature flag for clearing focus when the escape key is pressed."
@@ -120,22 +63,6 @@ flag {
}
flag {
- name: "icu_bidi_migration"
- namespace: "text"
- description: "A flag for replacing AndroidBidi with android.icu.text.Bidi."
- bug: "317144801"
-}
-
-flag {
- name: "lazy_variation_instance"
- namespace: "text"
- description: "A flag for enabling lazy variation instance creation."
- # Make read only, as it could be used before the Settings provider is initialized.
- is_fixed_read_only: true
- bug: "324676775"
-}
-
-flag {
name: "handwriting_end_of_line_tap"
namespace: "text"
description: "Initiate handwriting when stylus taps at the end of a line in a focused non-empty TextView with the cursor at the end of that line"
diff --git a/core/java/android/util/Slog.java b/core/java/android/util/Slog.java
index 9ecb4cbb283d..b2017a5fa868 100644
--- a/core/java/android/util/Slog.java
+++ b/core/java/android/util/Slog.java
@@ -224,7 +224,6 @@ public final class Slog {
/**
* Similar to {@link #wtf(String, String)}, but does not output anything to the log.
*/
- @android.ravenwood.annotation.RavenwoodThrow
public static void wtfQuiet(@Nullable String tag, @NonNull String msg) {
Log.wtfQuiet(Log.LOG_ID_SYSTEM, tag, msg, true);
}
@@ -243,7 +242,6 @@ public final class Slog {
* @see Log#wtfStack(String, String)
*/
@UnsupportedAppUsage(maxTargetSdk = Build.VERSION_CODES.P, trackingBug = 115609023)
- @android.ravenwood.annotation.RavenwoodThrow
public static int wtfStack(@Nullable String tag, @NonNull String msg) {
return Log.wtf(Log.LOG_ID_SYSTEM, tag, msg, null, true, true);
}
diff --git a/core/java/android/view/PointerIcon.java b/core/java/android/view/PointerIcon.java
index 815fd1c49a38..dd950e83dd52 100644
--- a/core/java/android/view/PointerIcon.java
+++ b/core/java/android/view/PointerIcon.java
@@ -540,8 +540,6 @@ public final class PointerIcon implements Parcelable {
// Assumes they have the exact duration.
mDurationPerFrame = animationDrawable.getDuration(0);
mBitmapFrames = new Bitmap[frames - 1];
- final int width = drawable.getIntrinsicWidth();
- final int height = drawable.getIntrinsicHeight();
final boolean isVectorAnimation = drawable instanceof VectorDrawable;
mDrawNativeDropShadow = isVectorAnimation;
for (int i = 1; i < frames; ++i) {
@@ -556,9 +554,6 @@ public final class PointerIcon implements Parcelable {
+ "is a different type from the others. All frames should be the "
+ "same type.");
}
- // TODO(b/361232935): Check when bitmap size of the ith frame is different
- // drawableFrame.getIntrinsicWidth() != width ||
- // drawableFrame.getIntrinsicHeight() != height
if (isVectorAnimation) {
drawableFrame = getBitmapDrawableFromVectorDrawable(resources,
(VectorDrawable) drawableFrame, pointerScale);
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 7b4ea41554f1..0ed0e60f6b4d 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -371,7 +371,7 @@ import java.util.function.Predicate;
* </tr>
* <tr>
* <td><code>{@link #onTouchEvent(MotionEvent)}</code></td>
- * <td>Called when a touch screen motion event occurs.
+ * <td>Called when a motion event occurs with pointers down on the view.
* </td>
* </tr>
* <tr>
@@ -17873,7 +17873,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
}
/**
- * Implement this method to handle touch screen motion events.
+ * Implement this method to handle pointer events.
+ * <p>
+ * This method is called to handle motion events where pointers are down on
+ * the view. For example, this could include touchscreen touches, stylus
+ * touches, or click-and-drag events from a mouse. However, it is not called
+ * for motion events that do not involve pointers being down, such as hover
+ * events or mouse scroll wheel movements.
* <p>
* If this method is used to detect click actions, it is recommended that
* the actions be performed by implementing and calling
diff --git a/core/java/android/view/ViewGroup.java b/core/java/android/view/ViewGroup.java
index 3b5286a04b3d..22374173b988 100644
--- a/core/java/android/view/ViewGroup.java
+++ b/core/java/android/view/ViewGroup.java
@@ -4504,6 +4504,11 @@ public abstract class ViewGroup extends View implements ViewParent, ViewManager
final View[] children = mChildren;
for (int i = 0; i < count; i++) {
final View child = children[i];
+ if (child == null) {
+ throw new IllegalStateException(getClass().getSimpleName() + " contains null " +
+ "child at index " + i + " when traversal in dispatchGetDisplayList," +
+ " the view may have been removed.");
+ }
if (((child.mViewFlags & VISIBILITY_MASK) == VISIBLE || child.getAnimation() != null)) {
recreateChildDisplayList(child);
}
diff --git a/core/java/android/view/WindowManager.java b/core/java/android/view/WindowManager.java
index 67a207e34a1a..5b39f62db261 100644
--- a/core/java/android/view/WindowManager.java
+++ b/core/java/android/view/WindowManager.java
@@ -107,6 +107,7 @@ import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.res.Configuration;
import android.graphics.Bitmap;
+import android.graphics.Insets;
import android.graphics.PixelFormat;
import android.graphics.Point;
import android.graphics.Rect;
@@ -2371,7 +2372,7 @@ public interface WindowManager extends ViewManager {
public static final int TYPE_SECURE_SYSTEM_OVERLAY = FIRST_SYSTEM_WINDOW+15;
/**
- * Window type: the drag-and-drop pseudowindow. There is only one
+ * Window type: the drag-and-drop pseudowindow. There is only one
* drag layer (at most), and it is placed on top of all other windows.
* In multiuser systems shows only on the owning user's window.
* @hide
@@ -2381,7 +2382,7 @@ public interface WindowManager extends ViewManager {
/**
* Window type: panel that slides out from over the status bar
* In multiuser systems shows on all users' windows. These windows
- * are displayed on top of the stauts bar and any {@link #TYPE_STATUS_BAR_PANEL}
+ * are displayed on top of the status bar and any {@link #TYPE_STATUS_BAR_PANEL}
* windows.
* @hide
*/
@@ -4649,6 +4650,30 @@ public interface WindowManager extends ViewManager {
public InsetsFrameProvider[] providedInsets;
/**
+ * Sets the insets to be provided by the window.
+ *
+ * @param insetsParams The parameters for the insets to be provided by the window.
+ *
+ * @hide
+ */
+ @FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_STATUS_BAR_AND_INSETS)
+ @SystemApi
+ public void setInsetsParams(@NonNull List<InsetsParams> insetsParams) {
+ if (insetsParams.isEmpty()) {
+ providedInsets = null;
+ } else {
+ providedInsets = new InsetsFrameProvider[insetsParams.size()];
+ for (int i = 0; i < insetsParams.size(); ++i) {
+ final InsetsParams params = insetsParams.get(i);
+ providedInsets[i] =
+ new InsetsFrameProvider(/* owner= */ this, /* index= */ i,
+ params.getType())
+ .setInsetsSize(params.getInsetsSize());
+ }
+ }
+ }
+
+ /**
* Specifies which {@link InsetsType}s should be forcibly shown. The types shown by this
* method won't affect the app's layout. This field only takes effects if the caller has
* {@link android.Manifest.permission#STATUS_BAR_SERVICE} or the caller has the same uid as
@@ -6117,6 +6142,56 @@ public interface WindowManager extends ViewManager {
}
/**
+ * Specifies the parameters of the insets provided by a window.
+ *
+ * @see WindowManager.LayoutParams#setInsetsParams(List)
+ * @see android.graphics.Insets
+ *
+ * @hide
+ */
+ @FlaggedApi(android.companion.virtualdevice.flags.Flags.FLAG_STATUS_BAR_AND_INSETS)
+ @SystemApi
+ public static class InsetsParams {
+
+ private final @InsetsType int mType;
+ private @Nullable Insets mInsets;
+
+ /**
+ * Creates an instance of InsetsParams.
+ *
+ * @param type the type of insets to provide, e.g. {@link WindowInsets.Type#statusBars()}.
+ * @see WindowInsets.Type
+ */
+ public InsetsParams(@InsetsType int type) {
+ mType = type;
+ }
+
+ /**
+ * Sets the size of the provided insets. If {@code null}, then the provided insets will
+ * have the same size as the window frame.
+ */
+ public @NonNull InsetsParams setInsetsSize(@Nullable Insets insets) {
+ mInsets = insets;
+ return this;
+ }
+
+ /**
+ * Returns the type of provided insets.
+ */
+ public @InsetsType int getType() {
+ return mType;
+ }
+
+ /**
+ * Returns the size of the provided insets. May be {@code null} if the provided insets have
+ * the same size as the window frame.
+ */
+ public @Nullable Insets getInsetsSize() {
+ return mInsets;
+ }
+ }
+
+ /**
* Holds the WM lock for the specified amount of milliseconds.
* Intended for use by the tests that need to imitate lock contention.
* The token should be obtained by
diff --git a/core/java/android/view/accessibility/AccessibilityManager.java b/core/java/android/view/accessibility/AccessibilityManager.java
index a87e5c8e1b56..2b7cf427a562 100644
--- a/core/java/android/view/accessibility/AccessibilityManager.java
+++ b/core/java/android/view/accessibility/AccessibilityManager.java
@@ -1774,7 +1774,8 @@ public final class AccessibilityManager {
}
/**
- * Notifies that the accessibility button in the system's navigation area has been clicked
+ * Notifies that the accessibility button in the system's navigation area has been clicked,
+ * or a gesture shortcut input has been performed.
*
* @param displayId The logical display id.
* @hide
@@ -1785,7 +1786,8 @@ public final class AccessibilityManager {
}
/**
- * Perform the accessibility button for the given target which is assigned to the button.
+ * Perform the accessibility button or gesture
+ * for the given target which is assigned to the button.
*
* @param displayId displayId The logical display id.
* @param targetName The flattened {@link ComponentName} string or the class name of a system
@@ -1810,6 +1812,31 @@ public final class AccessibilityManager {
}
/**
+ * Notifies that a shortcut was long-clicked.
+ * This displays the dialog used to select which target the given shortcut will use,
+ * from its list of targets.
+ * The current shortcut type is determined by the current navigation mode.
+ *
+ * @param displayId The id of the display to show the dialog on.
+ * @hide
+ */
+ @RequiresPermission(Manifest.permission.STATUS_BAR_SERVICE)
+ public void notifyAccessibilityButtonLongClicked(int displayId) {
+ final IAccessibilityManager service;
+ synchronized (mLock) {
+ service = getServiceLocked();
+ if (service == null) {
+ return;
+ }
+ }
+ try {
+ service.notifyAccessibilityButtonLongClicked(displayId);
+ } catch (RemoteException re) {
+ Log.e(LOG_TAG, "Error while dispatching accessibility button long click. ", re);
+ }
+ }
+
+ /**
* Notifies that the visibility of the accessibility button in the system's navigation area
* has changed.
*
diff --git a/core/java/android/view/accessibility/IAccessibilityManager.aidl b/core/java/android/view/accessibility/IAccessibilityManager.aidl
index 2de3ce8532e3..e04fa1537d54 100644
--- a/core/java/android/view/accessibility/IAccessibilityManager.aidl
+++ b/core/java/android/view/accessibility/IAccessibilityManager.aidl
@@ -88,6 +88,8 @@ interface IAccessibilityManager {
@EnforcePermission("STATUS_BAR_SERVICE")
void notifyAccessibilityButtonClicked(int displayId, String targetName);
+ @EnforcePermission("STATUS_BAR_SERVICE")
+ void notifyAccessibilityButtonLongClicked(int displayId);
@EnforcePermission("STATUS_BAR_SERVICE")
void notifyAccessibilityButtonVisibilityChanged(boolean available);
diff --git a/core/java/android/webkit/UserPackage.java b/core/java/android/webkit/UserPackage.java
index 1da2af459348..b18dbbc21cda 100644
--- a/core/java/android/webkit/UserPackage.java
+++ b/core/java/android/webkit/UserPackage.java
@@ -15,12 +15,14 @@
*/
package android.webkit;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
-import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.UserInfo;
+import android.content.pm.PackageManager;
import android.os.Build;
+import android.os.UserHandle;
import android.os.UserManager;
import java.util.ArrayList;
@@ -31,30 +33,31 @@ import java.util.List;
* @hide
*/
public class UserPackage {
- private final UserInfo mUserInfo;
+ private final UserHandle mUser;
private final PackageInfo mPackageInfo;
public static final int MINIMUM_SUPPORTED_SDK = Build.VERSION_CODES.TIRAMISU;
- public UserPackage(UserInfo user, PackageInfo packageInfo) {
- this.mUserInfo = user;
- this.mPackageInfo = packageInfo;
+ public UserPackage(@NonNull UserHandle user, @Nullable PackageInfo packageInfo) {
+ mUser = user;
+ mPackageInfo = packageInfo;
}
/**
* Returns a list of (User,PackageInfo) pairs corresponding to the PackageInfos for all
* device users for the package named {@param packageName}.
*/
- public static List<UserPackage> getPackageInfosAllUsers(Context context,
- String packageName, int packageFlags) {
- List<UserInfo> users = getAllUsers(context);
+ public static @NonNull List<UserPackage> getPackageInfosAllUsers(@NonNull Context context,
+ @NonNull String packageName, int packageFlags) {
+ UserManager userManager = context.getSystemService(UserManager.class);
+ List<UserHandle> users = userManager.getUserHandles(false);
List<UserPackage> userPackages = new ArrayList<UserPackage>(users.size());
- for (UserInfo user : users) {
+ for (UserHandle user : users) {
+ PackageManager pm = context.createContextAsUser(user, 0).getPackageManager();
PackageInfo packageInfo = null;
try {
- packageInfo = context.getPackageManager().getPackageInfoAsUser(
- packageName, packageFlags, user.id);
- } catch (NameNotFoundException e) {
+ packageInfo = pm.getPackageInfo(packageName, packageFlags);
+ } catch (PackageManager.NameNotFoundException e) {
}
userPackages.add(new UserPackage(user, packageInfo));
}
@@ -88,18 +91,11 @@ public class UserPackage {
return packageInfo.applicationInfo.targetSdkVersion >= MINIMUM_SUPPORTED_SDK;
}
- public UserInfo getUserInfo() {
- return mUserInfo;
+ public UserHandle getUser() {
+ return mUser;
}
public PackageInfo getPackageInfo() {
return mPackageInfo;
}
-
-
- private static List<UserInfo> getAllUsers(Context context) {
- UserManager userManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
- return userManager.getUsers();
- }
-
}
diff --git a/core/java/android/webkit/WebViewDelegate.java b/core/java/android/webkit/WebViewDelegate.java
index 8501474b70a6..4c5802ccfcf5 100644
--- a/core/java/android/webkit/WebViewDelegate.java
+++ b/core/java/android/webkit/WebViewDelegate.java
@@ -137,9 +137,13 @@ public final class WebViewDelegate {
*/
@Deprecated
public void detachDrawGlFunctor(View containerView, long nativeDrawGLFunctor) {
- ViewRootImpl viewRootImpl = containerView.getViewRootImpl();
- if (nativeDrawGLFunctor != 0 && viewRootImpl != null) {
- viewRootImpl.detachFunctor(nativeDrawGLFunctor);
+ if (Flags.mainlineApis()) {
+ throw new UnsupportedOperationException();
+ } else {
+ ViewRootImpl viewRootImpl = containerView.getViewRootImpl();
+ if (nativeDrawGLFunctor != 0 && viewRootImpl != null) {
+ viewRootImpl.detachFunctor(nativeDrawGLFunctor);
+ }
}
}
diff --git a/core/java/android/widget/ScrollView.java b/core/java/android/widget/ScrollView.java
index b5bf529fadbd..511c832a4876 100644
--- a/core/java/android/widget/ScrollView.java
+++ b/core/java/android/widget/ScrollView.java
@@ -16,6 +16,7 @@
package android.widget;
+import static android.view.flags.Flags.enableTouchScrollFeedback;
import static android.view.flags.Flags.viewVelocityApi;
import android.annotation.ColorInt;
@@ -846,6 +847,8 @@ public class ScrollView extends FrameLayout {
deltaY += mTouchSlop;
}
}
+ boolean hitTopLimit = false;
+ boolean hitBottomLimit = false;
if (mIsBeingDragged) {
// Scroll to follow the motion event
mLastMotionY = y - mScrollOffset[1];
@@ -889,12 +892,14 @@ public class ScrollView extends FrameLayout {
if (!mEdgeGlowBottom.isFinished()) {
mEdgeGlowBottom.onRelease();
}
+ hitTopLimit = true;
} else if (pulledToY > range) {
mEdgeGlowBottom.onPullDistance((float) deltaY / getHeight(),
1.f - displacement);
if (!mEdgeGlowTop.isFinished()) {
mEdgeGlowTop.onRelease();
}
+ hitBottomLimit = true;
}
if (shouldDisplayEdgeEffects()
&& (!mEdgeGlowTop.isFinished() || !mEdgeGlowBottom.isFinished())) {
@@ -902,6 +907,20 @@ public class ScrollView extends FrameLayout {
}
}
}
+
+ // TODO: b/360198915 - Add unit tests.
+ if (enableTouchScrollFeedback()) {
+ if (hitTopLimit || hitBottomLimit) {
+ initHapticScrollFeedbackProviderIfNotExists();
+ mHapticScrollFeedbackProvider.onScrollLimit(vtev.getDeviceId(),
+ vtev.getSource(), MotionEvent.AXIS_Y,
+ /* isStart= */ hitTopLimit);
+ } else if (Math.abs(deltaY) != 0) {
+ initHapticScrollFeedbackProviderIfNotExists();
+ mHapticScrollFeedbackProvider.onScrollProgress(vtev.getDeviceId(),
+ vtev.getSource(), MotionEvent.AXIS_Y, deltaY);
+ }
+ }
break;
case MotionEvent.ACTION_UP:
if (mIsBeingDragged) {
diff --git a/core/java/android/widget/flags/flags.aconfig b/core/java/android/widget/flags/flags.aconfig
new file mode 100644
index 000000000000..f0ed83be8f1e
--- /dev/null
+++ b/core/java/android/widget/flags/flags.aconfig
@@ -0,0 +1,11 @@
+package: "android.widget.flags"
+container: "system"
+flag {
+ name: "enable_fading_view_group"
+ namespace: "system_performance"
+ description: "FRP screen during OOBE must have fading and scaling animation in Wear Watches"
+ bug: "348515581"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+} \ No newline at end of file
diff --git a/core/java/android/window/flags/lse_desktop_experience.aconfig b/core/java/android/window/flags/lse_desktop_experience.aconfig
index 3998ac634f43..8e81951ba4ca 100644
--- a/core/java/android/window/flags/lse_desktop_experience.aconfig
+++ b/core/java/android/window/flags/lse_desktop_experience.aconfig
@@ -251,3 +251,10 @@ flag {
description: "Persists the desktop windowing session across reboots."
bug: "350456942"
}
+
+flag {
+ name: "enable_display_focus_in_shell_transitions"
+ namespace: "lse_desktop_experience"
+ description: "Creates a shell transition when display focus switches."
+ bug: "356109871"
+}
diff --git a/core/java/com/android/internal/accessibility/dialog/AccessibilityButtonChooserActivity.java b/core/java/com/android/internal/accessibility/dialog/AccessibilityButtonChooserActivity.java
index 01cbb5514669..81d8adfce2ae 100644
--- a/core/java/com/android/internal/accessibility/dialog/AccessibilityButtonChooserActivity.java
+++ b/core/java/com/android/internal/accessibility/dialog/AccessibilityButtonChooserActivity.java
@@ -20,7 +20,6 @@ import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_COMPONENT_NAME;
import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME;
-import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.GESTURE;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
import static com.android.internal.accessibility.dialog.AccessibilityTargetHelper.getTargets;
import static com.android.internal.accessibility.util.AccessibilityStatsLogUtils.logAccessibilityButtonLongPressStatus;
@@ -44,6 +43,8 @@ import java.util.List;
* Activity used to display and persist a service or feature target for the Accessibility button.
*/
public class AccessibilityButtonChooserActivity extends Activity {
+ public static final String EXTRA_TYPE_TO_CHOOSE = "TYPE";
+
private final List<AccessibilityTarget> mTargets = new ArrayList<>();
@Override
@@ -67,8 +68,8 @@ public class AccessibilityButtonChooserActivity extends Activity {
NAV_BAR_MODE_GESTURAL == getResources().getInteger(
com.android.internal.R.integer.config_navBarInteractionMode);
- final int targetType = (isGestureNavigateEnabled
- && android.provider.Flags.a11yStandaloneGestureEnabled()) ? GESTURE : SOFTWARE;
+ final int targetType = android.provider.Flags.a11yStandaloneGestureEnabled()
+ ? getIntent().getIntExtra(EXTRA_TYPE_TO_CHOOSE, SOFTWARE) : SOFTWARE;
if (isGestureNavigateEnabled) {
final TextView promptPrologue = findViewById(R.id.accessibility_button_prompt_prologue);
diff --git a/core/java/com/android/internal/app/SetScreenLockDialogActivity.java b/core/java/com/android/internal/app/SetScreenLockDialogActivity.java
index 360fcafe3318..4c3af4d45380 100644
--- a/core/java/com/android/internal/app/SetScreenLockDialogActivity.java
+++ b/core/java/com/android/internal/app/SetScreenLockDialogActivity.java
@@ -60,6 +60,7 @@ public class SetScreenLockDialogActivity extends AlertActivity
LAUNCH_REASON_PRIVATE_SPACE_SETTINGS_ACCESS,
LAUNCH_REASON_DISABLE_QUIET_MODE,
LAUNCH_REASON_UNKNOWN,
+ LAUNCH_REASON_RESET_PRIVATE_SPACE_SETTINGS_ACCESS,
})
@Retention(RetentionPolicy.SOURCE)
public @interface LaunchReason {
@@ -67,6 +68,7 @@ public class SetScreenLockDialogActivity extends AlertActivity
public static final int LAUNCH_REASON_UNKNOWN = -1;
public static final int LAUNCH_REASON_DISABLE_QUIET_MODE = 1;
public static final int LAUNCH_REASON_PRIVATE_SPACE_SETTINGS_ACCESS = 2;
+ public static final int LAUNCH_REASON_RESET_PRIVATE_SPACE_SETTINGS_ACCESS = 3;
private @LaunchReason int mReason;
private int mOriginUserId;
@@ -139,7 +141,11 @@ public class SetScreenLockDialogActivity extends AlertActivity
// Always set private space message if launch reason is specific to private space
builder.setMessage(R.string.private_space_set_up_screen_lock_message);
return;
+ } else if (mReason == LAUNCH_REASON_RESET_PRIVATE_SPACE_SETTINGS_ACCESS) {
+ builder.setMessage(R.string.private_space_set_up_screen_lock_for_reset);
+ return;
}
+
final UserManager userManager = getApplicationContext().getSystemService(UserManager.class);
if (userManager != null) {
UserInfo userInfo = userManager.getUserInfo(mOriginUserId);
diff --git a/core/java/com/android/internal/jank/flags.aconfig b/core/java/com/android/internal/jank/flags.aconfig
index b6b8bc5ac44c..82f50ae848b3 100644
--- a/core/java/com/android/internal/jank/flags.aconfig
+++ b/core/java/com/android/internal/jank/flags.aconfig
@@ -3,7 +3,7 @@ container: "system"
flag {
name: "use_sf_frame_duration"
- namespace: "android_platform_window_surfaces"
+ namespace: "window_surfaces"
description: "Whether to get the frame duration from SurfaceFlinger, or HWUI"
bug: "354763298"
is_fixed_read_only: true
diff --git a/core/java/com/android/internal/pm/parsing/pkg/PackageImpl.java b/core/java/com/android/internal/pm/parsing/pkg/PackageImpl.java
index 032ac4283712..12d326486e77 100644
--- a/core/java/com/android/internal/pm/parsing/pkg/PackageImpl.java
+++ b/core/java/com/android/internal/pm/parsing/pkg/PackageImpl.java
@@ -3025,7 +3025,6 @@ public class PackageImpl implements ParsedPackage, AndroidPackageInternal,
@Override
public PackageImpl setSplitCodePaths(@Nullable String[] splitCodePaths) {
this.splitCodePaths = splitCodePaths;
- this.mSplits = null; // reset for paths changed
if (splitCodePaths != null) {
int size = splitCodePaths.length;
for (int index = 0; index < size; index++) {
diff --git a/core/java/com/android/internal/widget/ViewGroupFader.java b/core/java/com/android/internal/widget/ViewGroupFader.java
index b54023a3382e..21206c244c8f 100644
--- a/core/java/com/android/internal/widget/ViewGroupFader.java
+++ b/core/java/com/android/internal/widget/ViewGroupFader.java
@@ -16,12 +16,14 @@
package com.android.internal.widget;
+import android.content.res.Resources;
import android.graphics.Rect;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.MarginLayoutParams;
import android.view.animation.BaseInterpolator;
import android.view.animation.PathInterpolator;
+import android.widget.flags.Flags;
/**
* This class is ported from
@@ -36,7 +38,7 @@ import android.view.animation.PathInterpolator;
* height of the child. When not in the top or bottom regions, children have their default alpha and
* scale.
*/
-class ViewGroupFader {
+public class ViewGroupFader {
private static final float SCALE_LOWER_BOUND = 0.7f;
private float mScaleLowerBound = SCALE_LOWER_BOUND;
@@ -68,7 +70,7 @@ class ViewGroupFader {
private BaseInterpolator mBottomInterpolator = new PathInterpolator(0.3f, 0f, 0.7f, 1f);
/** Callback which is called when attempting to fade a view. */
- interface AnimationCallback {
+ public interface AnimationCallback {
boolean shouldFadeFromTop(View view);
boolean shouldFadeFromBottom(View view);
@@ -82,7 +84,7 @@ class ViewGroupFader {
* of the current position.
*/
// TODO(b/182846214): Clean up the interface design to avoid exposing too much details to users.
- interface ChildViewBoundsProvider {
+ public interface ChildViewBoundsProvider {
/**
* Provide the bounds of the child view.
*
@@ -168,7 +170,7 @@ class ViewGroupFader {
}
}
- ViewGroupFader(
+ public ViewGroupFader(
ViewGroup parent,
AnimationCallback callback,
ChildViewBoundsProvider childViewBoundsProvider) {
@@ -212,7 +214,7 @@ class ViewGroupFader {
this.mContainerBoundsProvider = boundsProvider;
}
- void updateFade() {
+ public void updateFade() {
mContainerBoundsProvider.provideBounds(mParent, mContainerBounds);
mTopBoundPixels = mContainerBounds.height() * mChainedBoundsTop;
mBottomBoundPixels = mContainerBounds.height() * mChainedBoundsBottom;
@@ -221,13 +223,20 @@ class ViewGroupFader {
}
/** For each list element, calculate and adjust the scale and alpha based on its position */
- private void updateListElementFades(ViewGroup parent, boolean shouldFade) {
+ public void updateListElementFades(ViewGroup parent, boolean shouldFade) {
for (int i = 0; i < parent.getChildCount(); i++) {
View child = parent.getChildAt(i);
if (child.getVisibility() != View.VISIBLE) {
continue;
}
+ if (Flags.enableFadingViewGroup() && Resources.getSystem().getBoolean(
+ com.android.internal.R.bool.config_enableViewGroupScalingFading)) {
+ if (child instanceof ViewGroup) {
+ updateListElementFades((ViewGroup) child, true);
+ }
+ }
+
if (shouldFade) {
fadeElement(parent, child);
}
@@ -312,4 +321,4 @@ class ViewGroupFader {
private static float lerp(float min, float max, float fraction) {
return min + (max - min) * fraction;
}
-}
+} \ No newline at end of file
diff --git a/core/jni/android_database_SQLiteConnection.cpp b/core/jni/android_database_SQLiteConnection.cpp
index 7410468199b8..3370f386f4d2 100644
--- a/core/jni/android_database_SQLiteConnection.cpp
+++ b/core/jni/android_database_SQLiteConnection.cpp
@@ -70,11 +70,14 @@ struct SQLiteConnection {
// Open flags.
// Must be kept in sync with the constants defined in SQLiteDatabase.java.
enum {
+ // LINT.IfChange
OPEN_READWRITE = 0x00000000,
OPEN_READONLY = 0x00000001,
OPEN_READ_MASK = 0x00000001,
NO_LOCALIZED_COLLATORS = 0x00000010,
+ NO_DOUBLE_QUOTED_STRS = 0x00000020,
CREATE_IF_NECESSARY = 0x10000000,
+ // LINT.ThenChange(/core/java/android/database/sqlite/SQLiteDatabase.java)
};
sqlite3* const db;
@@ -156,6 +159,18 @@ static jlong nativeOpen(JNIEnv* env, jclass clazz, jstring pathStr, jint openFla
}
}
+ // Disallow double-quoted string literals if the proper flag is set.
+ if ((openFlags & SQLiteConnection::NO_DOUBLE_QUOTED_STRS) != 0) {
+ void *setting = 0;
+ int err = 0;
+ if ((err = sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DDL, 0, setting)) != SQLITE_OK) {
+ ALOGE("failed to configure SQLITE_DBCONFIG_DQS_DDL: %d", err);
+ }
+ if ((err = sqlite3_db_config(db, SQLITE_DBCONFIG_DQS_DML, 0, setting)) != SQLITE_OK) {
+ ALOGE("failed to configure SQLITE_DBCONFIG_DQS_DML: %d", err);
+ }
+ }
+
// Check that the database is really read/write when that is what we asked for.
if ((sqliteFlags & SQLITE_OPEN_READWRITE) && sqlite3_db_readonly(db, NULL)) {
throw_sqlite3_exception(env, db, "Could not open the database in read/write mode.");
diff --git a/core/jni/android_os_Parcel.cpp b/core/jni/android_os_Parcel.cpp
index 584ebaa221fc..dec724b6a7ff 100644
--- a/core/jni/android_os_Parcel.cpp
+++ b/core/jni/android_os_Parcel.cpp
@@ -90,7 +90,7 @@ void recycleJavaParcelObject(JNIEnv* env, jobject parcelObj)
env->CallVoidMethod(parcelObj, gParcelOffsets.recycle);
}
-static void android_os_Parcel_markSensitive(jlong nativePtr)
+static void android_os_Parcel_markSensitive(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel) {
@@ -116,30 +116,30 @@ static void android_os_Parcel_markForBinder(JNIEnv* env, jclass clazz, jlong nat
}
}
-static jboolean android_os_Parcel_isForRpc(jlong nativePtr) {
+static jboolean android_os_Parcel_isForRpc(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr) {
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return parcel ? parcel->isForRpc() : false;
}
-static jint android_os_Parcel_dataSize(jlong nativePtr)
+static jint android_os_Parcel_dataSize(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return parcel ? parcel->dataSize() : 0;
}
-static jint android_os_Parcel_dataAvail(jlong nativePtr)
+static jint android_os_Parcel_dataAvail(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return parcel ? parcel->dataAvail() : 0;
}
-static jint android_os_Parcel_dataPosition(jlong nativePtr)
+static jint android_os_Parcel_dataPosition(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return parcel ? parcel->dataPosition() : 0;
}
-static jint android_os_Parcel_dataCapacity(jlong nativePtr)
+static jint android_os_Parcel_dataCapacity(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return parcel ? parcel->dataCapacity() : 0;
@@ -156,7 +156,7 @@ static void android_os_Parcel_setDataSize(JNIEnv* env, jclass clazz, jlong nativ
}
}
-static void android_os_Parcel_setDataPosition(jlong nativePtr, jint pos)
+static void android_os_Parcel_setDataPosition(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr, jint pos)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -175,7 +175,8 @@ static void android_os_Parcel_setDataCapacity(JNIEnv* env, jclass clazz, jlong n
}
}
-static jboolean android_os_Parcel_pushAllowFds(jlong nativePtr, jboolean allowFds)
+static jboolean android_os_Parcel_pushAllowFds(CRITICAL_JNI_PARAMS_COMMA
+ jlong nativePtr, jboolean allowFds)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
jboolean ret = JNI_TRUE;
@@ -185,7 +186,8 @@ static jboolean android_os_Parcel_pushAllowFds(jlong nativePtr, jboolean allowFd
return ret;
}
-static void android_os_Parcel_restoreAllowFds(jlong nativePtr, jboolean lastValue)
+static void android_os_Parcel_restoreAllowFds(CRITICAL_JNI_PARAMS_COMMA
+ jlong nativePtr, jboolean lastValue)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -259,22 +261,22 @@ static void android_os_Parcel_writeBlob(JNIEnv* env, jclass clazz, jlong nativeP
blob.release();
}
-static int android_os_Parcel_writeInt(jlong nativePtr, jint val) {
+static int android_os_Parcel_writeInt(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr, jint val) {
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return (parcel != NULL) ? parcel->writeInt32(val) : OK;
}
-static int android_os_Parcel_writeLong(jlong nativePtr, jlong val) {
+static int android_os_Parcel_writeLong(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr, jlong val) {
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return (parcel != NULL) ? parcel->writeInt64(val) : OK;
}
-static int android_os_Parcel_writeFloat(jlong nativePtr, jfloat val) {
+static int android_os_Parcel_writeFloat(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr, jfloat val) {
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return (parcel != NULL) ? parcel->writeFloat(val) : OK;
}
-static int android_os_Parcel_writeDouble(jlong nativePtr, jdouble val) {
+static int android_os_Parcel_writeDouble(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr, jdouble val) {
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
return (parcel != NULL) ? parcel->writeDouble(val) : OK;
}
@@ -446,7 +448,7 @@ static jbyteArray android_os_Parcel_readBlob(JNIEnv* env, jclass clazz, jlong na
return ret;
}
-static jint android_os_Parcel_readInt(jlong nativePtr)
+static jint android_os_Parcel_readInt(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -455,7 +457,7 @@ static jint android_os_Parcel_readInt(jlong nativePtr)
return 0;
}
-static jlong android_os_Parcel_readLong(jlong nativePtr)
+static jlong android_os_Parcel_readLong(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -464,7 +466,7 @@ static jlong android_os_Parcel_readLong(jlong nativePtr)
return 0;
}
-static jfloat android_os_Parcel_readFloat(jlong nativePtr)
+static jfloat android_os_Parcel_readFloat(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -473,7 +475,7 @@ static jfloat android_os_Parcel_readFloat(jlong nativePtr)
return 0;
}
-static jdouble android_os_Parcel_readDouble(jlong nativePtr)
+static jdouble android_os_Parcel_readDouble(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -690,7 +692,7 @@ static jboolean android_os_Parcel_hasBindersInRange(JNIEnv* env, jclass clazz, j
return JNI_FALSE;
}
-static jboolean android_os_Parcel_hasFileDescriptors(jlong nativePtr)
+static jboolean android_os_Parcel_hasFileDescriptors(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
jboolean ret = JNI_FALSE;
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
@@ -807,7 +809,7 @@ static jlong android_os_Parcel_getGlobalAllocCount(JNIEnv* env, jclass clazz)
return Parcel::getGlobalAllocCount();
}
-static jlong android_os_Parcel_getOpenAshmemSize(jlong nativePtr)
+static jlong android_os_Parcel_getOpenAshmemSize(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -816,7 +818,7 @@ static jlong android_os_Parcel_getOpenAshmemSize(jlong nativePtr)
return 0;
}
-static jint android_os_Parcel_readCallingWorkSourceUid(jlong nativePtr)
+static jint android_os_Parcel_readCallingWorkSourceUid(CRITICAL_JNI_PARAMS_COMMA jlong nativePtr)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
@@ -825,7 +827,8 @@ static jint android_os_Parcel_readCallingWorkSourceUid(jlong nativePtr)
return IPCThreadState::kUnsetWorkSource;
}
-static jboolean android_os_Parcel_replaceCallingWorkSourceUid(jlong nativePtr, jint uid)
+static jboolean android_os_Parcel_replaceCallingWorkSourceUid(CRITICAL_JNI_PARAMS_COMMA
+ jlong nativePtr, jint uid)
{
Parcel* parcel = reinterpret_cast<Parcel*>(nativePtr);
if (parcel != NULL) {
diff --git a/core/jni/android_util_Binder.cpp b/core/jni/android_util_Binder.cpp
index 921b77d61f4d..f2c70b5f41d4 100644
--- a/core/jni/android_util_Binder.cpp
+++ b/core/jni/android_util_Binder.cpp
@@ -1152,60 +1152,60 @@ void signalExceptionForError(JNIEnv* env, jobject obj, status_t err,
// ----------------------------------------------------------------------------
-static jint android_os_Binder_getCallingPid()
+static jint android_os_Binder_getCallingPid(CRITICAL_JNI_PARAMS)
{
return IPCThreadState::self()->getCallingPid();
}
-static jint android_os_Binder_getCallingUid()
+static jint android_os_Binder_getCallingUid(CRITICAL_JNI_PARAMS)
{
return IPCThreadState::self()->getCallingUid();
}
-static jboolean android_os_Binder_isDirectlyHandlingTransactionNative() {
+static jboolean android_os_Binder_isDirectlyHandlingTransactionNative(CRITICAL_JNI_PARAMS) {
return getCurrentServingCall() == BinderCallType::BINDER;
}
-static jlong android_os_Binder_clearCallingIdentity()
+static jlong android_os_Binder_clearCallingIdentity(CRITICAL_JNI_PARAMS)
{
return IPCThreadState::self()->clearCallingIdentity();
}
-static void android_os_Binder_restoreCallingIdentity(jlong token)
+static void android_os_Binder_restoreCallingIdentity(CRITICAL_JNI_PARAMS_COMMA jlong token)
{
IPCThreadState::self()->restoreCallingIdentity(token);
}
-static jboolean android_os_Binder_hasExplicitIdentity() {
+static jboolean android_os_Binder_hasExplicitIdentity(CRITICAL_JNI_PARAMS) {
return IPCThreadState::self()->hasExplicitIdentity();
}
-static void android_os_Binder_setThreadStrictModePolicy(jint policyMask)
+static void android_os_Binder_setThreadStrictModePolicy(CRITICAL_JNI_PARAMS_COMMA jint policyMask)
{
IPCThreadState::self()->setStrictModePolicy(policyMask);
}
-static jint android_os_Binder_getThreadStrictModePolicy()
+static jint android_os_Binder_getThreadStrictModePolicy(CRITICAL_JNI_PARAMS)
{
return IPCThreadState::self()->getStrictModePolicy();
}
-static jlong android_os_Binder_setCallingWorkSourceUid(jint workSource)
+static jlong android_os_Binder_setCallingWorkSourceUid(CRITICAL_JNI_PARAMS_COMMA jint workSource)
{
return IPCThreadState::self()->setCallingWorkSourceUid(workSource);
}
-static jlong android_os_Binder_getCallingWorkSourceUid()
+static jlong android_os_Binder_getCallingWorkSourceUid(CRITICAL_JNI_PARAMS)
{
return IPCThreadState::self()->getCallingWorkSourceUid();
}
-static jlong android_os_Binder_clearCallingWorkSource()
+static jlong android_os_Binder_clearCallingWorkSource(CRITICAL_JNI_PARAMS)
{
return IPCThreadState::self()->clearCallingWorkSource();
}
-static void android_os_Binder_restoreCallingWorkSource(jlong token)
+static void android_os_Binder_restoreCallingWorkSource(CRITICAL_JNI_PARAMS_COMMA jlong token)
{
IPCThreadState::self()->restoreCallingWorkSource(token);
}
diff --git a/core/res/res/values-et-rEE/config.xml b/core/res/res/values-et-rEE/config.xml
new file mode 100644
index 000000000000..cf4d07f2ead0
--- /dev/null
+++ b/core/res/res/values-et-rEE/config.xml
@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+** Copyright 2024, 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.
+*/
+-->
+<resources>
+ <bool name="config_use_sim_language_file">false</bool>
+</resources>
diff --git a/core/res/res/values-watch/config.xml b/core/res/res/values-watch/config.xml
index 52662149b23a..e28b6462bad7 100644
--- a/core/res/res/values-watch/config.xml
+++ b/core/res/res/values-watch/config.xml
@@ -96,4 +96,8 @@
<!-- True if the device supports system decorations on secondary displays. -->
<bool name="config_supportsSystemDecorsOnSecondaryDisplays">false</bool>
+
+ <!-- Whether to enable scaling and fading animation to scrollviews while scrolling.
+ P.S this is a change only intended for wear devices. -->
+ <bool name="config_enableViewGroupScalingFading">true</bool>
</resources>
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 38aff7590a42..f6267f6174b6 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -7121,4 +7121,8 @@
<!-- The maximum number of call log entries for each sim card that can be stored in the call log
provider on the device. -->
<integer name="config_maximumCallLogEntriesPerSim">500</integer>
+
+ <!-- Whether to enable scaling and fading animation to scrollviews while scrolling.
+ P.S this is a change only intended for wear devices. -->
+ <bool name="config_enableViewGroupScalingFading">false</bool>
</resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 606c7fdaa954..d63421057939 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -5509,6 +5509,9 @@
<!-- Message shown in the dialog prompting the user to set up a screen lock to access private space [CHAR LIMIT=120] -->
<string name="private_space_set_up_screen_lock_message">To use your private space, set a screen lock on this device</string>
+ <!-- Message shown in the dialog prompting the user to set up a screen lock to delete private space from Reset Options [CHAR LIMIT=120] -->
+ <string name="private_space_set_up_screen_lock_for_reset">To delete private space, set a screen lock on this device</string>
+
<!-- Title of the dialog that is shown when the user tries to launch a blocked application [CHAR LIMIT=50] -->
<string name="app_blocked_title">App is not available</string>
<!-- Default message shown in the dialog that is shown when the user tries to launch a blocked application [CHAR LIMIT=NONE] -->
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 46938948b133..bd8077e71c5a 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -3299,6 +3299,8 @@
<java-symbol type="string" name="set_up_screen_lock_action_label" />
<!-- Message for the alert dialog prompting the user to set up a screen lock to access private space -->
<java-symbol type="string" name="private_space_set_up_screen_lock_message" />
+ <!-- Message shown in the dialog prompting the user to set up a screen lock to delete private space from Reset Options [CHAR LIMIT=120] -->
+ <java-symbol type="string" name="private_space_set_up_screen_lock_for_reset" />
<java-symbol type="string" name="deprecated_target_sdk_message" />
<java-symbol type="string" name="deprecated_target_sdk_app_store" />
@@ -5601,4 +5603,6 @@
<!-- Fingerprint loe notification string -->
<java-symbol type="string" name="fingerprint_loe_notification_msg" />
+
+ <java-symbol type="bool" name="config_enableViewGroupScalingFading"/>
</resources>
diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/RadioServiceUserControllerTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/RadioServiceUserControllerTest.java
index 516253b0ebff..44beb55b77db 100644
--- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/RadioServiceUserControllerTest.java
+++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/RadioServiceUserControllerTest.java
@@ -19,18 +19,18 @@ package com.android.server.broadcastradio;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doThrow;
-import static com.google.common.truth.Truth.assertWithMessage;
-
import static org.mockito.Mockito.when;
import android.app.ActivityManager;
-import android.app.compat.CompatChanges;
import android.os.Binder;
import android.os.UserHandle;
import com.android.dx.mockito.inline.extended.StaticMockitoSessionBuilder;
+import com.google.common.truth.Expect;
+
import org.junit.Before;
+import org.junit.Rule;
import org.junit.Test;
import org.mockito.Mock;
@@ -41,36 +41,40 @@ public final class RadioServiceUserControllerTest extends ExtendedRadioMockitoTe
private static final int USER_ID_1 = 11;
private static final int USER_ID_2 = 12;
+ private RadioServiceUserController mUserController;
@Mock
private UserHandle mUserHandleMock;
+ @Rule
+ public final Expect expect = Expect.create();
+
@Override
protected void initializeSession(StaticMockitoSessionBuilder builder) {
- builder.spyStatic(ActivityManager.class).spyStatic(Binder.class)
- .spyStatic(CompatChanges.class);
+ builder.spyStatic(ActivityManager.class).spyStatic(Binder.class);
}
@Before
public void setUp() {
doReturn(mUserHandleMock).when(() -> Binder.getCallingUserHandle());
doReturn(USER_ID_1).when(() -> ActivityManager.getCurrentUser());
+ mUserController = new RadioServiceUserControllerImpl();
}
@Test
public void isCurrentOrSystemUser_forCurrentUser_returnsFalse() {
when(mUserHandleMock.getIdentifier()).thenReturn(USER_ID_1);
- assertWithMessage("Current user")
- .that(RadioServiceUserController.isCurrentOrSystemUser()).isTrue();
+ expect.withMessage("Current user")
+ .that(mUserController.isCurrentOrSystemUser()).isTrue();
}
@Test
public void isCurrentOrSystemUser_forNonCurrentUser_returnsFalse() {
when(mUserHandleMock.getIdentifier()).thenReturn(USER_ID_2);
- assertWithMessage("Non-current user")
- .that(RadioServiceUserController.isCurrentOrSystemUser()).isFalse();
+ expect.withMessage("Non-current user")
+ .that(mUserController.isCurrentOrSystemUser()).isFalse();
}
@Test
@@ -78,8 +82,8 @@ public final class RadioServiceUserControllerTest extends ExtendedRadioMockitoTe
when(mUserHandleMock.getIdentifier()).thenReturn(USER_ID_1);
when(mUserHandleMock.getIdentifier()).thenReturn(UserHandle.USER_SYSTEM);
- assertWithMessage("System user")
- .that(RadioServiceUserController.isCurrentOrSystemUser()).isTrue();
+ expect.withMessage("System user")
+ .that(mUserController.isCurrentOrSystemUser()).isTrue();
}
@Test
@@ -87,14 +91,14 @@ public final class RadioServiceUserControllerTest extends ExtendedRadioMockitoTe
when(mUserHandleMock.getIdentifier()).thenReturn(USER_ID_1);
doThrow(new RuntimeException()).when(ActivityManager::getCurrentUser);
- assertWithMessage("User when activity manager fails")
- .that(RadioServiceUserController.isCurrentOrSystemUser()).isFalse();
+ expect.withMessage("User when activity manager fails")
+ .that(mUserController.isCurrentOrSystemUser()).isFalse();
}
@Test
public void getCurrentUser() {
- assertWithMessage("Current user")
- .that(RadioServiceUserController.getCurrentUser()).isEqualTo(USER_ID_1);
+ expect.withMessage("Current user")
+ .that(mUserController.getCurrentUser()).isEqualTo(USER_ID_1);
}
@Test
@@ -102,7 +106,15 @@ public final class RadioServiceUserControllerTest extends ExtendedRadioMockitoTe
when(mUserHandleMock.getIdentifier()).thenReturn(USER_ID_1);
doThrow(new RuntimeException()).when(ActivityManager::getCurrentUser);
- assertWithMessage("Current user when activity manager fails")
- .that(RadioServiceUserController.getCurrentUser()).isEqualTo(UserHandle.USER_NULL);
+ expect.withMessage("Current user when activity manager fails")
+ .that(mUserController.getCurrentUser()).isEqualTo(UserHandle.USER_NULL);
+ }
+
+ @Test
+ public void getCallingUserId() {
+ when(mUserHandleMock.getIdentifier()).thenReturn(USER_ID_1);
+
+ expect.withMessage("Calling user id")
+ .that(mUserController.getCallingUserId()).isEqualTo(USER_ID_1);
}
}
diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImplTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImplTest.java
index 22f3bd4abe11..63f12d82b48a 100644
--- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImplTest.java
+++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImplTest.java
@@ -91,12 +91,13 @@ public final class BroadcastRadioServiceImplTest extends ExtendedRadioMockitoTes
private IAnnouncementListener mAnnouncementListenerMock;
@Mock
private IBinder mListenerBinderMock;
+ @Mock
+ private RadioServiceUserController mUserControllerMock;
@Override
protected void initializeSession(StaticMockitoSessionBuilder builder) {
builder.spyStatic(ServiceManager.class)
- .spyStatic(RadioModule.class)
- .spyStatic(RadioServiceUserController.class);
+ .spyStatic(RadioModule.class);
}
@Test
@@ -156,7 +157,7 @@ public final class BroadcastRadioServiceImplTest extends ExtendedRadioMockitoTes
@Test
public void openSession_forNonCurrentUser_throwsException() throws Exception {
createBroadcastRadioService();
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
IllegalStateException thrown = assertThrows(IllegalStateException.class,
() -> mBroadcastRadioService.openSession(FM_RADIO_MODULE_ID,
@@ -206,9 +207,9 @@ public final class BroadcastRadioServiceImplTest extends ExtendedRadioMockitoTes
}
private void createBroadcastRadioService() throws RemoteException {
- doReturn(true).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(true).when(mUserControllerMock).isCurrentOrSystemUser();
mockServiceManager();
- mBroadcastRadioService = new BroadcastRadioServiceImpl(SERVICE_LIST);
+ mBroadcastRadioService = new BroadcastRadioServiceImpl(SERVICE_LIST, mUserControllerMock);
}
private void mockServiceManager() throws RemoteException {
@@ -222,9 +223,9 @@ public final class BroadcastRadioServiceImplTest extends ExtendedRadioMockitoTes
any(IServiceCallback.class)));
doReturn(mFmRadioModuleMock).when(() -> RadioModule.tryLoadingModule(
- eq(FM_RADIO_MODULE_ID), anyString(), any(IBinder.class)));
+ eq(FM_RADIO_MODULE_ID), anyString(), any(IBinder.class), any()));
doReturn(mDabRadioModuleMock).when(() -> RadioModule.tryLoadingModule(
- eq(DAB_RADIO_MODULE_ID), anyString(), any(IBinder.class)));
+ eq(DAB_RADIO_MODULE_ID), anyString(), any(IBinder.class), any()));
when(mFmRadioModuleMock.getProperties()).thenReturn(mFmModuleMock);
when(mDabRadioModuleMock.getProperties()).thenReturn(mDabModuleMock);
diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/RadioModuleTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/RadioModuleTest.java
index a952bde956d8..368df090070b 100644
--- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/RadioModuleTest.java
+++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/RadioModuleTest.java
@@ -34,6 +34,8 @@ import android.hardware.radio.RadioManager;
import android.os.ParcelableException;
import android.os.RemoteException;
+import com.android.server.broadcastradio.RadioServiceUserController;
+
import com.google.common.truth.Expect;
import org.junit.Before;
@@ -63,6 +65,8 @@ public final class RadioModuleTest {
private IAnnouncementListener mListenerMock;
@Mock
private android.hardware.broadcastradio.ICloseHandle mHalCloseHandleMock;
+ @Mock
+ private RadioServiceUserController mUserControllerMock;
// RadioModule under test
private RadioModule mRadioModule;
@@ -70,7 +74,8 @@ public final class RadioModuleTest {
@Before
public void setup() throws RemoteException {
- mRadioModule = new RadioModule(mBroadcastRadioMock, TEST_MODULE_PROPERTIES);
+ mRadioModule = new RadioModule(mBroadcastRadioMock, TEST_MODULE_PROPERTIES,
+ mUserControllerMock);
// TODO(b/241118988): test non-null image for getImage method
when(mBroadcastRadioMock.getImage(anyInt())).thenReturn(null);
diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/TunerSessionTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/TunerSessionTest.java
index 92dfe38c31fe..24d18e0893d0 100644
--- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/TunerSessionTest.java
+++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/aidl/TunerSessionTest.java
@@ -49,12 +49,10 @@ import android.hardware.radio.ProgramSelector;
import android.hardware.radio.RadioManager;
import android.hardware.radio.RadioTuner;
import android.hardware.radio.UniqueProgramIdentifier;
-import android.os.Binder;
import android.os.DeadObjectException;
import android.os.ParcelableException;
import android.os.RemoteException;
import android.os.ServiceSpecificException;
-import android.os.UserHandle;
import android.platform.test.flag.junit.SetFlagsRule;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -148,10 +146,10 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
// Mocks
@Mock
- private UserHandle mUserHandleMock;
- @Mock
private IBroadcastRadio mBroadcastRadioMock;
private android.hardware.radio.ITunerCallback[] mAidlTunerCallbackMocks;
+ @Mock
+ private RadioServiceUserController mUserControllerMock;
// RadioModule under test
private RadioModule mRadioModule;
@@ -170,8 +168,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
@Override
protected void initializeSession(StaticMockitoSessionBuilder builder) {
- builder.spyStatic(RadioServiceUserController.class).spyStatic(CompatChanges.class)
- .spyStatic(Binder.class);
+ builder.spyStatic(CompatChanges.class);
}
@Before
@@ -182,13 +179,12 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
doReturn(true).when(() -> CompatChanges.isChangeEnabled(
eq(ConversionUtils.RADIO_U_VERSION_REQUIRED), anyInt()));
- doReturn(USER_ID_1).when(mUserHandleMock).getIdentifier();
- doReturn(mUserHandleMock).when(() -> Binder.getCallingUserHandle());
- doReturn(true).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
- doReturn(USER_ID_1).when(() -> RadioServiceUserController.getCurrentUser());
+ doReturn(USER_ID_1).when(mUserControllerMock).getCallingUserId();
+ doReturn(true).when(mUserControllerMock).isCurrentOrSystemUser();
+ doReturn(USER_ID_1).when(mUserControllerMock).getCurrentUser();
mRadioModule = new RadioModule(mBroadcastRadioMock,
- AidlTestUtils.makeDefaultModuleProperties());
+ AidlTestUtils.makeDefaultModuleProperties(), mUserControllerMock);
doAnswer(invocation -> {
mHalTunerCallback = (ITunerCallback) invocation.getArguments()[0];
@@ -237,7 +233,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
@Test
public void setConfiguration_forNonCurrentUser_doesNotInvokesCallback() throws Exception {
openAidlClients(/* numClients= */ 1);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].setConfiguration(FM_BAND_CONFIG);
@@ -434,7 +430,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
@Test
public void tune_forNonCurrentUser_doesNotTune() throws Exception {
openAidlClients(/* numClients= */ 1);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
ProgramSelector initialSel = AidlTestUtils.makeFmSelector(AM_FM_FREQUENCY_LIST[1]);
RadioManager.ProgramInfo tuneInfo =
AidlTestUtils.makeProgramInfo(initialSel, SIGNAL_QUALITY);
@@ -514,7 +510,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
openAidlClients(/* numClients= */ 1);
mHalCurrentInfo = AidlTestUtils.makeHalProgramInfo(
ConversionUtils.programSelectorToHalProgramSelector(initialSel), SIGNAL_QUALITY);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].step(/* directionDown= */ true, /* skipSubChannel= */ false);
@@ -593,7 +589,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
openAidlClients(/* numClients= */ 1);
mHalCurrentInfo = AidlTestUtils.makeHalProgramInfo(
ConversionUtils.programSelectorToHalProgramSelector(initialSel), SIGNAL_QUALITY);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].seek(/* directionDown= */ true, /* skipSubChannel= */ false);
@@ -627,7 +623,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
@Test
public void cancel_forNonCurrentUser_doesNotCancel() throws Exception {
openAidlClients(/* numClients= */ 1);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].cancel();
@@ -698,7 +694,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
@Test
public void startBackgroundScan_forNonCurrentUser_doesNotInvokesCallback() throws Exception {
openAidlClients(/* numClients= */ 1);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].startBackgroundScan();
@@ -968,7 +964,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
openAidlClients(/* numClients= */ 1);
ProgramList.Filter filter = new ProgramList.Filter(new ArraySet<>(), new ArraySet<>(),
/* includeCategories= */ true, /* excludeModifications= */ false);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].startProgramListUpdates(filter);
@@ -1007,7 +1003,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
ProgramList.Filter filter = new ProgramList.Filter(new ArraySet<>(), new ArraySet<>(),
/* includeCategories= */ true, /* excludeModifications= */ false);
mTunerSessions[0].startProgramListUpdates(filter);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].stopProgramListUpdates();
@@ -1073,7 +1069,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
public void setConfigFlag_forNonCurrentUser_doesNotSetConfigFlag() throws Exception {
openAidlClients(/* numClients= */ 1);
int flag = UNSUPPORTED_CONFIG_FLAG + 1;
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].setConfigFlag(flag, /* value= */ true);
@@ -1138,7 +1134,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
openAidlClients(/* numClients= */ 1);
Map<String, String> parametersSet = Map.of("mockParam1", "mockValue1",
"mockParam2", "mockValue2");
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].setParameters(parametersSet);
@@ -1192,7 +1188,7 @@ public final class TunerSessionTest extends ExtendedRadioMockitoTestCase {
public void onCurrentProgramInfoChanged_withNonCurrentUser_doesNotInvokeCallback()
throws Exception {
openAidlClients(1);
- doReturn(USER_ID_2).when(() -> RadioServiceUserController.getCurrentUser());
+ doReturn(USER_ID_2).when(mUserControllerMock).getCurrentUser();
mHalTunerCallback.onCurrentProgramInfoChanged(AidlTestUtils.makeHalProgramInfo(
AidlTestUtils.makeHalFmSelector(AM_FM_FREQUENCY_LIST[1]), SIGNAL_QUALITY));
diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/BroadcastRadioServiceHidlTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/BroadcastRadioServiceHidlTest.java
index acf698bce33d..7c3f221f9bf5 100644
--- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/BroadcastRadioServiceHidlTest.java
+++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/BroadcastRadioServiceHidlTest.java
@@ -88,11 +88,12 @@ public final class BroadcastRadioServiceHidlTest extends ExtendedRadioMockitoTes
private IAnnouncementListener mAnnouncementListenerMock;
@Mock
private IBinder mBinderMock;
+ @Mock
+ private RadioServiceUserController mUserControllerMock;
@Override
protected void initializeSession(StaticMockitoSessionBuilder builder) {
- builder.spyStatic(RadioModule.class)
- .spyStatic(RadioServiceUserController.class);
+ builder.spyStatic(RadioModule.class);
}
@Test
@@ -156,7 +157,7 @@ public final class BroadcastRadioServiceHidlTest extends ExtendedRadioMockitoTes
@Test
public void openSession_forNonCurrentUser_throwsException() throws Exception {
createBroadcastRadioService();
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ when(mUserControllerMock.isCurrentOrSystemUser()).thenReturn(false);
IllegalStateException thrown = assertThrows(IllegalStateException.class,
() -> mBroadcastRadioService.openSession(FM_RADIO_MODULE_ID,
@@ -206,11 +207,11 @@ public final class BroadcastRadioServiceHidlTest extends ExtendedRadioMockitoTes
}
private void createBroadcastRadioService() throws RemoteException {
- doReturn(true).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ when(mUserControllerMock.isCurrentOrSystemUser()).thenReturn(true);
mockServiceManager();
mBroadcastRadioService = new BroadcastRadioService(/* nextModuleId= */ FM_RADIO_MODULE_ID,
- mServiceManagerMock);
+ mServiceManagerMock, mUserControllerMock);
}
private void mockServiceManager() throws RemoteException {
@@ -231,9 +232,9 @@ public final class BroadcastRadioServiceHidlTest extends ExtendedRadioMockitoTes
}).thenReturn(true);
doReturn(mFmRadioModuleMock).when(() -> RadioModule.tryLoadingModule(
- eq(FM_RADIO_MODULE_ID), anyString()));
+ eq(FM_RADIO_MODULE_ID), anyString(), any()));
doReturn(mDabRadioModuleMock).when(() -> RadioModule.tryLoadingModule(
- eq(DAB_RADIO_MODULE_ID), anyString()));
+ eq(DAB_RADIO_MODULE_ID), anyString(), any()));
when(mFmRadioModuleMock.getProperties()).thenReturn(mFmModuleMock);
when(mDabRadioModuleMock.getProperties()).thenReturn(mDabModuleMock);
diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/RadioModuleHidlTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/RadioModuleHidlTest.java
index 1f5e77038728..b53f7ca879aa 100644
--- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/RadioModuleHidlTest.java
+++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/RadioModuleHidlTest.java
@@ -36,6 +36,8 @@ import android.hardware.radio.ICloseHandle;
import android.hardware.radio.RadioManager;
import android.os.RemoteException;
+import com.android.server.broadcastradio.RadioServiceUserController;
+
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -61,13 +63,16 @@ public final class RadioModuleHidlTest {
private IAnnouncementListener mListenerMock;
@Mock
private android.hardware.broadcastradio.V2_0.ICloseHandle mHalCloseHandleMock;
+ @Mock
+ private RadioServiceUserController mUserControllerMock;
private RadioModule mRadioModule;
private android.hardware.broadcastradio.V2_0.IAnnouncementListener mHalListener;
@Before
public void setup() throws RemoteException {
- mRadioModule = new RadioModule(mBroadcastRadioMock, TEST_MODULE_PROPERTIES);
+ mRadioModule = new RadioModule(mBroadcastRadioMock, TEST_MODULE_PROPERTIES,
+ mUserControllerMock);
when(mBroadcastRadioMock.getImage(anyInt())).thenReturn(new ArrayList<Byte>(0));
diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/StartProgramListUpdatesFanoutTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/StartProgramListUpdatesFanoutTest.java
index 8c16d79133ce..fa0744775f6d 100644
--- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/StartProgramListUpdatesFanoutTest.java
+++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/StartProgramListUpdatesFanoutTest.java
@@ -38,13 +38,13 @@ import android.hardware.radio.RadioManager;
import android.hardware.radio.UniqueProgramIdentifier;
import android.os.RemoteException;
-import com.android.dx.mockito.inline.extended.StaticMockitoSessionBuilder;
-import com.android.server.broadcastradio.ExtendedRadioMockitoTestCase;
import com.android.server.broadcastradio.RadioServiceUserController;
import org.junit.Before;
import org.junit.Test;
+import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnitRunner;
import org.mockito.stubbing.Answer;
import org.mockito.verification.VerificationWithTimeout;
@@ -55,7 +55,8 @@ import java.util.List;
/**
* Tests for v2 HAL RadioModule.
*/
-public class StartProgramListUpdatesFanoutTest extends ExtendedRadioMockitoTestCase {
+@RunWith(MockitoJUnitRunner.class)
+public class StartProgramListUpdatesFanoutTest {
private static final String TAG = "BroadcastRadioTests.hal2.StartProgramListUpdatesFanout";
private static final VerificationWithTimeout CB_TIMEOUT = timeout(500);
@@ -64,6 +65,8 @@ public class StartProgramListUpdatesFanoutTest extends ExtendedRadioMockitoTestC
@Mock IBroadcastRadio mBroadcastRadioMock;
@Mock ITunerSession mHalTunerSessionMock;
private android.hardware.radio.ITunerCallback[] mAidlTunerCallbackMocks;
+ @Mock
+ private RadioServiceUserController mUserControllerMock;
// RadioModule under test
private RadioModule mRadioModule;
@@ -110,17 +113,12 @@ public class StartProgramListUpdatesFanoutTest extends ExtendedRadioMockitoTestC
private static final RadioManager.ProgramInfo TEST_DAB_INFO = TestUtils.makeProgramInfo(
TEST_DAB_SELECTOR, TEST_QUALITY);
- @Override
- protected void initializeSession(StaticMockitoSessionBuilder builder) {
- builder.spyStatic(RadioServiceUserController.class);
- }
-
@Before
public void setup() throws RemoteException {
- doReturn(true).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(true).when(mUserControllerMock).isCurrentOrSystemUser();
- mRadioModule = new RadioModule(mBroadcastRadioMock,
- TestUtils.makeDefaultModuleProperties());
+ mRadioModule = new RadioModule(mBroadcastRadioMock, TestUtils.makeDefaultModuleProperties(),
+ mUserControllerMock);
doAnswer((Answer) invocation -> {
mHalTunerCallback = (ITunerCallback) invocation.getArguments()[0];
diff --git a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/TunerSessionHidlTest.java b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/TunerSessionHidlTest.java
index 55aae9d3396a..62445cf90028 100644
--- a/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/TunerSessionHidlTest.java
+++ b/core/tests/BroadcastRadioTests/src/com/android/server/broadcastradio/hal2/TunerSessionHidlTest.java
@@ -44,16 +44,12 @@ import android.hardware.radio.ProgramList;
import android.hardware.radio.ProgramSelector;
import android.hardware.radio.RadioManager;
import android.hardware.radio.RadioTuner;
-import android.os.Binder;
import android.os.DeadObjectException;
import android.os.ParcelableException;
import android.os.RemoteException;
-import android.os.UserHandle;
import android.util.ArrayMap;
import android.util.ArraySet;
-import com.android.dx.mockito.inline.extended.StaticMockitoSessionBuilder;
-import com.android.server.broadcastradio.ExtendedRadioMockitoTestCase;
import com.android.server.broadcastradio.RadioServiceUserController;
import com.google.common.truth.Expect;
@@ -76,7 +72,7 @@ import java.util.Map;
* Tests for HIDL HAL TunerSession.
*/
@RunWith(MockitoJUnitRunner.class)
-public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
+public final class TunerSessionHidlTest {
private static final int USER_ID_1 = 11;
private static final int USER_ID_2 = 12;
@@ -104,27 +100,21 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
public final Expect mExpect = Expect.create();
@Mock
- private UserHandle mUserHandleMock;
- @Mock
private IBroadcastRadio mBroadcastRadioMock;
@Mock
ITunerSession mHalTunerSessionMock;
private android.hardware.radio.ITunerCallback[] mAidlTunerCallbackMocks;
-
- @Override
- protected void initializeSession(StaticMockitoSessionBuilder builder) {
- builder.spyStatic(RadioServiceUserController.class).spyStatic(Binder.class);
- }
+ @Mock
+ private RadioServiceUserController mUserControllerMock;
@Before
public void setup() throws Exception {
- doReturn(USER_ID_1).when(mUserHandleMock).getIdentifier();
- doReturn(mUserHandleMock).when(() -> Binder.getCallingUserHandle());
- doReturn(true).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
- doReturn(USER_ID_1).when(() -> RadioServiceUserController.getCurrentUser());
+ doReturn(USER_ID_1).when(mUserControllerMock).getCallingUserId();
+ doReturn(true).when(mUserControllerMock).isCurrentOrSystemUser();
+ doReturn(USER_ID_1).when(mUserControllerMock).getCurrentUser();
mRadioModule = new RadioModule(mBroadcastRadioMock,
- TestUtils.makeDefaultModuleProperties());
+ TestUtils.makeDefaultModuleProperties(), mUserControllerMock);
doAnswer(invocation -> {
mHalTunerCallback = (ITunerCallback) invocation.getArguments()[0];
@@ -228,7 +218,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
@Test
public void setConfiguration_forNonCurrentUser_doesNotInvokesCallback() throws Exception {
openAidlClients(/* numClients= */ 1);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].setConfiguration(FM_BAND_CONFIG);
@@ -403,7 +393,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
@Test
public void tune_forNonCurrentUser_doesNotTune() throws Exception {
openAidlClients(/* numClients= */ 1);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
ProgramSelector initialSel = TestUtils.makeFmSelector(AM_FM_FREQUENCY_LIST[1]);
RadioManager.ProgramInfo tuneInfo =
TestUtils.makeProgramInfo(initialSel, SIGNAL_QUALITY);
@@ -481,7 +471,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
openAidlClients(/* numClients= */ 1);
mHalCurrentInfo = TestUtils.makeHalProgramInfo(
Convert.programSelectorToHal(initialSel), SIGNAL_QUALITY);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].step(/* directionDown= */ true, /* skipSubChannel= */ false);
@@ -559,7 +549,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
openAidlClients(/* numClients= */ 1);
mHalCurrentInfo = TestUtils.makeHalProgramInfo(
Convert.programSelectorToHal(initialSel), SIGNAL_QUALITY);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].seek(/* directionDown= */ true, /* skipSubChannel= */ false);
@@ -593,7 +583,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
@Test
public void cancel_forNonCurrentUser_doesNotCancel() throws Exception {
openAidlClients(/* numClients= */ 1);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].cancel();
@@ -663,7 +653,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
@Test
public void startBackgroundScan_forNonCurrentUser_doesNotInvokesCallback() throws Exception {
openAidlClients(/* numClients= */ 1);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].startBackgroundScan();
@@ -676,7 +666,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
openAidlClients(/* numClients= */ 1);
ProgramList.Filter filter = new ProgramList.Filter(new ArraySet<>(), new ArraySet<>(),
/* includeCategories= */ true, /* excludeModifications= */ false);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].startProgramListUpdates(filter);
@@ -715,7 +705,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
ProgramList.Filter aidlFilter = new ProgramList.Filter(new ArraySet<>(), new ArraySet<>(),
/* includeCategories= */ true, /* excludeModifications= */ false);
mTunerSessions[0].startProgramListUpdates(aidlFilter);
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].stopProgramListUpdates();
@@ -781,7 +771,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
public void setConfigFlag_forNonCurrentUser_doesNotSetConfigFlag() throws Exception {
openAidlClients(/* numClients= */ 1);
int flag = UNSUPPORTED_CONFIG_FLAG + 1;
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].setConfigFlag(flag, /* value= */ true);
@@ -846,7 +836,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
openAidlClients(/* numClients= */ 1);
Map<String, String> parametersSet = Map.of("mockParam1", "mockValue1",
"mockParam2", "mockValue2");
- doReturn(false).when(() -> RadioServiceUserController.isCurrentOrSystemUser());
+ doReturn(false).when(mUserControllerMock).isCurrentOrSystemUser();
mTunerSessions[0].setParameters(parametersSet);
@@ -900,7 +890,7 @@ public final class TunerSessionHidlTest extends ExtendedRadioMockitoTestCase {
public void onCurrentProgramInfoChanged_withNonCurrentUser_doesNotInvokeCallback()
throws Exception {
openAidlClients(1);
- doReturn(USER_ID_2).when(() -> RadioServiceUserController.getCurrentUser());
+ doReturn(USER_ID_2).when(mUserControllerMock).getCurrentUser();
mHalTunerCallback.onCurrentProgramInfoChanged(TestUtils.makeHalProgramInfo(
TestUtils.makeHalFmSelector(/* freq= */ 97300), SIGNAL_QUALITY));
diff --git a/core/tests/coretests/Android.bp b/core/tests/coretests/Android.bp
index 99cbf0504be6..41599aea1a80 100644
--- a/core/tests/coretests/Android.bp
+++ b/core/tests/coretests/Android.bp
@@ -299,11 +299,6 @@ android_ravenwood_test {
auto_gen_config: true,
}
-FLAKY_OR_IGNORED = [
- "androidx.test.filters.FlakyTest",
- "org.junit.Ignore",
-]
-
test_module_config {
name: "FrameworksCoreTests_Presubmit",
base: "FrameworksCoreTests",
@@ -312,7 +307,6 @@ test_module_config {
"device-platinum-tests",
],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -337,7 +331,6 @@ test_module_config {
"device-platinum-tests",
],
include_filters: ["android.content.ContextTest"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -348,7 +341,6 @@ test_module_config {
"device-platinum-tests",
],
include_filters: ["android.app.KeyguardManagerTest"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -359,7 +351,6 @@ test_module_config {
"device-platinum-tests",
],
include_filters: ["android.app.PropertyInvalidatedCacheTests"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -374,7 +365,6 @@ test_module_config {
"android.content.ComponentCallbacksControllerTest",
"android.content.ContextWrapperTest",
],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -385,7 +375,6 @@ test_module_config {
"device-platinum-tests",
],
include_filters: ["android.database.sqlite.SQLiteRawStatementTest"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -397,7 +386,6 @@ test_module_config {
],
include_filters: ["android.net"],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -510,7 +498,6 @@ test_module_config {
"device-platinum-tests",
],
include_filters: ["com.android.internal.jank"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -569,7 +556,6 @@ test_module_config {
"device-platinum-tests",
],
include_filters: ["com.android.internal.util.LatencyTrackerTest"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -580,7 +566,6 @@ test_module_config {
"device-platinum-tests",
],
include_filters: ["android.content.ContentCaptureOptionsTest"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -602,7 +587,6 @@ test_module_config {
],
include_filters: ["android.content.pm."],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -614,7 +598,6 @@ test_module_config {
],
include_filters: ["android.content.pm."],
include_annotations: ["android.platform.test.annotations.Postsubmit"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -642,7 +625,6 @@ test_module_config {
],
include_filters: ["android.content.res."],
include_annotations: ["android.platform.test.annotations.Postsubmit"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -672,7 +654,6 @@ test_module_config {
"device-platinum-tests",
],
include_filters: ["android.view.contentcapture"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -683,7 +664,6 @@ test_module_config {
"device-platinum-tests",
],
include_filters: ["android.view.contentprotection"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -695,7 +675,6 @@ test_module_config {
],
include_filters: ["com.android.internal.content."],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -709,21 +688,6 @@ test_module_config {
}
test_module_config {
- name: "FrameworksCoreTests_accessibility_NO_FLAKES",
- base: "FrameworksCoreTests",
- test_suites: [
- "device-tests",
- "device-platinum-tests",
- ],
- include_filters: [
- "com.android.internal.accessibility",
- "android.accessibilityservice",
- "android.view.accessibility",
- ],
- exclude_annotations: ["androidx.test.filters.FlakyTest"],
-}
-
-test_module_config {
name: "FrameworksCoreTests_accessibility",
base: "FrameworksCoreTests",
test_suites: [
@@ -792,7 +756,6 @@ test_module_config {
"com.android.internal.jank.InteractionJankMonitorTest",
"com.android.internal.util.LatencyTrackerTest",
],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
@@ -803,7 +766,6 @@ test_module_config {
"device-platinum-tests",
],
include_annotations: ["android.platform.test.annotations.PlatinumTest"],
- exclude_annotations: FLAKY_OR_IGNORED,
}
test_module_config {
diff --git a/core/tests/coretests/src/android/app/NotificationChannelTest.java b/core/tests/coretests/src/android/app/NotificationChannelTest.java
index e47ef2df48b9..e19f887c1284 100644
--- a/core/tests/coretests/src/android/app/NotificationChannelTest.java
+++ b/core/tests/coretests/src/android/app/NotificationChannelTest.java
@@ -47,12 +47,13 @@ import android.os.RemoteException;
import android.os.VibrationEffect;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;
+import android.platform.test.annotations.UsesFlags;
+import android.platform.test.flag.junit.FlagsParameterization;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.MediaStore.Audio.AudioColumns;
import android.test.mock.MockContentResolver;
import android.util.Xml;
-import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import com.android.modules.utils.TypedXmlPullParser;
@@ -61,6 +62,7 @@ import com.android.modules.utils.TypedXmlSerializer;
import com.google.common.base.Strings;
import org.junit.Before;
+import org.junit.ClassRule;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
@@ -71,14 +73,28 @@ import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.lang.reflect.Field;
import java.util.Arrays;
+import java.util.List;
import java.util.function.Consumer;
-@RunWith(AndroidJUnit4.class)
+import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
+import platform.test.runner.parameterized.Parameters;
+
+@RunWith(ParameterizedAndroidJunit4.class)
+@UsesFlags(android.app.Flags.class)
@SmallTest
@Presubmit
public class NotificationChannelTest {
+ @ClassRule
+ public static final SetFlagsRule.ClassRule mSetFlagsClassRule = new SetFlagsRule.ClassRule();
+
+ @Parameters(name = "{0}")
+ public static List<FlagsParameterization> getParams() {
+ return FlagsParameterization.allCombinationsOf(
+ Flags.FLAG_NOTIF_CHANNEL_CROP_VIBRATION_EFFECTS);
+ }
+
@Rule
- public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+ public final SetFlagsRule mSetFlagsRule;
private final String CLASS = "android.app.NotificationChannel";
@@ -86,6 +102,10 @@ public class NotificationChannelTest {
ContentProvider mContentProvider;
IContentProvider mIContentProvider;
+ public NotificationChannelTest(FlagsParameterization flags) {
+ mSetFlagsRule = mSetFlagsClassRule.createSetFlagsRule(flags);
+ }
+
@Before
public void setUp() throws Exception {
mContext = mock(Context.class);
diff --git a/core/tests/coretests/src/android/content/pm/LauncherActivityInfoTest.java b/core/tests/coretests/src/android/content/pm/LauncherActivityInfoTest.java
index e19c4b15d300..3616ff5cc144 100644
--- a/core/tests/coretests/src/android/content/pm/LauncherActivityInfoTest.java
+++ b/core/tests/coretests/src/android/content/pm/LauncherActivityInfoTest.java
@@ -33,71 +33,169 @@ import org.junit.runner.RunWith;
public class LauncherActivityInfoTest {
@Test
- public void testTrimStart() {
- // Invisible case
- assertThat(LauncherActivityInfo.trimStart("\u0009").toString()).isEmpty();
- // It is not supported in the system font
- assertThat(LauncherActivityInfo.trimStart("\u0FE1").toString()).isEmpty();
- // Surrogates case
- assertThat(LauncherActivityInfo.trimStart("\uD83E\uDD36").toString())
- .isEqualTo("\uD83E\uDD36");
- assertThat(LauncherActivityInfo.trimStart("\u0009\u0FE1\uD83E\uDD36A").toString())
- .isEqualTo("\uD83E\uDD36A");
- assertThat(LauncherActivityInfo.trimStart("\uD83E\uDD36A\u0009\u0FE1").toString())
- .isEqualTo("\uD83E\uDD36A\u0009\u0FE1");
- assertThat(LauncherActivityInfo.trimStart("A\uD83E\uDD36\u0009\u0FE1A").toString())
- .isEqualTo("A\uD83E\uDD36\u0009\u0FE1A");
- assertThat(LauncherActivityInfo.trimStart(
- "A\uD83E\uDD36\u0009\u0FE1A\uD83E\uDD36").toString())
- .isEqualTo("A\uD83E\uDD36\u0009\u0FE1A\uD83E\uDD36");
- assertThat(LauncherActivityInfo.trimStart(
- "\u0009\u0FE1\uD83E\uDD36A\u0009\u0FE1").toString())
- .isEqualTo("\uD83E\uDD36A\u0009\u0FE1");
+ public void testIsVisible_normal() {
+ // normal
+ assertThat(LauncherActivityInfo.isVisible("label")).isTrue();
+ // 1 surrogates case
+ assertThat(LauncherActivityInfo.isVisible("\uD83E\uDD36")).isTrue();
}
@Test
- public void testTrimEnd() {
- // Invisible case
- assertThat(LauncherActivityInfo.trimEnd("\u0009").toString()).isEmpty();
- // It is not supported in the system font
- assertThat(LauncherActivityInfo.trimEnd("\u0FE1").toString()).isEmpty();
- // Surrogates case
- assertThat(LauncherActivityInfo.trimEnd("\uD83E\uDD36").toString())
- .isEqualTo("\uD83E\uDD36");
- assertThat(LauncherActivityInfo.trimEnd("\u0009\u0FE1\uD83E\uDD36A").toString())
- .isEqualTo("\u0009\u0FE1\uD83E\uDD36A");
- assertThat(LauncherActivityInfo.trimEnd("\uD83E\uDD36A\u0009\u0FE1").toString())
- .isEqualTo("\uD83E\uDD36A");
- assertThat(LauncherActivityInfo.trimEnd("A\uD83E\uDD36\u0009\u0FE1A").toString())
- .isEqualTo("A\uD83E\uDD36\u0009\u0FE1A");
- assertThat(LauncherActivityInfo.trimEnd(
- "A\uD83E\uDD36\u0009\u0FE1A\uD83E\uDD36").toString())
- .isEqualTo("A\uD83E\uDD36\u0009\u0FE1A\uD83E\uDD36");
- assertThat(LauncherActivityInfo.trimEnd(
- "\u0009\u0FE1\uD83E\uDD36A\u0009\u0FE1").toString())
- .isEqualTo("\u0009\u0FE1\uD83E\uDD36A");
+ public void testIsVisible_onlyInvisibleCharacter() {
+ // 1 invisible
+ assertThat(LauncherActivityInfo.isVisible("\u0009")).isFalse();
+ // 2 invisible
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u3164")).isFalse();
+ // 3 invisible
+ assertThat(LauncherActivityInfo.isVisible("\u3000\u0009\u3164")).isFalse();
+ // 4 invisible
+ assertThat(LauncherActivityInfo.isVisible("\u200F\u3000\u0009\u3164")).isFalse();
}
@Test
- public void testTrim() {
- // Invisible case
- assertThat(LauncherActivityInfo.trim("\u0009").toString()).isEmpty();
- // It is not supported in the system font
- assertThat(LauncherActivityInfo.trim("\u0FE1").toString()).isEmpty();
- // Surrogates case
- assertThat(LauncherActivityInfo.trim("\uD83E\uDD36").toString())
- .isEqualTo("\uD83E\uDD36");
- assertThat(LauncherActivityInfo.trim("\u0009\u0FE1\uD83E\uDD36A").toString())
- .isEqualTo("\uD83E\uDD36A");
- assertThat(LauncherActivityInfo.trim("\uD83E\uDD36A\u0009\u0FE1").toString())
- .isEqualTo("\uD83E\uDD36A");
- assertThat(LauncherActivityInfo.trim("A\uD83E\uDD36\u0009\u0FE1A").toString())
- .isEqualTo("A\uD83E\uDD36\u0009\u0FE1A");
- assertThat(LauncherActivityInfo.trim(
- "A\uD83E\uDD36\u0009\u0FE1A\uD83E\uDD36").toString())
- .isEqualTo("A\uD83E\uDD36\u0009\u0FE1A\uD83E\uDD36");
- assertThat(LauncherActivityInfo.trim(
- "\u0009\u0FE1\uD83E\uDD36A\u0009\u0FE1").toString())
- .isEqualTo("\uD83E\uDD36A");
+ public void testIsVisible_onlyNotSupportedCharacter() {
+ // 1 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1")).isFalse();
+ // 2 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u0FE2")).isFalse();
+ // 3 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u0FE2\u0FE3")).isFalse();
+ // 4 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u0FE2\u0FE3\u0FE4")).isFalse();
+ }
+
+ @Test
+ public void testIsVisible_invisibleAndNotSupportedCharacter() {
+ // 1 invisible, 1 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u0FE1")).isFalse();
+ // 1 invisible, 2 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u0FE1\u0FE2")).isFalse();
+ // 1 invisible, 3 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u0FE1\u0FE2\u0FE3")).isFalse();
+ // 1 invisible, 4 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u0FE1\u0FE2\u0FE3\u0FE4")).isFalse();
+
+ // 2 invisible, 1 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u3164\u0FE1")).isFalse();
+ // 2 invisible, 2 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u3164\u0FE1\u0FE2")).isFalse();
+ // 2 invisible, 3 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u3164\u0FE1\u0FE2\u0FE3")).isFalse();
+ // 2 invisible, 4 not supported
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u0009\u3164\u0FE1\u0FE2\u0FE3\u0FE4")).isFalse();
+
+ // 3 invisible, 1 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u3000\u0009\u3164\u0FE1")).isFalse();
+ // 3 invisible, 2 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u3000\u0009\u3164\u0FE1\u0FE2")).isFalse();
+ // 3 invisible, 3 not supported
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u3000\u0009\u3164\u0FE1\u0FE2\u0FE3")).isFalse();
+ // 3 invisible, 4 not supported
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u3000\u0009\u3164\u0FE1\u0FE2\u0FE3\u0FE4")).isFalse();
+
+ // 4 invisible, 1 not supported
+ assertThat(LauncherActivityInfo.isVisible("\u200F\u3000\u0009\u3164\u0FE1")).isFalse();
+ // 4 invisible, 2 not supported
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u200F\u3000\u0009\u3164\u0FE1\u0FE2")).isFalse();
+ // 4 invisible, 3 not supported
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u200F\u3000\u0009\u3164\u0FE1\u0FE2\u0FE3")).isFalse();
+ // 4 invisible, 4 not supported
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u200F\u3000\u0009\u3164\u0FE1\u0FE2\u0FE3\u0FE4")).isFalse();
+
+ // 1 not supported, 1 invisible,
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u0009")).isFalse();
+ // 1 not supported, 2 invisible
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u0009\u3164")).isFalse();
+ // 1 not supported, 3 invisible
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u3000\u0009\u3164")).isFalse();
+ // 1 not supported, 4 invisible
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u200F\u3000\u0009\u3164")).isFalse();
+ }
+
+ @Test
+ public void testIsVisible_invisibleAndNormalCharacter() {
+ // 1 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u0009\uD83E\uDD36")).isTrue();
+ // 2 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u3164\uD83E\uDD36")).isTrue();
+ // 3 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u3000\u0009\u3164\uD83E\uDD36")).isFalse();
+ // 4 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u200F\u3000\u0009\u3164\uD83E\uDD36")).isFalse();
+ }
+
+ @Test
+ public void testIsVisible_notSupportedAndNormalCharacter() {
+ // 1 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\uD83E\uDD36")).isTrue();
+ // 2 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u0FE2\uD83E\uDD36")).isTrue();
+ // 3 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u0FE2\u0FE3\uD83E\uDD36")).isTrue();
+ // 4 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u0FE1\u0FE2\u0FE3\u0FE4\uD83E\uDD36")).isTrue();
+ }
+
+ @Test
+ public void testIsVisible_mixAllCharacter() {
+ // 1 invisible, 1 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u0FE1\uD83E\uDD36")).isTrue();
+ // 1 invisible, 1 not supported, 1 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u0FE1\u3164\uD83E\uDD36")).isTrue();
+ // 1 invisible, 1 not supported, 2 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u0009\u0FE1\u3000\u3164\uD83E\uDD36")).isTrue();
+ // 1 invisible, 1 not supported, 3 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u0009\u0FE1\u200F\u3000\u3164\uD83E\uDD36")).isTrue();
+
+ // 2 invisible, 1 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u0009\u3164\u0FE1\uD83E\uDD36")).isTrue();
+ // 2 invisible, 2 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u0009\u3164\u0FE1\u0FE2\uD83E\uDD36")).isTrue();
+
+ // 3 invisible, 1 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u3000\u0009\u3164\u0FE1\uD83E\uDD36")).isFalse();
+ // 3 invisible, 2 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u3000\u0009\u3164\u0FE1\u0FE2\uD83E\uDD36")).isFalse();
+ // 3 invisible, 3 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u3000\u0009\u3164\u0FE1\u0FE2\u0FE3\uD83E\uDD36")).isFalse();
+
+ // 4 invisible, 1 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u200F\u3000\u0009\u3164\u0FE1\uD83E\uDD36")).isFalse();
+ // 4 invisible, 2 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u200F\u3000\u0009\u3164\u0FE1\u0FE2\uD83E\uDD36")).isFalse();
+ // 4 invisible, 3 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u200F\u3000\u0009\u3164\u0FE1\u0FE2\u0FE3\uD83E\uDD36")).isFalse();
+ // 4 invisible, 4 not supported, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u200F\u3000\u0009\u3164\u0FE1\u0FE2\u0FE3\u0FE4\uD83E\uDD36")).isFalse();
+
+ // 1 not supported, 1 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u0009\uD83E\uDD36")).isTrue();
+ // 1 not supported, 2 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible("\u0FE1\u0009\u3164\uD83E\uDD36")).isTrue();
+ // 1 not supported, 3 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u0FE1\u3000\u0009\u3164\uD83E\uDD36")).isTrue();
+ // 1 not supported, 4 invisible, 1 surrogates
+ assertThat(LauncherActivityInfo.isVisible(
+ "\u0FE1\u200F\u3000\u0009\u3164\uD83E\uDD36")).isTrue();
+
}
}
diff --git a/core/tests/coretests/src/android/database/sqlite/SQLiteDatabaseTest.java b/core/tests/coretests/src/android/database/sqlite/SQLiteDatabaseTest.java
index 519f23b0deb6..00978a099f13 100644
--- a/core/tests/coretests/src/android/database/sqlite/SQLiteDatabaseTest.java
+++ b/core/tests/coretests/src/android/database/sqlite/SQLiteDatabaseTest.java
@@ -538,4 +538,58 @@ public class SQLiteDatabaseTest {
assertEquals(1, db.mConnection.size());
}
+
+ // Create and open the database, allowing or disallowing double-quoted strings.
+ private void createDatabase(boolean noDoubleQuotedStrs) throws Exception {
+ // The open-flags that do not change in this test.
+ int flags = SQLiteDatabase.CREATE_IF_NECESSARY | SQLiteDatabase.OPEN_READWRITE;
+
+ // The flag to be tested.
+ int flagUnderTest = SQLiteDatabase.NO_DOUBLE_QUOTED_STRS;
+
+ if (noDoubleQuotedStrs) {
+ flags |= flagUnderTest;
+ } else {
+ flags &= ~flagUnderTest;
+ }
+ mDatabase = SQLiteDatabase.openDatabase(mDatabaseFile.getPath(), null, flags, null);
+ }
+
+ /**
+ * This test verifies that the NO_DOUBLE_QUOTED_STRS flag works as expected when opening a
+ * database. This does not test that the flag is initialized as expected from the system
+ * properties.
+ */
+ @Test
+ public void testNoDoubleQuotedStrings() throws Exception {
+ closeAndDeleteDatabase();
+ createDatabase(/* noDoubleQuotedStrs */ false);
+
+ mDatabase.beginTransaction();
+ try {
+ mDatabase.execSQL("CREATE TABLE t1 (t text);");
+ // Insert a value in double-quotes. This is invalid but accepted.
+ mDatabase.execSQL("INSERT INTO t1 (t) VALUES (\"foo\")");
+ } finally {
+ mDatabase.endTransaction();
+ }
+
+ closeAndDeleteDatabase();
+ createDatabase(/* noDoubleQuotedStrs */ true);
+
+ mDatabase.beginTransaction();
+ try {
+ mDatabase.execSQL("CREATE TABLE t1 (t text);");
+ try {
+ // Insert a value in double-quotes. This is invalid and must throw.
+ mDatabase.execSQL("INSERT INTO t1 (t) VALUES (\"foo\")");
+ fail("expected an exception");
+ } catch (SQLiteException e) {
+ assertTrue(e.toString().contains("no such column"));
+ }
+ } finally {
+ mDatabase.endTransaction();
+ }
+ closeAndDeleteDatabase();
+ }
}
diff --git a/core/tests/coretests/src/android/os/BinderTest.java b/core/tests/coretests/src/android/os/BinderTest.java
index 9767d677807d..90ec93e46418 100644
--- a/core/tests/coretests/src/android/os/BinderTest.java
+++ b/core/tests/coretests/src/android/os/BinderTest.java
@@ -24,18 +24,16 @@ import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.testng.Assert.assertThrows;
-import android.platform.test.annotations.IgnoreUnderRavenwood;
+import android.platform.test.annotations.DisabledOnRavenwood;
import android.platform.test.ravenwood.RavenwoodRule;
import androidx.test.filters.SmallTest;
import com.android.internal.os.BinderInternal;
-
import org.junit.Rule;
import org.junit.Test;
-@IgnoreUnderRavenwood(blockedBy = WorkSource.class)
public class BinderTest {
private static final int UID = 100;
@@ -89,6 +87,7 @@ public class BinderTest {
@SmallTest
@Test(expected = java.lang.SecurityException.class)
+ @DisabledOnRavenwood(blockedBy = ServiceManagerNative.class)
public void testServiceManagerNativeSecurityException() throws RemoteException {
// Find the service manager
IServiceManager sServiceManager = ServiceManagerNative
@@ -101,6 +100,7 @@ public class BinderTest {
@SmallTest
@Test(expected = java.lang.NullPointerException.class)
+ @DisabledOnRavenwood(blockedBy = ServiceManagerNative.class)
public void testServiceManagerNativeNullptrException() throws RemoteException {
// Find the service manager
IServiceManager sServiceManager = ServiceManagerNative
diff --git a/core/tests/coretests/src/android/os/BundleTest.java b/core/tests/coretests/src/android/os/BundleTest.java
index ded6fc5de2e5..31e07524d777 100644
--- a/core/tests/coretests/src/android/os/BundleTest.java
+++ b/core/tests/coretests/src/android/os/BundleTest.java
@@ -25,7 +25,6 @@ import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
import android.platform.test.annotations.DisabledOnRavenwood;
-import android.platform.test.annotations.IgnoreUnderRavenwood;
import android.platform.test.annotations.Presubmit;
import android.platform.test.ravenwood.RavenwoodRule;
import android.util.Log;
@@ -131,7 +130,6 @@ public class BundleTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = ParcelFileDescriptor.class)
public void testCreateFromParcel() throws Exception {
boolean withFd;
Parcel p;
@@ -312,7 +310,7 @@ public class BundleTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
+ @DisabledOnRavenwood(reason = "Ravenwood tests run on the BCP")
public void kindofEquals_lazyValuesAndDifferentClassLoaders_returnsFalse() {
Parcelable p1 = new CustomParcelable(13, "Tiramisu");
Parcelable p2 = new CustomParcelable(13, "Tiramisu");
@@ -368,7 +366,6 @@ public class BundleTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void readWriteLengthMismatch_logsWtf() throws Exception {
mWtfHandler = Log.setWtfHandler((tag, e, system) -> {
throw new RuntimeException(e);
@@ -383,7 +380,7 @@ public class BundleTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
+ @DisabledOnRavenwood(reason = "Ravenwood tests run on the BCP")
public void getParcelable_whenThrowingAndNotDefusing_throws() throws Exception {
Bundle.setShouldDefuse(false);
Bundle bundle = new Bundle();
@@ -396,7 +393,7 @@ public class BundleTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
+ @DisabledOnRavenwood(reason = "Ravenwood tests run on the BCP")
public void getParcelable_whenThrowingAndDefusing_returnsNull() throws Exception {
Bundle.setShouldDefuse(true);
Bundle bundle = new Bundle();
@@ -412,7 +409,7 @@ public class BundleTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
+ @DisabledOnRavenwood(reason = "Ravenwood tests run on the BCP")
public void getParcelable_whenThrowingAndDefusing_leavesElement() throws Exception {
Bundle.setShouldDefuse(true);
Bundle bundle = new Bundle();
@@ -447,7 +444,6 @@ public class BundleTest {
}
@Test
- @DisabledOnRavenwood(blockedBy = Parcel.class)
public void parcelledBundleWithBinder_shouldReturnHasBindersTrue() throws Exception {
Bundle bundle = new Bundle();
bundle.putParcelable("test", new CustomParcelable(13, "Tiramisu"));
@@ -470,7 +466,6 @@ public class BundleTest {
}
@Test
- @DisabledOnRavenwood(blockedBy = Parcel.class)
public void parcelledBundleWithoutBinder_shouldReturnHasBindersFalse() throws Exception {
Bundle bundle = new Bundle();
bundle.putParcelable("test", new CustomParcelable(13, "Tiramisu"));
diff --git a/core/tests/coretests/src/android/os/ParcelNullabilityTest.java b/core/tests/coretests/src/android/os/ParcelNullabilityTest.java
index 09395f15a57b..96316c436d61 100644
--- a/core/tests/coretests/src/android/os/ParcelNullabilityTest.java
+++ b/core/tests/coretests/src/android/os/ParcelNullabilityTest.java
@@ -20,7 +20,7 @@ import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import android.platform.test.annotations.IgnoreUnderRavenwood;
+import android.platform.test.annotations.DisabledOnRavenwood;
import android.platform.test.ravenwood.RavenwoodRule;
import android.util.ArrayMap;
@@ -67,7 +67,7 @@ public final class ParcelNullabilityTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
+ @DisabledOnRavenwood(blockedBy = android.text.Spanned.class)
public void nullCharSequence() {
Parcel p = Parcel.obtain();
p.writeCharSequence(null);
@@ -76,7 +76,6 @@ public final class ParcelNullabilityTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void nullStrongBinder() {
Parcel p = Parcel.obtain();
p.writeStrongBinder(null);
@@ -85,7 +84,6 @@ public final class ParcelNullabilityTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void nullStringInterface() {
Parcel p = Parcel.obtain();
p.writeStrongInterface(null);
diff --git a/core/tests/coretests/src/android/os/ParcelTest.java b/core/tests/coretests/src/android/os/ParcelTest.java
index 037323111e9f..da9d687ee2b0 100644
--- a/core/tests/coretests/src/android/os/ParcelTest.java
+++ b/core/tests/coretests/src/android/os/ParcelTest.java
@@ -23,7 +23,6 @@ import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertThrows;
import static org.junit.Assert.assertTrue;
-import android.platform.test.annotations.IgnoreUnderRavenwood;
import android.platform.test.annotations.Presubmit;
import android.platform.test.ravenwood.RavenwoodRule;
import android.util.Log;
@@ -48,7 +47,6 @@ public class ParcelTest {
private static final String INTERFACE_TOKEN_2 = "Another IBinder interface token";
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void testIsForRpc() {
Parcel p = Parcel.obtain();
assertEquals(false, p.isForRpc());
@@ -56,7 +54,6 @@ public class ParcelTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void testCallingWorkSourceUidAfterWrite() {
Parcel p = Parcel.obtain();
// Method does not throw if replaceCallingWorkSourceUid is called before requests headers
@@ -77,7 +74,6 @@ public class ParcelTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void testCallingWorkSourceUidAfterEnforce() {
Parcel p = Parcel.obtain();
p.writeInterfaceToken(INTERFACE_TOKEN_1);
@@ -95,7 +91,6 @@ public class ParcelTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void testParcelWithMultipleHeaders() {
Parcel p = Parcel.obtain();
Binder.setCallingWorkSourceUid(WORK_SOURCE_1);
@@ -153,7 +148,6 @@ public class ParcelTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void testCompareDataInRange_whenSameDataWithBinder() {
Binder binder = new Binder();
Parcel pA = Parcel.obtain();
@@ -313,7 +307,6 @@ public class ParcelTest {
* and 1M length for complex objects are allowed.
*/
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void testAllocations_whenWithinLimit() {
Binder.setIsDirectlyHandlingTransactionOverride(true);
Parcel p = Parcel.obtain();
@@ -398,7 +391,6 @@ public class ParcelTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void testHasBinders_AfterWritingBinderToParcel() {
Binder binder = new Binder();
Parcel pA = Parcel.obtain();
@@ -410,7 +402,6 @@ public class ParcelTest {
}
@Test
- @IgnoreUnderRavenwood(blockedBy = Parcel.class)
public void testHasBindersInRange_AfterWritingBinderToParcel() {
Binder binder = new Binder();
Parcel pA = Parcel.obtain();
diff --git a/core/tests/coretests/src/android/text/TextLineLetterSpacingTest.kt b/core/tests/coretests/src/android/text/TextLineLetterSpacingTest.kt
index 71980c125f01..e4e04a028588 100644
--- a/core/tests/coretests/src/android/text/TextLineLetterSpacingTest.kt
+++ b/core/tests/coretests/src/android/text/TextLineLetterSpacingTest.kt
@@ -17,11 +17,9 @@
package android.text
import android.graphics.Paint
-import android.platform.test.annotations.RequiresFlagsEnabled
import android.platform.test.flag.junit.DeviceFlagsValueProvider
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
-import com.android.text.flags.Flags.FLAG_LETTER_SPACING_JUSTIFICATION
import com.google.common.truth.Truth.assertThat
import org.junit.Rule
import org.junit.Test
@@ -40,7 +38,6 @@ class TextLineLetterSpacingTest {
@JvmField
val mCheckFlagsRule = DeviceFlagsValueProvider.createCheckFlagsRule()
- @RequiresFlagsEnabled(FLAG_LETTER_SPACING_JUSTIFICATION)
@Test
fun calculateRunFlagTest() {
// Only one Bidi run
@@ -84,7 +81,6 @@ class TextLineLetterSpacingTest {
.isEqualTo(LEFT_EDGE)
}
- @RequiresFlagsEnabled(FLAG_LETTER_SPACING_JUSTIFICATION)
@Test
fun resolveRunFlagForSubSequenceTest() {
val runStart = 5
diff --git a/core/tests/coretests/src/com/android/internal/widget/ViewGroupFaderTest.java b/core/tests/coretests/src/com/android/internal/widget/ViewGroupFaderTest.java
new file mode 100644
index 000000000000..eeabc2f4e0ed
--- /dev/null
+++ b/core/tests/coretests/src/com/android/internal/widget/ViewGroupFaderTest.java
@@ -0,0 +1,107 @@
+/*
+ * Copyright (C) 2024 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.internal.widget;
+
+import static androidx.test.platform.app.InstrumentationRegistry.getInstrumentation;
+
+import android.content.Context;
+import android.content.res.Resources;
+import android.platform.test.annotations.EnableFlags;
+import android.platform.test.flag.junit.SetFlagsRule;
+import android.test.AndroidTestCase;
+import android.view.View;
+import android.view.ViewGroup;
+import android.widget.flags.Flags;
+
+import org.mockito.Mock;
+import org.mockito.MockitoAnnotations;
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.spy;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * Tests for {@link ViewGroupFader}.
+ */
+public class ViewGroupFaderTest extends AndroidTestCase {
+
+ private Context mContext;
+ private ViewGroupFader mViewGroupFader;
+ private Resources mResources;
+
+ @Mock
+ private ViewGroup mViewGroup,mViewGroup1;
+
+ @Mock
+ private ViewGroupFader mockViewGroupFader;
+
+ @Mock
+ private ViewGroupFader.AnimationCallback mAnimationCallback;
+
+ @Mock
+ private ViewGroupFader.ChildViewBoundsProvider mChildViewBoundsProvider;
+
+ @Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule();
+
+ @Before
+ public void setUp() throws Exception {
+ MockitoAnnotations.initMocks(this);
+ final Context mContext = getInstrumentation().getContext();
+ mResources = spy(mContext.getResources());
+ when(mResources.getBoolean(com.android.internal.R.bool.config_enableViewGroupScalingFading))
+ .thenReturn(true);
+ when(mViewGroup.getResources()).thenReturn(mResources);
+
+ mViewGroupFader = new ViewGroupFader(
+ mViewGroup,
+ mAnimationCallback,
+ mChildViewBoundsProvider);
+ }
+
+ /** This test checks that for each child of the parent viewgroup,
+ * updateListElementFades is called for each of its child, when the Flag is set to true
+ */
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_FADING_VIEW_GROUP)
+ public void testFadingAndScrollingAnimationWorking_FlagOn() {
+ mViewGroup.addView(mViewGroup1);
+ mViewGroupFader.updateFade();
+
+ for (int i = 0; i < mViewGroup.getChildCount(); i++) {
+ View child = mViewGroup.getChildAt(i);
+ verify(mockViewGroupFader).updateListElementFades((ViewGroup)child,true);
+ }
+ }
+
+ /** This test checks that for each child of the parent viewgroup,
+ * updateListElementFades is never called for each of its child, when the Flag is set to false
+ */
+ @Test
+ public void testFadingAndScrollingAnimationNotWorking_FlagOff() {
+ mViewGroup.addView(mViewGroup1);
+ mViewGroupFader.updateFade();
+
+ for (int i = 0; i < mViewGroup.getChildCount(); i++) {
+ View child = mViewGroup.getChildAt(i);
+ verify(mockViewGroupFader,never()).updateListElementFades((ViewGroup)child,true);
+ }
+ }
+} \ No newline at end of file
diff --git a/core/tests/vibrator/src/android/os/VibratorInfoTest.java b/core/tests/vibrator/src/android/os/VibratorInfoTest.java
index 73cd4647415d..c81081075859 100644
--- a/core/tests/vibrator/src/android/os/VibratorInfoTest.java
+++ b/core/tests/vibrator/src/android/os/VibratorInfoTest.java
@@ -139,6 +139,35 @@ public class VibratorInfoTest {
}
@Test
+ public void testAreEnvelopeEffectsSupported() {
+ VibratorInfo noCapabilities = new VibratorInfo.Builder(TEST_VIBRATOR_ID).build();
+ assertFalse(noCapabilities.areEnvelopeEffectsSupported());
+ VibratorInfo envelopeEffectCapability = new VibratorInfo.Builder(TEST_VIBRATOR_ID)
+ .setCapabilities(IVibrator.CAP_COMPOSE_PWLE_EFFECTS_V2)
+ .build();
+ assertTrue(envelopeEffectCapability.areEnvelopeEffectsSupported());
+ }
+
+ @Test
+ public void testEnvelopeEffectLimits() {
+ VibratorInfo info = new VibratorInfo.Builder(TEST_VIBRATOR_ID)
+ .setMaxEnvelopeEffectSize(16)
+ .setMinEnvelopeEffectControlPointDurationMillis(20)
+ .setMaxEnvelopeEffectControlPointDurationMillis(1_000)
+ .build();
+ assertEquals(16, info.getMaxEnvelopeEffectSize());
+ assertEquals(20, info.getMinEnvelopeEffectControlPointDurationMillis());
+ assertEquals(1_000, info.getMaxEnvelopeEffectControlPointDurationMillis());
+ assertEquals(16_000, info.getMaxEnvelopeEffectDurationMillis());
+
+ VibratorInfo emptyInfo = new VibratorInfo.Builder(TEST_VIBRATOR_ID).build();
+ assertEquals(0, emptyInfo.getMaxEnvelopeEffectSize());
+ assertEquals(0, emptyInfo.getMinEnvelopeEffectControlPointDurationMillis());
+ assertEquals(0, emptyInfo.getMaxEnvelopeEffectControlPointDurationMillis());
+ assertEquals(0, emptyInfo.getMaxEnvelopeEffectDurationMillis());
+ }
+
+ @Test
public void testGetDefaultBraking_returnsFirstSupportedBraking() {
assertEquals(Braking.NONE, new VibratorInfo.Builder(
TEST_VIBRATOR_ID).build().getDefaultBraking());
@@ -262,17 +291,20 @@ public class VibratorInfoTest {
VibratorInfo.Builder completeBuilder2 = new VibratorInfo.Builder(TEST_VIBRATOR_ID + 2);
for (VibratorInfo.Builder builder :
- new VibratorInfo.Builder[] {completeBuilder, completeBuilder2}) {
+ new VibratorInfo.Builder[]{completeBuilder, completeBuilder2}) {
builder.setCapabilities(IVibrator.CAP_AMPLITUDE_CONTROL)
- .setSupportedEffects(VibrationEffect.EFFECT_CLICK)
- .setSupportedPrimitive(VibrationEffect.Composition.PRIMITIVE_CLICK, 20)
- .setPrimitiveDelayMax(100)
- .setCompositionSizeMax(10)
- .setSupportedBraking(Braking.CLAB)
- .setPwlePrimitiveDurationMax(50)
- .setPwleSizeMax(20)
- .setQFactor(2f)
- .setFrequencyProfile(TEST_FREQUENCY_PROFILE);
+ .setSupportedEffects(VibrationEffect.EFFECT_CLICK)
+ .setSupportedPrimitive(VibrationEffect.Composition.PRIMITIVE_CLICK, 20)
+ .setPrimitiveDelayMax(100)
+ .setCompositionSizeMax(10)
+ .setSupportedBraking(Braking.CLAB)
+ .setPwlePrimitiveDurationMax(50)
+ .setPwleSizeMax(20)
+ .setQFactor(2f)
+ .setFrequencyProfile(TEST_FREQUENCY_PROFILE)
+ .setMaxEnvelopeEffectSize(16)
+ .setMinEnvelopeEffectControlPointDurationMillis(20)
+ .setMaxEnvelopeEffectControlPointDurationMillis(1_000);
}
VibratorInfo complete = completeBuilder.build();
diff --git a/core/tests/vibrator/src/android/os/vibrator/VibrationConfigTest.java b/core/tests/vibrator/src/android/os/vibrator/VibrationConfigTest.java
new file mode 100644
index 000000000000..a2ff9d77674a
--- /dev/null
+++ b/core/tests/vibrator/src/android/os/vibrator/VibrationConfigTest.java
@@ -0,0 +1,100 @@
+/*
+ * Copyright (C) 2024 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 android.os.vibrator;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.Mockito.when;
+
+import android.content.res.Resources;
+
+import com.android.internal.R;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+
+import java.util.HashMap;
+import java.util.Map;
+
+public class VibrationConfigTest {
+
+ @Rule
+ public MockitoRule rule = MockitoJUnit.rule();
+
+ @Mock
+ private Resources mResourcesMock;
+
+ private final Map<String, String> mSystemProperties = new HashMap<>();
+
+ @Test
+ public void getDefaultVibrationAmplitude_returnsConfiguredAmplitude() {
+ when(mResourcesMock.getInteger(R.integer.config_defaultVibrationAmplitude)).thenReturn(1);
+ assertThat(createConfig().getDefaultVibrationAmplitude()).isEqualTo(1);
+
+ when(mResourcesMock.getInteger(R.integer.config_defaultVibrationAmplitude)).thenReturn(123);
+ assertThat(createConfig().getDefaultVibrationAmplitude()).isEqualTo(123);
+
+ when(mResourcesMock.getInteger(R.integer.config_defaultVibrationAmplitude)).thenReturn(255);
+ assertThat(createConfig().getDefaultVibrationAmplitude()).isEqualTo(255);
+ }
+
+ @Test
+ public void getDefaultVibrationAmplitude_invalidValue_returnsMaxAmplitude() {
+ when(mResourcesMock.getInteger(R.integer.config_defaultVibrationAmplitude)).thenReturn(-1);
+ assertThat(createConfig().getDefaultVibrationAmplitude()).isEqualTo(255);
+
+ when(mResourcesMock.getInteger(R.integer.config_defaultVibrationAmplitude)).thenReturn(0);
+ assertThat(createConfig().getDefaultVibrationAmplitude()).isEqualTo(255);
+
+ when(mResourcesMock.getInteger(R.integer.config_defaultVibrationAmplitude)).thenReturn(500);
+ assertThat(createConfig().getDefaultVibrationAmplitude()).isEqualTo(255);
+ }
+
+ @Test
+ public void getDefaultVibrationScaleLevelGain_returnsConfiguredGain() {
+ mSystemProperties.put(VibrationConfig.SCALE_LEVEL_GAIN_SYSTEM_PROPERTY, "1.2");
+ assertThat(createConfig().getDefaultVibrationScaleLevelGain()).isEqualTo(1.2f);
+
+ mSystemProperties.put(VibrationConfig.SCALE_LEVEL_GAIN_SYSTEM_PROPERTY, "2");
+ assertThat(createConfig().getDefaultVibrationScaleLevelGain()).isEqualTo(2f);
+ }
+
+ @Test
+ public void getDefaultVibrationScaleLevelGain_invalidValue_returnsFixedScaleGain() {
+ mSystemProperties.put(VibrationConfig.SCALE_LEVEL_GAIN_SYSTEM_PROPERTY, "");
+ assertThat(createConfig().getDefaultVibrationScaleLevelGain()).isEqualTo(1.4f);
+
+ mSystemProperties.put(VibrationConfig.SCALE_LEVEL_GAIN_SYSTEM_PROPERTY, "invalid");
+ assertThat(createConfig().getDefaultVibrationScaleLevelGain()).isEqualTo(1.4f);
+
+ mSystemProperties.put(VibrationConfig.SCALE_LEVEL_GAIN_SYSTEM_PROPERTY, "-1");
+ assertThat(createConfig().getDefaultVibrationScaleLevelGain()).isEqualTo(1.4f);
+
+ mSystemProperties.put(VibrationConfig.SCALE_LEVEL_GAIN_SYSTEM_PROPERTY, "0.5");
+ assertThat(createConfig().getDefaultVibrationScaleLevelGain()).isEqualTo(1.4f);
+
+ mSystemProperties.put(VibrationConfig.SCALE_LEVEL_GAIN_SYSTEM_PROPERTY, "1.0");
+ assertThat(createConfig().getDefaultVibrationScaleLevelGain()).isEqualTo(1.4f);
+ }
+
+ private VibrationConfig createConfig() {
+ return new VibrationConfig(mResourcesMock, mSystemProperties::get);
+ }
+}
diff --git a/graphics/java/android/graphics/OWNERS b/graphics/java/android/graphics/OWNERS
index 9fa8f1b284bb..ef8d26cc65b9 100644
--- a/graphics/java/android/graphics/OWNERS
+++ b/graphics/java/android/graphics/OWNERS
@@ -11,3 +11,4 @@ per-file BLASTBufferQueue.java = file:/services/core/java/com/android/server/wm/
per-file FontFamily.java = file:fonts/OWNERS
per-file FontListParser.java = file:fonts/OWNERS
per-file Typeface.java = file:fonts/OWNERS
+per-file Paint.java = file:fonts/OWNERS
diff --git a/graphics/java/android/graphics/Paint.java b/graphics/java/android/graphics/Paint.java
index df95a91d72d7..b866382e4061 100644
--- a/graphics/java/android/graphics/Paint.java
+++ b/graphics/java/android/graphics/Paint.java
@@ -1805,16 +1805,7 @@ public class Paint {
* @return true if elegant metrics are enabled for text drawing.
*/
public boolean isElegantTextHeight() {
- int rawValue = nGetElegantTextHeight(mNativePaint);
- switch (rawValue) {
- case ELEGANT_TEXT_HEIGHT_DISABLED:
- return false;
- case ELEGANT_TEXT_HEIGHT_ENABLED:
- return true;
- case ELEGANT_TEXT_HEIGHT_UNSET:
- default:
- return com.android.text.flags.Flags.deprecateUiFonts();
- }
+ return nGetElegantTextHeight(mNativePaint) != ELEGANT_TEXT_HEIGHT_DISABLED;
}
// Note: the following three values must be equal to the ones in the JNI file: Paint.cpp
diff --git a/graphics/java/android/graphics/fonts/SystemFonts.java b/graphics/java/android/graphics/fonts/SystemFonts.java
index f727f5b076a1..0e25c346064c 100644
--- a/graphics/java/android/graphics/fonts/SystemFonts.java
+++ b/graphics/java/android/graphics/fonts/SystemFonts.java
@@ -306,13 +306,7 @@ public final class SystemFonts {
long lastModifiedDate,
int configVersion
) {
- final String fontsXml;
- if (com.android.text.flags.Flags.newFontsFallbackXml()) {
- fontsXml = FONTS_XML;
- } else {
- fontsXml = LEGACY_FONTS_XML;
- }
- return getSystemFontConfigInternal(fontsXml, SYSTEM_FONT_DIR, OEM_XML, OEM_FONT_DIR,
+ return getSystemFontConfigInternal(FONTS_XML, SYSTEM_FONT_DIR, OEM_XML, OEM_FONT_DIR,
updatableFontMap, lastModifiedDate, configVersion);
}
@@ -337,13 +331,7 @@ public final class SystemFonts {
* @hide
*/
public static @NonNull FontConfig getSystemPreinstalledFontConfig() {
- final String fontsXml;
- if (com.android.text.flags.Flags.newFontsFallbackXml()) {
- fontsXml = FONTS_XML;
- } else {
- fontsXml = LEGACY_FONTS_XML;
- }
- return getSystemFontConfigInternal(fontsXml, SYSTEM_FONT_DIR, OEM_XML, OEM_FONT_DIR, null,
+ return getSystemFontConfigInternal(FONTS_XML, SYSTEM_FONT_DIR, OEM_XML, OEM_FONT_DIR, null,
0, 0);
}
diff --git a/libs/WindowManager/Shell/res/values/dimen.xml b/libs/WindowManager/Shell/res/values/dimen.xml
index 2d98a2b675a3..755e0d5f742d 100644
--- a/libs/WindowManager/Shell/res/values/dimen.xml
+++ b/libs/WindowManager/Shell/res/values/dimen.xml
@@ -569,7 +569,7 @@
<!-- The thickness in dp for all desktop drag transition regions. -->
<dimen name="desktop_mode_transition_region_thickness">44dp</dimen>
- <item type="dimen" format="float" name="desktop_mode_fullscreen_region_scale">0.4</item>
+ <item type="dimen" format="float" name="desktop_mode_fullscreen_region_scale">0.2</item>
<!-- The height on the screen where drag to the left or right edge will result in a
desktop task snapping to split size. The empty space between this and the top is to allow
diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeFlags.kt b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeFlags.kt
index 424d4bf5c6e8..b5d63bd6addc 100644
--- a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeFlags.kt
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeFlags.kt
@@ -49,6 +49,7 @@ enum class DesktopModeFlags(
SIZE_CONSTRAINTS(Flags::enableDesktopWindowingSizeConstraints, true),
DISABLE_SNAP_RESIZE(Flags::disableNonResizableAppSnapResizing, true),
DYNAMIC_INITIAL_BOUNDS(Flags::enableWindowingDynamicInitialBounds, false),
+ SCALED_RESIZING(Flags::enableWindowingScaledResizing, false),
ENABLE_DESKTOP_WINDOWING_TASK_LIMIT(Flags::enableDesktopWindowingTaskLimit, true),
BACK_NAVIGATION(Flags::enableDesktopWindowingBackNavigation, true),
EDGE_DRAG_RESIZE(Flags::enableWindowingEdgeDragResize, true),
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
index 156399499c5b..f478b4446cbe 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java
@@ -874,10 +874,6 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
// start post animation
dispatchOnBackInvoked(mActiveCallback);
} else {
- if (migrateBackToTransition
- && mBackTransitionHandler.mPrepareOpenTransition != null) {
- mBackTransitionHandler.createClosePrepareTransition();
- }
tryDispatchOnBackCancelled(mActiveCallback);
}
}
@@ -1163,8 +1159,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
IBinder mClosePrepareTransition;
TransitionInfo mOpenTransitionInfo;
void onAnimationFinished() {
- if (!mCloseTransitionRequested && mClosePrepareTransition == null) {
- applyFinishOpenTransition();
+ if (!mCloseTransitionRequested && mPrepareOpenTransition != null) {
+ createClosePrepareTransition();
}
if (mOnAnimationFinishCallback != null) {
mOnAnimationFinishCallback.run();
@@ -1234,7 +1230,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
applyAndFinish(st, ft, finishCallback);
return true;
} else if (mClosePrepareTransition == null && isPrepareTransition) {
- // Gesture animation was cancelled before prepare transition ready, create the
+ // Gesture animation was cancelled before prepare transition ready, create
// the close prepare transition
createClosePrepareTransition();
}
@@ -1247,6 +1243,10 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
}
void createClosePrepareTransition() {
+ if (mClosePrepareTransition != null) {
+ Log.e(TAG, "Re-create close prepare transition");
+ return;
+ }
final WindowContainerTransaction wct = new WindowContainerTransaction();
wct.restoreBackNavi();
mClosePrepareTransition = mTransitions.startTransition(
@@ -1384,10 +1384,10 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
}
if (info.getType() == TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION
- && !mCloseTransitionRequested && info.getChanges().isEmpty() && mApps != null) {
- // Wait for post animation finish
+ && !mCloseTransitionRequested && info.getChanges().isEmpty() && mApps == null) {
finishCallback.onTransitionFinished(null);
t.apply();
+ applyFinishOpenTransition();
return;
}
if (isNotGestureBackTransition(info) || shouldCancelAnimation(info)
@@ -1598,41 +1598,6 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
}
return null;
}
-
- class QueuedTransition {
- final TransitionInfo mInfo;
- final SurfaceControl.Transaction mSt;
- final SurfaceControl.Transaction mFt;
- final Transitions.TransitionFinishCallback mFinishCallback;
- QueuedTransition(@NonNull TransitionInfo info,
- @NonNull SurfaceControl.Transaction st,
- @NonNull SurfaceControl.Transaction ft,
- @NonNull Transitions.TransitionFinishCallback finishCallback) {
- mInfo = info;
- mSt = st;
- mFt = ft;
- mFinishCallback = finishCallback;
- }
-
- void consume() {
- // not animating, consume transition directly
- if (mApps == null || mApps.length == 0) {
- applyAndFinish(mSt, mFt, mFinishCallback);
- return;
- }
- // we are animating
- if (handlePrepareTransition(mInfo, mSt, mFt, mFinishCallback)) {
- // handle merge transition if any
- if (mCloseTransitionRequested) {
- mOnAnimationFinishCallback = () -> {
- applyFinishOpenTransition();
- mCloseTransitionRequested = false;
- };
- }
- }
- handleCloseTransition(mInfo, mSt, mFt, mFinishCallback);
- }
- }
}
private static boolean isNotGestureBackTransition(@NonNull TransitionInfo info) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java
index 8156a9c8d04a..f7f45ae36eda 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java
@@ -235,7 +235,7 @@ public class DividerSnapAlgorithm {
private SnapTarget snap(int position, boolean hardDismiss) {
if (shouldApplyFreeSnapMode(position)) {
- return new SnapTarget(position, position, SNAP_TO_NONE);
+ return new SnapTarget(position, SNAP_TO_NONE);
}
int minIndex = -1;
float minDistance = Float.MAX_VALUE;
@@ -263,7 +263,7 @@ public class DividerSnapAlgorithm {
if (dockedSide == DOCKED_RIGHT) {
startPos += mInsets.left;
}
- mTargets.add(new SnapTarget(startPos, startPos, SNAP_TO_START_AND_DISMISS, 0.35f));
+ mTargets.add(new SnapTarget(startPos, SNAP_TO_START_AND_DISMISS, 0.35f));
switch (mSnapMode) {
case SNAP_MODE_16_9:
addRatio16_9Targets(isHorizontalDivision, dividerMax);
@@ -278,7 +278,7 @@ public class DividerSnapAlgorithm {
addMinimizedTarget(isHorizontalDivision, dockedSide);
break;
}
- mTargets.add(new SnapTarget(dividerMax, dividerMax, SNAP_TO_END_AND_DISMISS, 0.35f));
+ mTargets.add(new SnapTarget(dividerMax, SNAP_TO_END_AND_DISMISS, 0.35f));
}
private void addNonDismissingTargets(boolean isHorizontalDivision, int topPosition,
@@ -325,14 +325,14 @@ public class DividerSnapAlgorithm {
*/
private void maybeAddTarget(int position, int smallerSize, @SnapPosition int snapPosition) {
if (smallerSize >= mMinimalSizeResizableTask) {
- mTargets.add(new SnapTarget(position, position, snapPosition));
+ mTargets.add(new SnapTarget(position, snapPosition));
}
}
private void addMiddleTarget(boolean isHorizontalDivision) {
int position = DockedDividerUtils.calculateMiddlePosition(isHorizontalDivision,
mInsets, mDisplayWidth, mDisplayHeight, mDividerSize);
- mTargets.add(new SnapTarget(position, position, SNAP_TO_50_50));
+ mTargets.add(new SnapTarget(position, SNAP_TO_50_50));
}
private void addMinimizedTarget(boolean isHorizontalDivision, int dockedSide) {
@@ -346,7 +346,7 @@ public class DividerSnapAlgorithm {
position = mDisplayWidth - position - mInsets.right - mDividerSize;
}
}
- mTargets.add(new SnapTarget(position, position, SNAP_TO_MINIMIZE));
+ mTargets.add(new SnapTarget(position, SNAP_TO_MINIMIZE));
}
public SnapTarget getMiddleTarget() {
@@ -377,20 +377,15 @@ public class DividerSnapAlgorithm {
}
/**
- * Represents a snap target for the divider.
+ * An object, calculated at boot time, representing a legal position for the split screen
+ * divider (i.e. the divider can be dragged to this spot).
*/
public static class SnapTarget {
/** Position of this snap target. The right/bottom edge of the top/left task snaps here. */
public final int position;
/**
- * Like {@link #position}, but used to calculate the task bounds which might be different
- * from the stack bounds.
- */
- public final int taskPosition;
-
- /**
- * An int describing the placement of the divider in this snap target.
+ * An int (enum) describing the placement of the divider in this snap target.
*/
public final @SnapPosition int snapPosition;
@@ -402,14 +397,13 @@ public class DividerSnapAlgorithm {
*/
private final float distanceMultiplier;
- public SnapTarget(int position, int taskPosition, @SnapPosition int snapPosition) {
- this(position, taskPosition, snapPosition, 1f);
+ public SnapTarget(int position, @SnapPosition int snapPosition) {
+ this(position, snapPosition, 1f);
}
- public SnapTarget(int position, int taskPosition, @SnapPosition int snapPosition,
+ public SnapTarget(int position, @SnapPosition int snapPosition,
float distanceMultiplier) {
this.position = position;
- this.taskPosition = taskPosition;
this.snapPosition = snapPosition;
this.distanceMultiplier = distanceMultiplier;
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java
index 2a934cba1b50..b8aa1b189f7e 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java
@@ -72,11 +72,12 @@ import com.android.wm.shell.common.DisplayImeController;
import com.android.wm.shell.common.DisplayInsetsController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.pip.PipUtils;
+import com.android.wm.shell.common.split.DividerSnapAlgorithm.SnapTarget;
+import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.shared.animation.Interpolators;
import com.android.wm.shell.shared.split.SplitScreenConstants.PersistentSnapPosition;
import com.android.wm.shell.shared.split.SplitScreenConstants.SnapPosition;
import com.android.wm.shell.shared.split.SplitScreenConstants.SplitPosition;
-import com.android.wm.shell.protolog.ShellProtoLogGroup;
import com.android.wm.shell.splitscreen.StageTaskListener;
import java.io.PrintWriter;
@@ -543,7 +544,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
* to middle position if the provided SnapTarget is not supported.
*/
public void setDivideRatio(@PersistentSnapPosition int snapPosition) {
- final DividerSnapAlgorithm.SnapTarget snapTarget = mDividerSnapAlgorithm.findSnapTarget(
+ final SnapTarget snapTarget = mDividerSnapAlgorithm.findSnapTarget(
snapPosition);
setDividerPosition(snapTarget != null
@@ -577,7 +578,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
* Sets new divider position and updates bounds correspondingly. Notifies listener if the new
* target indicates dismissing split.
*/
- public void snapToTarget(int currentPosition, DividerSnapAlgorithm.SnapTarget snapTarget) {
+ public void snapToTarget(int currentPosition, SnapTarget snapTarget) {
switch (snapTarget.snapPosition) {
case SNAP_TO_START_AND_DISMISS:
flingDividerPosition(currentPosition, snapTarget.position, FLING_RESIZE_DURATION,
@@ -613,10 +614,10 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
}
/**
- * Returns {@link DividerSnapAlgorithm.SnapTarget} which matches passing position and velocity.
+ * Returns {@link SnapTarget} which matches passing position and velocity.
* If hardDismiss is set to {@code true}, it will be harder to reach dismiss target.
*/
- public DividerSnapAlgorithm.SnapTarget findSnapTarget(int position, float velocity,
+ public SnapTarget findSnapTarget(int position, float velocity,
boolean hardDismiss) {
return mDividerSnapAlgorithm.calculateSnapTarget(position, velocity, hardDismiss);
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java
index bfc0ee803591..72619195fb3f 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicator.java
@@ -45,6 +45,7 @@ import android.view.animation.DecelerateInterpolator;
import androidx.annotation.VisibleForTesting;
+import com.android.internal.policy.SystemBarUtils;
import com.android.wm.shell.R;
import com.android.wm.shell.RootTaskDisplayAreaOrganizer;
import com.android.wm.shell.common.DisplayController;
@@ -173,8 +174,7 @@ public class DesktopModeVisualIndicator {
final Region region = new Region();
int transitionHeight = mDragStartState == DragStartState.FROM_FREEFORM
|| mDragStartState == DragStartState.DRAGGED_INTENT
- ? mContext.getResources().getDimensionPixelSize(
- com.android.wm.shell.R.dimen.desktop_mode_transition_region_thickness)
+ ? SystemBarUtils.getStatusBarHeight(mContext)
: 2 * layout.stableInsets().top;
// A Rect at the top of the screen that takes up the center 40%.
if (mDragStartState == DragStartState.FROM_FREEFORM) {
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionHandler.java
index 1ffa54103d62..832e2d2bc77b 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/freeform/FreeformTaskTransitionHandler.java
@@ -118,7 +118,7 @@ public class FreeformTaskTransitionHandler
@Override
public IBinder startMinimizedModeTransition(WindowContainerTransaction wct) {
- final int type = WindowManager.TRANSIT_TO_BACK;
+ final int type = Transitions.TRANSIT_MINIMIZE;
final IBinder token = mTransitions.startTransition(type, wct, this);
mPendingTransitionTokens.add(token);
return token;
@@ -161,7 +161,8 @@ public class FreeformTaskTransitionHandler
transition, info.getType(), change);
break;
case WindowManager.TRANSIT_TO_BACK:
- transitionHandled |= startMinimizeTransition(transition);
+ transitionHandled |= startMinimizeTransition(
+ transition, info.getType(), change);
break;
case WindowManager.TRANSIT_CLOSE:
if (change.getTaskInfo().getWindowingMode() == WINDOWING_MODE_FREEFORM) {
@@ -227,8 +228,20 @@ public class FreeformTaskTransitionHandler
return handled;
}
- private boolean startMinimizeTransition(IBinder transition) {
- return mPendingTransitionTokens.contains(transition);
+ private boolean startMinimizeTransition(
+ IBinder transition,
+ int type,
+ TransitionInfo.Change change) {
+ if (!mPendingTransitionTokens.contains(transition)) {
+ return false;
+ }
+
+ final ActivityManager.RunningTaskInfo taskInfo = change.getTaskInfo();
+ if (type != Transitions.TRANSIT_MINIMIZE) {
+ return false;
+ }
+ // TODO(b/361524575): Add minimize animations
+ return true;
}
private boolean startCloseTransition(IBinder transition, TransitionInfo.Change change,
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java
index 4df649ca8c93..f060158766fe 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip/PipAnimationController.java
@@ -497,13 +497,8 @@ public class PipAnimationController {
mCurrentValue = value;
}
- boolean shouldApplyCornerRadius() {
- return !isOutPipDirection(mTransitionDirection);
- }
-
boolean shouldApplyShadowRadius() {
- return !isOutPipDirection(mTransitionDirection)
- && !isRemovePipDirection(mTransitionDirection);
+ return !isRemovePipDirection(mTransitionDirection);
}
boolean inScaleTransition() {
@@ -556,7 +551,7 @@ public class PipAnimationController {
final float alpha = getStartValue() * (1 - fraction) + getEndValue() * fraction;
setCurrentValue(alpha);
getSurfaceTransactionHelper().alpha(tx, leash, alpha)
- .round(tx, leash, shouldApplyCornerRadius())
+ .round(tx, leash, true /* applyCornerRadius */)
.shadow(tx, leash, shouldApplyShadowRadius());
if (!handlePipTransaction(leash, tx, destinationBounds, alpha)) {
tx.apply();
@@ -572,7 +567,7 @@ public class PipAnimationController {
getSurfaceTransactionHelper()
.resetScale(tx, leash, getDestinationBounds())
.crop(tx, leash, getDestinationBounds())
- .round(tx, leash, shouldApplyCornerRadius())
+ .round(tx, leash, true /* applyCornerRadius */)
.shadow(tx, leash, shouldApplyShadowRadius());
tx.show(leash);
tx.apply();
@@ -686,13 +681,11 @@ public class PipAnimationController {
getSurfaceTransactionHelper().scaleAndCrop(tx, leash,
adjustedSourceRectHint, initialSourceValue, bounds, insets,
isInPipDirection, fraction);
- if (shouldApplyCornerRadius()) {
- final Rect sourceBounds = new Rect(initialContainerRect);
- sourceBounds.inset(insets);
- getSurfaceTransactionHelper()
- .round(tx, leash, sourceBounds, bounds)
- .shadow(tx, leash, shouldApplyShadowRadius());
- }
+ final Rect sourceBounds = new Rect(initialContainerRect);
+ sourceBounds.inset(insets);
+ getSurfaceTransactionHelper()
+ .round(tx, leash, sourceBounds, bounds)
+ .shadow(tx, leash, shouldApplyShadowRadius());
}
if (!handlePipTransaction(leash, tx, bounds, /* alpha= */ 1f)) {
tx.apply();
@@ -741,11 +734,9 @@ public class PipAnimationController {
.rotateAndScaleWithCrop(tx, leash, initialContainerRect, bounds,
insets, degree, x, y, isOutPipDirection,
rotationDelta == ROTATION_270 /* clockwise */);
- if (shouldApplyCornerRadius()) {
- getSurfaceTransactionHelper()
- .round(tx, leash, sourceBounds, bounds)
- .shadow(tx, leash, shouldApplyShadowRadius());
- }
+ getSurfaceTransactionHelper()
+ .round(tx, leash, sourceBounds, bounds)
+ .shadow(tx, leash, shouldApplyShadowRadius());
if (!handlePipTransaction(leash, tx, bounds, 1f /* alpha */)) {
tx.apply();
}
@@ -761,7 +752,7 @@ public class PipAnimationController {
void onStartTransaction(SurfaceControl leash, SurfaceControl.Transaction tx) {
getSurfaceTransactionHelper()
.alpha(tx, leash, 1f)
- .round(tx, leash, shouldApplyCornerRadius())
+ .round(tx, leash, true /* applyCornerRadius */)
.shadow(tx, leash, shouldApplyShadowRadius());
tx.show(leash);
tx.apply();
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentTasks.aidl b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentTasks.aidl
index ebfd3571ae6d..799028a5507a 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentTasks.aidl
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentTasks.aidl
@@ -21,8 +21,8 @@ import android.app.IApplicationThread;
import android.app.PendingIntent;
import android.content.Intent;
import android.os.Bundle;
-import android.view.IRecentsAnimationRunner;
+import com.android.wm.shell.recents.IRecentsAnimationRunner;
import com.android.wm.shell.recents.IRecentTasksListener;
import com.android.wm.shell.shared.GroupedRecentTaskInfo;
diff --git a/core/java/android/view/IRecentsAnimationController.aidl b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentsAnimationController.aidl
index 55ad4ae6d665..ccfaab079205 100644
--- a/core/java/android/view/IRecentsAnimationController.aidl
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentsAnimationController.aidl
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package android.view;
+package com.android.wm.shell.recents;
import android.app.ActivityManager;
import android.graphics.GraphicBuffer;
@@ -61,7 +61,6 @@ interface IRecentsAnimationController {
* @param sendUserLeaveHint If set to true, {@link Activity#onUserLeaving} will be sent to the
* top resumed app, false otherwise.
*/
- @UnsupportedAppUsage
void finish(boolean moveHomeToTop, boolean sendUserLeaveHint, in IResultReceiver finishCb);
/**
@@ -71,75 +70,15 @@ interface IRecentsAnimationController {
* may register the recents animation input consumer prior to starting the recents animation
* and then enable it mid-animation to start receiving touch events.
*/
- @UnsupportedAppUsage
void setInputConsumerEnabled(boolean enabled);
/**
- * Informs the system whether the animation targets passed into
- * IRecentsAnimationRunner.onAnimationStart are currently behind the system bars. If they are,
- * they can control the SystemUI flags, otherwise the SystemUI flags from home activity will be
- * taken.
- */
- @UnsupportedAppUsage
- void setAnimationTargetsBehindSystemBars(boolean behindSystemBars);
-
- /**
- * Clean up the screenshot of previous task which was created during recents animation that
- * was cancelled by a stack order change.
- *
- * @see {@link IRecentsAnimationRunner#onAnimationCanceled}
- */
- void cleanupScreenshot();
-
- /**
- * Set a state for controller whether would like to cancel recents animations with deferred
- * task screenshot presentation.
- *
- * When we cancel the recents animation due to a stack order change, we can't just cancel it
- * immediately as it would lead to a flicker in Launcher if we just remove the task from the
- * leash. Instead we screenshot the previous task and replace the child of the leash with the
- * screenshot, so that Launcher can still control the leash lifecycle & make the next app
- * transition animate smoothly without flickering.
- *
- * @param defer When set {@code true}, means that the recents animation will defer canceling the
- * animation when a stack order change is triggered until the subsequent app
- * transition start and skip previous task's animation.
- * When set to {@code false}, means that the recents animation will be canceled
- * immediately when the stack order changes.
- * @param screenshot When set {@code true}, means that the system will take previous task's
- * screenshot and replace the contents of the leash with it when the next app
- * transition starting. The runner must call #cleanupScreenshot() to end the
- * recents animation.
- * When set to {@code false}, means that the system will simply wait for the
- * next app transition start to immediately cancel the recents animation. This
- * can be useful when you want an immediate transition into a state where the
- * task is shown in the home/recents activity (without waiting for a
- * screenshot).
- *
- * @see #cleanupScreenshot()
- * @see IRecentsAnimationRunner#onCancelled
- */
- void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot);
-
- /**
* Sets a state for controller to decide which surface is the destination when the recents
* animation is cancelled through fail safe mechanism.
*/
void setWillFinishToHome(boolean willFinishToHome);
/**
- * Stops controlling a task that is currently controlled by this recents animation.
- *
- * This method should be called when a task that has been received via {@link #onAnimationStart}
- * or {@link #onTaskAppeared} is no longer needed. After calling this method, the task will
- * either disappear from the screen, or jump to its final position in case it was the top task.
- *
- * @param taskId Id of the Task target to remove
- * @return {@code true} when target removed successfully, {@code false} otherwise.
- */
- boolean removeTask(int taskId);
-
- /**
* Detach navigation bar from app.
*
* The system reparents the leash of navigation bar to the app when the recents animation starts
@@ -155,15 +94,6 @@ interface IRecentsAnimationController {
void detachNavigationBarFromApp(boolean moveHomeToTop);
/**
- * Used for animating the navigation bar during app launch from recents in live tile mode.
- *
- * First fade out the navigation bar at the bottom of the display and then fade in to the app.
- *
- * @param duration the duration of the app launch animation
- */
- void animateNavigationBarToApp(long duration);
-
- /**
* Hand off the ongoing animation of a set of remote targets, to be run by another handler using
* the given starting parameters.
*
diff --git a/core/java/android/view/IRecentsAnimationRunner.aidl b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentsAnimationRunner.aidl
index 37663d59cafd..8021758bf7c3 100644
--- a/core/java/android/view/IRecentsAnimationRunner.aidl
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/IRecentsAnimationRunner.aidl
@@ -14,15 +14,16 @@
* limitations under the License.
*/
-package android.view;
+package com.android.wm.shell.recents;
import android.app.ActivityManager;
import android.graphics.Rect;
import android.view.RemoteAnimationTarget;
-import android.view.IRecentsAnimationController;
import android.window.TaskSnapshot;
import android.os.Bundle;
+import com.android.wm.shell.recents.IRecentsAnimationController;
+
/**
* Interface that is used to callback from window manager to the process that runs a recents
* animation to start or cancel it.
@@ -55,7 +56,6 @@ oneway interface IRecentsAnimationRunner {
* @param minimizedHomeBounds Specifies the bounds of the minimized home app, will be
* {@code null} if the device is not currently in split screen
*/
- @UnsupportedAppUsage(maxTargetSdk = 30, trackingBug = 170729553)
void onAnimationStart(in IRecentsAnimationController controller,
in RemoteAnimationTarget[] apps, in RemoteAnimationTarget[] wallpapers,
in Rect homeContentInsets, in Rect minimizedHomeBounds, in Bundle extras) = 2;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java
index 9af33a84b045..a6e25a95e1eb 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentTasksController.java
@@ -37,7 +37,6 @@ import android.os.RemoteException;
import android.util.Slog;
import android.util.SparseArray;
import android.util.SparseIntArray;
-import android.view.IRecentsAnimationRunner;
import android.window.WindowContainerToken;
import androidx.annotation.BinderThread;
@@ -54,6 +53,7 @@ import com.android.wm.shell.common.TaskStackListenerCallback;
import com.android.wm.shell.common.TaskStackListenerImpl;
import com.android.wm.shell.desktopmode.DesktopModeTaskRepository;
import com.android.wm.shell.protolog.ShellProtoLogGroup;
+import com.android.wm.shell.recents.IRecentsAnimationRunner;
import com.android.wm.shell.shared.GroupedRecentTaskInfo;
import com.android.wm.shell.shared.annotations.ExternalThread;
import com.android.wm.shell.shared.annotations.ShellMainThread;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
index c90da052dd72..c660000e4f61 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/recents/RecentsTransitionHandler.java
@@ -49,8 +49,6 @@ import android.util.IntArray;
import android.util.Pair;
import android.util.Slog;
import android.view.Display;
-import android.view.IRecentsAnimationController;
-import android.view.IRecentsAnimationRunner;
import android.view.RemoteAnimationTarget;
import android.view.SurfaceControl;
import android.window.PictureInPictureSurfaceTransaction;
@@ -1024,10 +1022,6 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
}
@Override
- public void setAnimationTargetsBehindSystemBars(boolean behindSystemBars) {
- }
-
- @Override
public void setFinishTaskTransaction(int taskId,
PictureInPictureSurfaceTransaction finishTransaction, SurfaceControl overlay) {
mExecutor.execute(() -> {
@@ -1254,14 +1248,6 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
}
@Override
- public void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot) {
- }
-
- @Override
- public void cleanupScreenshot() {
- }
-
- @Override
public void setWillFinishToHome(boolean willFinishToHome) {
mExecutor.execute(() -> {
mWillFinishToHome = willFinishToHome;
@@ -1269,14 +1255,6 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
}
/**
- * @see IRecentsAnimationController#removeTask
- */
- @Override
- public boolean removeTask(int taskId) {
- return false;
- }
-
- /**
* @see IRecentsAnimationController#detachNavigationBarFromApp
*/
@Override
@@ -1292,13 +1270,6 @@ public class RecentsTransitionHandler implements Transitions.TransitionHandler {
}
});
}
-
- /**
- * @see IRecentsAnimationController#animateNavigationBarToApp(long)
- */
- @Override
- public void animateNavigationBarToApp(long duration) {
- }
};
/** Utility class to track the state of a task as-seen by recents. */
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitscreenEventLogger.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitscreenEventLogger.java
index 1e6fa2807b9b..2033902f03c7 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitscreenEventLogger.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/SplitscreenEventLogger.java
@@ -24,6 +24,7 @@ import static com.android.internal.util.FrameworkStatsLog.SPLITSCREEN_UICHANGED_
import static com.android.internal.util.FrameworkStatsLog.SPLITSCREEN_UICHANGED__EXIT_REASON__CHILD_TASK_ENTER_PIP;
import static com.android.internal.util.FrameworkStatsLog.SPLITSCREEN_UICHANGED__EXIT_REASON__DEVICE_FOLDED;
import static com.android.internal.util.FrameworkStatsLog.SPLITSCREEN_UICHANGED__EXIT_REASON__DRAG_DIVIDER;
+import static com.android.internal.util.FrameworkStatsLog.SPLITSCREEN_UICHANGED__EXIT_REASON__FULLSCREEN_REQUEST;
import static com.android.internal.util.FrameworkStatsLog.SPLITSCREEN_UICHANGED__EXIT_REASON__FULLSCREEN_SHORTCUT;
import static com.android.internal.util.FrameworkStatsLog.SPLITSCREEN_UICHANGED__EXIT_REASON__DESKTOP_MODE;
import static com.android.internal.util.FrameworkStatsLog.SPLITSCREEN_UICHANGED__EXIT_REASON__RECREATE_SPLIT;
@@ -45,6 +46,7 @@ import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_DEVICE_FOLDED;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_DRAG_DIVIDER;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_DESKTOP_MODE;
+import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_FULLSCREEN_REQUEST;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_FULLSCREEN_SHORTCUT;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_RECREATE_SPLIT;
import static com.android.wm.shell.splitscreen.SplitScreenController.EXIT_REASON_RETURN_HOME;
@@ -211,6 +213,8 @@ public class SplitscreenEventLogger {
return SPLITSCREEN_UICHANGED__EXIT_REASON__FULLSCREEN_SHORTCUT;
case EXIT_REASON_DESKTOP_MODE:
return SPLITSCREEN_UICHANGED__EXIT_REASON__DESKTOP_MODE;
+ case EXIT_REASON_FULLSCREEN_REQUEST:
+ return SPLITSCREEN_UICHANGED__EXIT_REASON__FULLSCREEN_REQUEST;
case EXIT_REASON_UNKNOWN:
// Fall through
default:
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java
index dad0d4eb4d8d..1b143ebddde7 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java
@@ -1175,6 +1175,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
mSplitTransitions.startDismissTransition(wct, this, mLastActiveStage, reason);
setSplitsVisible(false);
mBreakOnNextWake = false;
+ logExit(reason);
}
void exitSplitScreenOnHide(boolean exitSplitScreenOnHide) {
@@ -1265,6 +1266,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
final WindowContainerTransaction wct = new WindowContainerTransaction();
prepareExitSplitScreen(stage, wct);
mSplitTransitions.startDismissTransition(wct, this, stage, exitReason);
+ logExit(exitReason);
}
/**
@@ -1361,6 +1363,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
mMainStage.doForAllChildTasks(taskId -> recentTasks.removeSplitPair(taskId));
mSideStage.doForAllChildTasks(taskId -> recentTasks.removeSplitPair(taskId));
});
+ logExit(exitReason);
}
/**
@@ -1579,7 +1582,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
if (stage == STAGE_TYPE_MAIN) {
mLogger.logMainStageAppChange(getMainStagePosition(), mMainStage.getTopChildTaskUid(),
mSplitLayout.isLeftRightSplit());
- } else {
+ } else if (stage == STAGE_TYPE_SIDE) {
mLogger.logSideStageAppChange(getSideStagePosition(), mSideStage.getTopChildTaskUid(),
mSplitLayout.isLeftRightSplit());
}
@@ -2275,6 +2278,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
if (isOpening && inFullscreen) {
// One task is opening into fullscreen mode, remove the corresponding split record.
mRecentTasks.ifPresent(recentTasks -> recentTasks.removeSplitPair(triggerTask.taskId));
+ logExit(EXIT_REASON_FULLSCREEN_REQUEST);
}
if (isSplitActive()) {
@@ -2402,6 +2406,7 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
if (triggerTask != null) {
mRecentTasks.ifPresent(
recentTasks -> recentTasks.removeSplitPair(triggerTask.taskId));
+ logExit(EXIT_REASON_CHILD_TASK_ENTER_PIP);
}
@StageType int topStage = STAGE_TYPE_UNDEFINED;
if (isSplitScreenVisible()) {
@@ -2743,7 +2748,10 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
final int dismissTop = mainChild != null ? STAGE_TYPE_MAIN :
(sideChild != null ? STAGE_TYPE_SIDE : STAGE_TYPE_UNDEFINED);
pendingEnter.cancel(
- (cancelWct, cancelT) -> prepareExitSplitScreen(dismissTop, cancelWct));
+ (cancelWct, cancelT) -> {
+ prepareExitSplitScreen(dismissTop, cancelWct);
+ logExit(EXIT_REASON_UNKNOWN);
+ });
Log.w(TAG, splitFailureMessage("startPendingEnterAnimation",
"launched 2 tasks in split, but didn't receive "
+ "2 tasks in transition. Possibly one of them failed to launch"));
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java
index 7dc336bdfb7d..aba8b61af306 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/Transitions.java
@@ -196,6 +196,9 @@ public class Transitions implements RemoteCallable<Transitions>,
/** Transition to set windowing mode after exit pip transition is finished animating. */
public static final int TRANSIT_CLEANUP_PIP_EXIT = WindowManager.TRANSIT_FIRST_CUSTOM + 19;
+ /** Transition type to minimize a task. */
+ public static final int TRANSIT_MINIMIZE = WindowManager.TRANSIT_FIRST_CUSTOM + 20;
+
/** Transition type for desktop mode transitions. */
public static final int TRANSIT_DESKTOP_MODE_TYPES =
WindowManager.TRANSIT_FIRST_CUSTOM + 100;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
index 79190689adc1..0f8bd2866fa8 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModel.java
@@ -199,6 +199,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
});
}
};
+ private final TaskPositionerFactory mTaskPositionerFactory;
public DesktopModeWindowDecorViewModel(
Context context,
@@ -250,7 +251,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
new SparseArray<>(),
interactionJankMonitor,
desktopTasksLimiter,
- activityOrientationChangeHandler);
+ activityOrientationChangeHandler,
+ new TaskPositionerFactory());
}
@VisibleForTesting
@@ -280,7 +282,8 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
SparseArray<DesktopModeWindowDecoration> windowDecorByTaskId,
InteractionJankMonitor interactionJankMonitor,
Optional<DesktopTasksLimiter> desktopTasksLimiter,
- Optional<DesktopActivityOrientationChangeHandler> activityOrientationChangeHandler) {
+ Optional<DesktopActivityOrientationChangeHandler> activityOrientationChangeHandler,
+ TaskPositionerFactory taskPositionerFactory) {
mContext = context;
mMainExecutor = shellExecutor;
mMainHandler = mainHandler;
@@ -335,6 +338,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
}
}
};
+ mTaskPositionerFactory = taskPositionerFactory;
shellInit.addInitCallback(this::onInit, this);
}
@@ -828,7 +832,10 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
decoration.mTaskSurface,
e.getRawX(dragPointerIdx),
newTaskBounds);
- updateDragStatus(e.getActionMasked());
+ // Flip mIsDragging only if the bounds actually changed.
+ if (mIsDragging || !newTaskBounds.equals(mOnDragStartInitialBounds)) {
+ updateDragStatus(e.getActionMasked());
+ }
return true;
}
case MotionEvent.ACTION_UP:
@@ -1280,23 +1287,18 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
mMultiInstanceHelper);
mWindowDecorByTaskId.put(taskInfo.taskId, windowDecoration);
- final DragPositioningCallback dragPositioningCallback;
- if (!DesktopModeStatus.isVeiledResizeEnabled()) {
- dragPositioningCallback = new FluidResizeTaskPositioner(
- mTaskOrganizer, mTransitions, windowDecoration, mDisplayController,
- mDragStartListener, mTransactionFactory);
- windowDecoration.setTaskDragResizer(
- (FluidResizeTaskPositioner) dragPositioningCallback);
- } else {
- dragPositioningCallback = new VeiledResizeTaskPositioner(
- mTaskOrganizer, windowDecoration, mDisplayController,
- mDragStartListener, mTransitions, mInteractionJankMonitor);
- windowDecoration.setTaskDragResizer(
- (VeiledResizeTaskPositioner) dragPositioningCallback);
- }
+ final TaskPositioner taskPositioner = mTaskPositionerFactory.create(
+ mTaskOrganizer,
+ windowDecoration,
+ mDisplayController,
+ mDragStartListener,
+ mTransitions,
+ mInteractionJankMonitor,
+ mTransactionFactory);
+ windowDecoration.setTaskDragResizer(taskPositioner);
final DesktopModeTouchEventListener touchEventListener =
- new DesktopModeTouchEventListener(taskInfo, dragPositioningCallback);
+ new DesktopModeTouchEventListener(taskInfo, taskPositioner);
windowDecoration.setOnMaximizeOrRestoreClickListener(() -> {
onMaximizeOrRestore(taskInfo.taskId, "maximize_menu");
return Unit.INSTANCE;
@@ -1330,7 +1332,7 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
windowDecoration.setCaptionListeners(
touchEventListener, touchEventListener, touchEventListener, touchEventListener);
windowDecoration.setExclusionRegionListener(mExclusionRegionListener);
- windowDecoration.setDragPositioningCallback(dragPositioningCallback);
+ windowDecoration.setDragPositioningCallback(taskPositioner);
windowDecoration.setDragDetector(touchEventListener.mDragDetector);
windowDecoration.relayout(taskInfo, startT, finishT,
false /* applyStartTransactionOnDraw */, false /* shouldSetTaskPositionAndCrop */);
@@ -1479,6 +1481,25 @@ public class DesktopModeWindowDecorViewModel implements WindowDecorViewModel {
}
}
}
-}
-
+ @VisibleForTesting
+ static class TaskPositionerFactory {
+ TaskPositioner create(
+ ShellTaskOrganizer taskOrganizer,
+ DesktopModeWindowDecoration windowDecoration,
+ DisplayController displayController,
+ DragPositioningCallbackUtility.DragStartListener dragStartListener,
+ Transitions transitions,
+ InteractionJankMonitor interactionJankMonitor,
+ Supplier<SurfaceControl.Transaction> transactionFactory) {
+ if (!DesktopModeStatus.isVeiledResizeEnabled()) {
+ return new FluidResizeTaskPositioner(
+ taskOrganizer, transitions, windowDecoration, displayController,
+ dragStartListener, transactionFactory);
+ }
+ return new VeiledResizeTaskPositioner(
+ taskOrganizer, windowDecoration, displayController,
+ dragStartListener, transitions, interactionJankMonitor);
+ }
+ }
+}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java
index e2d42b2783da..3853f1f086c1 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/FluidResizeTaskPositioner.java
@@ -49,8 +49,7 @@ import java.util.function.Supplier;
* that we send the final shell transition since we still utilize the {@link #onTransitionConsumed}
* callback.
*/
-class FluidResizeTaskPositioner implements DragPositioningCallback,
- TaskDragResizer, Transitions.TransitionHandler {
+class FluidResizeTaskPositioner implements TaskPositioner, Transitions.TransitionHandler {
private final ShellTaskOrganizer mTaskOrganizer;
private final Transitions mTransitions;
private final WindowDecoration mWindowDecoration;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskDragResizer.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskDragResizer.java
index 40421b599889..d7ea0c3a8e62 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskDragResizer.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskDragResizer.java
@@ -19,7 +19,7 @@ package com.android.wm.shell.windowdecor;
/**
* Holds the state of a drag resize.
*/
-interface TaskDragResizer {
+public interface TaskDragResizer {
/**
* Returns true if task is currently being resized or animating the final transition after
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskPositioner.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskPositioner.kt
new file mode 100644
index 000000000000..96c43da0cdf2
--- /dev/null
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/TaskPositioner.kt
@@ -0,0 +1,22 @@
+/*
+ * Copyright (C) 2024 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.wm.shell.windowdecor
+
+/**
+ * Interface for TaskPositioner.
+ */
+interface TaskPositioner : DragPositioningCallback, TaskDragResizer
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java
index 4a884eb50595..599815530f63 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/VeiledResizeTaskPositioner.java
@@ -47,8 +47,7 @@ import java.util.function.Supplier;
* If the drag is resizing the task, we resize the veil instead.
* If the drag is repositioning, we update in the typical manner.
*/
-public class VeiledResizeTaskPositioner implements DragPositioningCallback,
- TaskDragResizer, Transitions.TransitionHandler {
+public class VeiledResizeTaskPositioner implements TaskPositioner, Transitions.TransitionHandler {
private DesktopModeWindowDecoration mDesktopWindowDecoration;
private ShellTaskOrganizer mTaskOrganizer;
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java
index 1e4b8b62a082..b53ea3837178 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java
@@ -692,6 +692,8 @@ public class BackAnimationControllerTest extends ShellTestCase {
mBackTransitionHandler.startAnimation(mockBinder, tInfo, st, ft, callback);
verify(mBackTransitionHandler).handlePrepareTransition(
eq(tInfo), eq(st), eq(ft), eq(callback));
+
+ mBackTransitionHandler.onAnimationFinished();
final TransitionInfo.Change openToClose = createAppChange(openTaskId, TRANSIT_CLOSE,
FLAG_BACK_GESTURE_ANIMATED);
tInfo2 = createTransitionInfo(TRANSIT_CLOSE_PREPARE_BACK_NAVIGATION, openToClose);
@@ -700,7 +702,6 @@ public class BackAnimationControllerTest extends ShellTestCase {
mBackTransitionHandler.mergeAnimation(mBackTransitionHandler.mClosePrepareTransition,
tInfo2, st, mock(IBinder.class), mergeCallback);
assertTrue("Change should be consumed", tInfo2.getChanges().isEmpty());
- mBackTransitionHandler.onAnimationFinished();
verify(callback).onTransitionFinished(any());
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java
index 09fcd8b02010..82b3a7de521b 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/common/split/SplitLayoutTests.java
@@ -20,8 +20,6 @@ import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_50_50;
-import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_END_AND_DISMISS;
-import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_START_AND_DISMISS;
import static com.google.common.truth.Truth.assertThat;
@@ -150,8 +148,8 @@ public class SplitLayoutTests extends ShellTestCase {
@UiThreadTest
public void testSnapToDismissStart() {
// verify it callbacks properly when the snap target indicates dismissing split.
- DividerSnapAlgorithm.SnapTarget snapTarget = getSnapTarget(0 /* position */,
- SNAP_TO_START_AND_DISMISS);
+ DividerSnapAlgorithm.SnapTarget snapTarget =
+ mSplitLayout.mDividerSnapAlgorithm.getDismissStartTarget();
mSplitLayout.snapToTarget(mSplitLayout.getDividerPosition(), snapTarget);
waitDividerFlingFinished();
@@ -162,8 +160,8 @@ public class SplitLayoutTests extends ShellTestCase {
@UiThreadTest
public void testSnapToDismissEnd() {
// verify it callbacks properly when the snap target indicates dismissing split.
- DividerSnapAlgorithm.SnapTarget snapTarget = getSnapTarget(0 /* position */,
- SNAP_TO_END_AND_DISMISS);
+ DividerSnapAlgorithm.SnapTarget snapTarget =
+ mSplitLayout.mDividerSnapAlgorithm.getDismissEndTarget();
mSplitLayout.snapToTarget(mSplitLayout.getDividerPosition(), snapTarget);
waitDividerFlingFinished();
@@ -203,9 +201,4 @@ public class SplitLayoutTests extends ShellTestCase {
new Rect(0, 0, 1080, 2160));
return configuration;
}
-
- private static DividerSnapAlgorithm.SnapTarget getSnapTarget(int position, int flag) {
- return new DividerSnapAlgorithm.SnapTarget(
- position /* position */, position /* taskPosition */, flag);
- }
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt
index f558e87c4ed7..2b7f86f36477 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopModeVisualIndicatorTest.kt
@@ -22,6 +22,7 @@ import android.graphics.Region
import android.testing.AndroidTestingRunner
import android.view.SurfaceControl
import androidx.test.filters.SmallTest
+import com.android.internal.policy.SystemBarUtils
import com.android.wm.shell.R
import com.android.wm.shell.RootTaskDisplayAreaOrganizer
import com.android.wm.shell.ShellTestCase
@@ -67,8 +68,7 @@ class DesktopModeVisualIndicatorTest : ShellTestCase() {
createVisualIndicator(DesktopModeVisualIndicator.DragStartState.FROM_FREEFORM)
testRegion = visualIndicator.calculateFullscreenRegion(displayLayout, CAPTION_HEIGHT)
- val transitionHeight = context.resources.getDimensionPixelSize(
- R.dimen.desktop_mode_transition_region_thickness)
+ val transitionHeight = SystemBarUtils.getStatusBarHeight(context)
val toFullscreenScale = mContext.resources.getFloat(
R.dimen.desktop_mode_fullscreen_region_scale
)
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java
index 7c63fdad660a..7937a843b90a 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/transition/ShellTransitionTests.java
@@ -76,7 +76,6 @@ import android.os.RemoteException;
import android.platform.test.flag.junit.SetFlagsRule;
import android.util.ArraySet;
import android.util.Pair;
-import android.view.IRecentsAnimationRunner;
import android.view.Surface;
import android.view.SurfaceControl;
import android.window.IRemoteTransition;
@@ -107,6 +106,7 @@ import com.android.wm.shell.TestShellExecutor;
import com.android.wm.shell.common.DisplayController;
import com.android.wm.shell.common.DisplayLayout;
import com.android.wm.shell.common.ShellExecutor;
+import com.android.wm.shell.recents.IRecentsAnimationRunner;
import com.android.wm.shell.recents.RecentTasksController;
import com.android.wm.shell.recents.RecentsTransitionHandler;
import com.android.wm.shell.shared.ShellSharedConstants;
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt
index 3dd8a2bacbcd..2c805e8e77b3 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt
@@ -34,6 +34,7 @@ import android.hardware.display.VirtualDisplay
import android.hardware.input.InputManager
import android.net.Uri
import android.os.Handler
+import android.os.SystemClock
import android.os.UserHandle
import android.platform.test.annotations.DisableFlags
import android.platform.test.annotations.EnableFlags
@@ -52,10 +53,12 @@ import android.view.InputMonitor
import android.view.InsetsSource
import android.view.InsetsState
import android.view.KeyEvent
+import android.view.MotionEvent
import android.view.Surface
import android.view.SurfaceControl
import android.view.SurfaceView
import android.view.View
+import android.view.ViewRootImpl
import android.view.WindowInsets.Type.statusBars
import android.widget.Toast
import android.window.WindowContainerTransaction
@@ -174,6 +177,10 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() {
@Mock private lateinit var mockFreeformTaskTransitionStarter: FreeformTaskTransitionStarter
@Mock private lateinit var mockActivityOrientationChangeHandler:
DesktopActivityOrientationChangeHandler
+ @Mock private lateinit var mockInputManager: InputManager
+ @Mock private lateinit var mockTaskPositionerFactory:
+ DesktopModeWindowDecorViewModel.TaskPositionerFactory
+ @Mock private lateinit var mockTaskPositioner: TaskPositioner
private lateinit var spyContext: TestableContext
private val transactionFactory = Supplier<SurfaceControl.Transaction> {
@@ -203,6 +210,7 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() {
doNothing().`when`(spyContext).startActivity(any())
shellInit = ShellInit(mockShellExecutor)
windowDecorByTaskIdSpy.clear()
+ spyContext.addMockSystemService(InputManager::class.java, mockInputManager)
desktopModeWindowDecorViewModel = DesktopModeWindowDecorViewModel(
spyContext,
mockShellExecutor,
@@ -229,12 +237,15 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() {
windowDecorByTaskIdSpy,
mockInteractionJankMonitor,
Optional.of(mockTasksLimiter),
- Optional.of(mockActivityOrientationChangeHandler)
+ Optional.of(mockActivityOrientationChangeHandler),
+ mockTaskPositionerFactory
)
desktopModeWindowDecorViewModel.setSplitScreenController(mockSplitScreenController)
whenever(mockDisplayController.getDisplayLayout(any())).thenReturn(mockDisplayLayout)
whenever(mockDisplayLayout.stableInsets()).thenReturn(STABLE_INSETS)
whenever(mockInputMonitorFactory.create(any(), any())).thenReturn(mockInputMonitor)
+ whenever(mockTaskPositionerFactory.create(any(), any(), any(), any(), any(), any(), any()))
+ .thenReturn(mockTaskPositioner)
doReturn(mockToast).`when` { Toast.makeText(any(), anyInt(), anyInt()) }
@@ -1058,6 +1069,55 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() {
verify(wct, never()).setBounds(eq(thirdTask.token), any())
}
+ @Test
+ fun testCloseButtonInFreeform_closeWindow_ignoreMoveEventsWithoutBoundsChange() {
+ val onClickListenerCaptor = forClass(View.OnClickListener::class.java)
+ as ArgumentCaptor<View.OnClickListener>
+ val onTouchListenerCaptor = forClass(View.OnTouchListener::class.java)
+ as ArgumentCaptor<View.OnTouchListener>
+ val decor = createOpenTaskDecoration(
+ windowingMode = WINDOWING_MODE_FREEFORM,
+ onCaptionButtonClickListener = onClickListenerCaptor,
+ onCaptionButtonTouchListener = onTouchListenerCaptor
+ )
+
+ whenever(mockTaskPositioner.onDragPositioningStart(any(), any(), any()))
+ .thenReturn(INITIAL_BOUNDS)
+ whenever(mockTaskPositioner.onDragPositioningMove(any(), any()))
+ .thenReturn(INITIAL_BOUNDS)
+ whenever(mockTaskPositioner.onDragPositioningEnd(any(), any()))
+ .thenReturn(INITIAL_BOUNDS)
+
+ val view = mock(View::class.java)
+ whenever(view.id).thenReturn(R.id.close_window)
+ val viewRootImpl = mock(ViewRootImpl::class.java)
+ whenever(view.getViewRootImpl()).thenReturn(viewRootImpl)
+ whenever(viewRootImpl.getInputToken()).thenReturn(null)
+
+ desktopModeWindowDecorViewModel
+ .setFreeformTaskTransitionStarter(mockFreeformTaskTransitionStarter)
+
+ onTouchListenerCaptor.value.onTouch(view,
+ MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
+ MotionEvent.ACTION_DOWN, /* x= */ 0f, /* y= */ 0f, /* metaState= */ 0))
+ onTouchListenerCaptor.value.onTouch(view,
+ MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
+ MotionEvent.ACTION_MOVE, /* x= */ 0f, /* y= */ 0f, /* metaState= */ 0))
+ onTouchListenerCaptor.value.onTouch(view,
+ MotionEvent.obtain(SystemClock.uptimeMillis(), SystemClock.uptimeMillis(),
+ MotionEvent.ACTION_UP, /* x= */ 0f, /* y= */ 0f, /* metaState= */ 0))
+ onClickListenerCaptor.value.onClick(view)
+
+ val transactionCaptor = argumentCaptor<WindowContainerTransaction>()
+ verify(mockFreeformTaskTransitionStarter).startRemoveTransition(transactionCaptor.capture())
+ val wct = transactionCaptor.firstValue
+
+ assertEquals(1, wct.getHierarchyOps().size)
+ assertEquals(HierarchyOp.HIERARCHY_OP_TYPE_REMOVE_TASK,
+ wct.getHierarchyOps().get(0).getType())
+ assertEquals(decor.mTaskInfo.token.asBinder(), wct.getHierarchyOps().get(0).getContainer())
+ }
+
private fun createOpenTaskDecoration(
@WindowingMode windowingMode: Int,
taskSurface: SurfaceControl = SurfaceControl(),
@@ -1076,7 +1136,9 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() {
onOpenInBrowserClickListener: ArgumentCaptor<Consumer<Uri>> =
forClass(Consumer::class.java) as ArgumentCaptor<Consumer<Uri>>,
onCaptionButtonClickListener: ArgumentCaptor<View.OnClickListener> =
- forClass(View.OnClickListener::class.java) as ArgumentCaptor<View.OnClickListener>
+ forClass(View.OnClickListener::class.java) as ArgumentCaptor<View.OnClickListener>,
+ onCaptionButtonTouchListener: ArgumentCaptor<View.OnTouchListener> =
+ forClass(View.OnTouchListener::class.java) as ArgumentCaptor<View.OnTouchListener>
): DesktopModeWindowDecoration {
val decor = setUpMockDecorationForTask(createTask(windowingMode = windowingMode))
onTaskOpening(decor.mTaskInfo, taskSurface)
@@ -1088,7 +1150,8 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() {
verify(decor).setOnToSplitScreenClickListener(onToSplitScreenClickListenerCaptor.capture())
verify(decor).setOpenInBrowserClickListener(onOpenInBrowserClickListener.capture())
verify(decor).setCaptionListeners(
- onCaptionButtonClickListener.capture(), any(), any(), any())
+ onCaptionButtonClickListener.capture(), onCaptionButtonTouchListener.capture(),
+ any(), any())
return decor
}
@@ -1175,5 +1238,6 @@ class DesktopModeWindowDecorViewModelTests : ShellTestCase() {
companion object {
private const val TAG = "DesktopModeWindowDecorViewModelTests"
private val STABLE_INSETS = Rect(0, 100, 0, 0)
+ private val INITIAL_BOUNDS = Rect(0, 0, 100, 100)
}
}
diff --git a/libs/hwui/FeatureFlags.h b/libs/hwui/FeatureFlags.h
index c0cedf12c0ae..fddcf29b9197 100644
--- a/libs/hwui/FeatureFlags.h
+++ b/libs/hwui/FeatureFlags.h
@@ -25,14 +25,6 @@ namespace android {
namespace text_feature {
-inline bool deprecate_ui_fonts() {
-#ifdef __ANDROID__
- return com_android_text_flags_deprecate_ui_fonts();
-#else
- return true;
-#endif // __ANDROID__
-}
-
inline bool letter_spacing_justification() {
#ifdef __ANDROID__
return com_android_text_flags_letter_spacing_justification();
diff --git a/libs/hwui/hwui/MinikinUtils.cpp b/libs/hwui/hwui/MinikinUtils.cpp
index d66d7f8e83f4..ede385adc779 100644
--- a/libs/hwui/hwui/MinikinUtils.cpp
+++ b/libs/hwui/hwui/MinikinUtils.cpp
@@ -53,9 +53,7 @@ minikin::MinikinPaint MinikinUtils::prepareMinikinPaint(const Paint* paint,
if (familyVariant.has_value()) {
minikinPaint.familyVariant = familyVariant.value();
} else {
- minikinPaint.familyVariant = text_feature::deprecate_ui_fonts()
- ? minikin::FamilyVariant::ELEGANT
- : minikin::FamilyVariant::DEFAULT;
+ minikinPaint.familyVariant = minikin::FamilyVariant::ELEGANT;
}
return minikinPaint;
}
diff --git a/libs/hwui/renderthread/CanvasContext.cpp b/libs/hwui/renderthread/CanvasContext.cpp
index dfda25d013ed..8ec04304a808 100644
--- a/libs/hwui/renderthread/CanvasContext.cpp
+++ b/libs/hwui/renderthread/CanvasContext.cpp
@@ -654,6 +654,9 @@ void CanvasContext::draw(bool solelyTextureViewUpdates) {
if (vsyncId != UiFrameInfoBuilder::INVALID_VSYNC_ID) {
const auto inputEventId =
static_cast<int32_t>(mCurrentFrameInfo->get(FrameInfoIndex::InputEventId));
+ ATRACE_FORMAT(
+ "frameTimelineInfo(frameNumber=%llu, vsyncId=%lld, inputEventId=0x%" PRIx32 ")",
+ frameCompleteNr, vsyncId, inputEventId);
const ANativeWindowFrameTimelineInfo ftl = {
.frameNumber = frameCompleteNr,
.frameTimelineVsyncId = vsyncId,
diff --git a/location/java/android/location/flags/location.aconfig b/location/java/android/location/flags/location.aconfig
index 3c387d33286a..bbd91fc19ee5 100644
--- a/location/java/android/location/flags/location.aconfig
+++ b/location/java/android/location/flags/location.aconfig
@@ -109,3 +109,11 @@ flag {
description: "Flag for GNSS configuration from resource"
bug: "317734846"
}
+
+flag {
+ name: "enable_ni_supl_message_injection_by_carrier_config"
+ namespace: "location"
+ description: "Flag for enabling NI SUPL message injection by carrier config"
+ bug: "242105192"
+ is_fixed_read_only: true
+}
diff --git a/nfc/java/android/nfc/cardemulation/ApduServiceInfo.java b/nfc/java/android/nfc/cardemulation/ApduServiceInfo.java
index ea5a03613ddc..b28237cb0fbc 100644
--- a/nfc/java/android/nfc/cardemulation/ApduServiceInfo.java
+++ b/nfc/java/android/nfc/cardemulation/ApduServiceInfo.java
@@ -69,6 +69,29 @@ public final class ApduServiceInfo implements Parcelable {
private static final String TAG = "ApduServiceInfo";
/**
+ * Component level {@link android.content.pm.PackageManager.Property PackageManager
+ * .Property} for a system application to change its icon and label
+ * on the default applications page. This property should be added to an
+ * {@link HostApduService} declaration in the manifest.
+ *
+ * <p>For example:
+ * <pre>
+ * &lt;service
+ * android:apduServiceBanner="@drawable/product_logo"
+ * android:label="@string/service_label"&gt
+ * &lt;property
+ * android:name="android.content.PROPERTY_WALLET_ICON_AND_LABEL_HOLDER"
+ * android:value="true"/&gt;
+ * &lt/service&gt;
+ * </pre>
+ * @hide
+ */
+ @SystemApi
+ @FlaggedApi(android.permission.flags.Flags.FLAG_WALLET_ROLE_ICON_PROPERTY_ENABLED)
+ public static final String PROPERTY_WALLET_PREFERRED_BANNER_AND_LABEL =
+ "android.nfc.cardemulation.PROPERTY_WALLET_PREFERRED_BANNER_AND_LABEL";
+
+ /**
* The service that implements this
*/
private final ResolveInfo mService;
diff --git a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
index 3409c29d3c2c..defbc1142adb 100644
--- a/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
+++ b/packages/ExternalStorageProvider/src/com/android/externalstorage/ExternalStorageProvider.java
@@ -16,8 +16,6 @@
package com.android.externalstorage;
-import static java.util.regex.Pattern.CASE_INSENSITIVE;
-
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.usage.StorageStatsManager;
@@ -61,12 +59,15 @@ import java.io.FileDescriptor;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.PrintWriter;
+import java.nio.file.Files;
+import java.nio.file.Paths;
+import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Objects;
import java.util.UUID;
-import java.util.regex.Pattern;
+import java.util.stream.Collectors;
/**
* Presents content of the shared (a.k.a. "external") storage.
@@ -89,12 +90,9 @@ public class ExternalStorageProvider extends FileSystemProvider {
private static final Uri BASE_URI =
new Uri.Builder().scheme(ContentResolver.SCHEME_CONTENT).authority(AUTHORITY).build();
- /**
- * Regex for detecting {@code /Android/data/}, {@code /Android/obb/} and
- * {@code /Android/sandbox/} along with all their subdirectories and content.
- */
- private static final Pattern PATTERN_RESTRICTED_ANDROID_SUBTREES =
- Pattern.compile("^Android/(?:data|obb|sandbox)(?:/.+)?", CASE_INSENSITIVE);
+ private static final String PRIMARY_EMULATED_STORAGE_PATH = "/storage/emulated/";
+
+ private static final String STORAGE_PATH = "/storage/";
private static final String[] DEFAULT_ROOT_PROJECTION = new String[] {
Root.COLUMN_ROOT_ID, Root.COLUMN_FLAGS, Root.COLUMN_ICON, Root.COLUMN_TITLE,
@@ -309,11 +307,70 @@ public class ExternalStorageProvider extends FileSystemProvider {
return false;
}
- final String path = getPathFromDocId(documentId);
- return PATTERN_RESTRICTED_ANDROID_SUBTREES.matcher(path).matches();
+ try {
+ final RootInfo root = getRootFromDocId(documentId);
+ final String canonicalPath = getPathFromDocId(documentId);
+ return isRestrictedPath(root.rootId, canonicalPath);
+ } catch (Exception e) {
+ return true;
+ }
}
/**
+ * Based on the given root id and path, we restrict path access if file is Android/data or
+ * Android/obb or Android/sandbox or one of their subdirectories.
+ *
+ * @param canonicalPath of the file
+ * @return true if path is restricted
+ */
+ private boolean isRestrictedPath(String rootId, String canonicalPath) {
+ if (rootId == null || canonicalPath == null) {
+ return true;
+ }
+
+ final String rootPath;
+ if (rootId.equalsIgnoreCase(ROOT_ID_PRIMARY_EMULATED)) {
+ // Creates "/storage/emulated/<user-id>"
+ rootPath = PRIMARY_EMULATED_STORAGE_PATH + UserHandle.myUserId();
+ } else {
+ // Creates "/storage/<volume-uuid>"
+ rootPath = STORAGE_PATH + rootId;
+ }
+ List<java.nio.file.Path> restrictedPathList = Arrays.asList(
+ Paths.get(rootPath, "Android", "data"),
+ Paths.get(rootPath, "Android", "obb"),
+ Paths.get(rootPath, "Android", "sandbox"));
+ // We need to identify restricted parent paths which actually exist on the device
+ List<java.nio.file.Path> validRestrictedPathsToCheck = restrictedPathList.stream().filter(
+ Files::exists).collect(Collectors.toList());
+
+ boolean isRestricted = false;
+ java.nio.file.Path filePathToCheck = Paths.get(rootPath, canonicalPath);
+ try {
+ while (filePathToCheck != null) {
+ for (java.nio.file.Path restrictedPath : validRestrictedPathsToCheck) {
+ if (Files.isSameFile(restrictedPath, filePathToCheck)) {
+ isRestricted = true;
+ Log.v(TAG, "Restricting access for path: " + filePathToCheck);
+ break;
+ }
+ }
+ if (isRestricted) {
+ break;
+ }
+
+ filePathToCheck = filePathToCheck.getParent();
+ }
+ } catch (Exception e) {
+ Log.w(TAG, "Error in checking file equality check.", e);
+ isRestricted = true;
+ }
+
+ return isRestricted;
+ }
+
+
+ /**
* Check that the directory is the root of storage or blocked file from tree.
* <p>
* Note, that this is different from hidden documents: blocked documents <b>WILL</b> appear
diff --git a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
index 81f7315dd422..fe27cee7ba2d 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/model/PageContentRepository.java
@@ -654,52 +654,49 @@ public final class PageContentRepository {
public void renderPage(int pageIndex, RenderSpec renderSpec,
OnPageContentAvailableCallback callback) {
- // First, check if we have a rendered page for this index.
- RenderedPage renderedPage = mPageContentCache.getRenderedPage(pageIndex);
- if (renderedPage != null && renderedPage.state == RenderedPage.STATE_RENDERED) {
- // If we have rendered page with same constraints - done.
- if (renderedPage.renderSpec.equals(renderSpec)) {
- if (DEBUG) {
- Log.i(LOG_TAG, "Cache hit for page: " + pageIndex);
- }
+ synchronized (mPageToRenderTaskMap) {
+ RenderedPage renderedPage = mPageContentCache.getRenderedPage(pageIndex);
+ if (renderedPage != null && renderedPage.state == RenderedPage.STATE_RENDERED) {
+ // If we have rendered page with same constraints - done.
+ if (renderedPage.renderSpec.equals(renderSpec)) {
+ if (DEBUG) {
+ Log.i(LOG_TAG, "Cache hit for page: " + pageIndex);
+ }
- // Announce if needed.
- if (callback != null) {
- callback.onPageContentAvailable(renderedPage.content);
+ // Announce if needed.
+ if (callback != null) {
+ callback.onPageContentAvailable(renderedPage.content);
+ }
+ return;
+ } else {
+ // If the constraints changed, mark the page obsolete.
+ renderedPage.state = RenderedPage.STATE_SCRAP;
}
- return;
- } else {
- // If the constraints changed, mark the page obsolete.
- renderedPage.state = RenderedPage.STATE_SCRAP;
}
- }
- // Next, check if rendering this page is scheduled.
- RenderPageTask renderTask = mPageToRenderTaskMap.get(pageIndex);
- if (renderTask != null && !renderTask.isCancelled()) {
- // If not rendered and constraints same....
- if (renderTask.mRenderSpec.equals(renderSpec)) {
- if (renderTask.mCallback != null) {
- // If someone else is already waiting for this page - bad state.
- if (callback != null && renderTask.mCallback != callback) {
- throw new IllegalStateException("Page rendering not cancelled");
- }
- } else {
- // No callback means we are preloading so just let the argument
- // callback be attached to our work in progress.
+ // Next, check if rendering this page is scheduled.
+ RenderPageTask renderTask = mPageToRenderTaskMap.get(pageIndex);
+ if (renderTask != null && !renderTask.isCancelled()) {
+ // If not rendered and constraints same....
+ if (renderTask.mRenderSpec.equals(renderSpec)) {
renderTask.mCallback = callback;
+ return;
+ } else {
+ // If not rendered and constraints changed - cancel rendering.
+ try {
+ renderTask.cancel(true);
+ mPageToRenderTaskMap.remove(pageIndex);
+ } catch (Exception e) {
+ Log.e(LOG_TAG, "Error cancelling RenderPageTask ", e);
+ }
}
- return;
- } else {
- // If not rendered and constraints changed - cancel rendering.
- renderTask.cancel(true);
}
- }
- // Oh well, we will have work to do...
- renderTask = new RenderPageTask(pageIndex, renderSpec, callback);
- mPageToRenderTaskMap.put(pageIndex, renderTask);
- renderTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
+ // Oh well, we will have work to do...
+ renderTask = new RenderPageTask(pageIndex, renderSpec, callback);
+ mPageToRenderTaskMap.put(pageIndex, renderTask);
+ renderTask.executeOnExecutor(AsyncTask.SERIAL_EXECUTOR);
+ }
}
public void cancelRendering(int pageIndex) {
diff --git a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
index ff09084e24cd..c4173ed999f3 100644
--- a/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
+++ b/packages/PrintSpooler/src/com/android/printspooler/ui/PrintActivity.java
@@ -460,7 +460,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
- if (keyCode == KeyEvent.KEYCODE_BACK) {
+ if (keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE) {
event.startTracking();
return true;
}
@@ -479,7 +479,7 @@ public class PrintActivity extends Activity implements RemotePrintDocument.Updat
return true;
}
- if (keyCode == KeyEvent.KEYCODE_BACK
+ if ((keyCode == KeyEvent.KEYCODE_BACK || keyCode == KeyEvent.KEYCODE_ESCAPE)
&& event.isTracking() && !event.isCanceled()) {
if (mPrintPreviewController != null && mPrintPreviewController.isOptionsOpened()
&& !hasErrors()) {
diff --git a/packages/SettingsLib/Android.bp b/packages/SettingsLib/Android.bp
index 0cb85d8638b0..b997c35668d2 100644
--- a/packages/SettingsLib/Android.bp
+++ b/packages/SettingsLib/Android.bp
@@ -42,6 +42,8 @@ android_library {
"SettingsLibIllustrationPreference",
"SettingsLibLayoutPreference",
"SettingsLibMainSwitchPreference",
+ "SettingsLibMetadata",
+ "SettingsLibPreference",
"SettingsLibProfileSelector",
"SettingsLibProgressBar",
"SettingsLibRestrictedLockUtils",
diff --git a/packages/SettingsLib/Preference/Android.bp b/packages/SettingsLib/Preference/Android.bp
index 9665dbd17e2d..17852e8e7ece 100644
--- a/packages/SettingsLib/Preference/Android.bp
+++ b/packages/SettingsLib/Preference/Android.bp
@@ -18,6 +18,7 @@ android_library {
"SettingsLibMetadata",
"androidx.annotation_annotation",
"androidx.preference_preference",
+ "guava",
],
kotlincflags: ["-Xjvm-default=all"],
}
diff --git a/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceFragment.kt b/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceFragment.kt
index 207200998b05..68f640bbb9b4 100644
--- a/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceFragment.kt
+++ b/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceFragment.kt
@@ -79,7 +79,7 @@ open class PreferenceFragment :
* This is for flagging purpose. If false (e.g. flag is disabled), xml resource is used to build
* preference screen.
*/
- protected open fun usePreferenceScreenMetadata(): Boolean = true
+ protected open fun usePreferenceScreenMetadata(): Boolean = false
/** Returns the xml resource to create preference screen. */
@XmlRes protected open fun getPreferenceScreenResId(context: Context): Int = 0
diff --git a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/preference/MainSwitchPreference.kt b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/preference/MainSwitchPreference.kt
index 0a469b868562..b28e88eb8af8 100644
--- a/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/preference/MainSwitchPreference.kt
+++ b/packages/SettingsLib/Spa/spa/src/com/android/settingslib/spa/widget/preference/MainSwitchPreference.kt
@@ -18,6 +18,7 @@ package com.android.settingslib.spa.widget.preference
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.padding
+import androidx.compose.foundation.shape.CircleShape
import androidx.compose.material3.MaterialTheme
import androidx.compose.material3.Surface
import androidx.compose.runtime.Composable
@@ -27,6 +28,7 @@ import androidx.compose.ui.unit.dp
import com.android.settingslib.spa.framework.theme.SettingsDimension
import com.android.settingslib.spa.framework.theme.SettingsShape
import com.android.settingslib.spa.framework.theme.SettingsTheme
+import com.android.settingslib.spa.framework.theme.isSpaExpressiveEnabled
import com.android.settingslib.spa.framework.util.EntryHighlight
@Composable
@@ -38,16 +40,17 @@ fun MainSwitchPreference(model: SwitchPreferenceModel) {
true -> MaterialTheme.colorScheme.primaryContainer
else -> MaterialTheme.colorScheme.secondaryContainer
},
- shape = SettingsShape.CornerExtraLarge,
+ shape = if (isSpaExpressiveEnabled) CircleShape
+ else SettingsShape.CornerExtraLarge,
) {
InternalSwitchPreference(
title = model.title,
checked = model.checked(),
changeable = model.changeable(),
onCheckedChange = model.onCheckedChange,
- paddingStart = 20.dp,
+ paddingStart = if (isSpaExpressiveEnabled) 32.dp else 20.dp,
paddingEnd = 20.dp,
- paddingVertical = 24.dp,
+ paddingVertical = if (isSpaExpressiveEnabled) 16.dp else 24.dp,
)
}
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservablePreferenceFragment.java b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservablePreferenceFragment.java
index bd1e5a588968..79949248cd8a 100644
--- a/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservablePreferenceFragment.java
+++ b/packages/SettingsLib/src/com/android/settingslib/core/lifecycle/ObservablePreferenceFragment.java
@@ -31,13 +31,14 @@ import android.view.MenuInflater;
import android.view.MenuItem;
import androidx.lifecycle.LifecycleOwner;
-import androidx.preference.PreferenceFragmentCompat;
import androidx.preference.PreferenceScreen;
+import com.android.settingslib.preference.PreferenceFragment;
+
/**
- * {@link PreferenceFragmentCompat} that has hooks to observe fragment lifecycle events.
+ * Preference fragment that has hooks to observe fragment lifecycle events.
*/
-public abstract class ObservablePreferenceFragment extends PreferenceFragmentCompat
+public abstract class ObservablePreferenceFragment extends PreferenceFragment
implements LifecycleOwner {
private final Lifecycle mLifecycle = new Lifecycle(this);
diff --git a/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt b/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt
index 3e2d8328f21e..d3c345deebad 100644
--- a/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt
+++ b/packages/SettingsLib/src/com/android/settingslib/volume/data/repository/AudioRepository.kt
@@ -98,7 +98,7 @@ interface AudioRepository {
*/
suspend fun setMuted(audioStream: AudioStream, isMuted: Boolean): Boolean
- suspend fun setRingerMode(audioStream: AudioStream, mode: RingerMode)
+ suspend fun setRingerModeInternal(audioStream: AudioStream, mode: RingerMode)
/** Gets audio device category. */
@AudioDeviceCategory suspend fun getBluetoothAudioDeviceCategory(bluetoothAddress: String): Int
@@ -248,8 +248,8 @@ class AudioRepositoryImpl(
}
}
- override suspend fun setRingerMode(audioStream: AudioStream, mode: RingerMode) {
- withContext(backgroundCoroutineContext) { audioManager.ringerMode = mode.value }
+ override suspend fun setRingerModeInternal(audioStream: AudioStream, mode: RingerMode) {
+ withContext(backgroundCoroutineContext) { audioManager.ringerModeInternal = mode.value }
}
@AudioDeviceCategory
diff --git a/packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt b/packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt
index 08863b56cbe0..dca890d34bc0 100644
--- a/packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt
+++ b/packages/SettingsLib/src/com/android/settingslib/volume/domain/interactor/AudioVolumeInteractor.kt
@@ -68,7 +68,7 @@ class AudioVolumeInteractor(
if (audioStream.value == AudioManager.STREAM_RING) {
val mode =
if (isMuted) AudioManager.RINGER_MODE_VIBRATE else AudioManager.RINGER_MODE_NORMAL
- audioRepository.setRingerMode(audioStream, RingerMode(mode))
+ audioRepository.setRingerModeInternal(audioStream, RingerMode(mode))
}
val mutedChanged = audioRepository.setMuted(audioStream, isMuted)
if (mutedChanged && !isMuted) {
diff --git a/packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioRepositoryTest.kt b/packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioRepositoryTest.kt
index 52e639172af5..8a3b1dfb0846 100644
--- a/packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioRepositoryTest.kt
+++ b/packages/SettingsLib/tests/integ/src/com/android/settingslib/volume/data/repository/AudioRepositoryTest.kt
@@ -74,6 +74,8 @@ class AudioRepositoryTest {
private lateinit var underTest: AudioRepository
+ private var ringerModeInternal: RingerMode = RingerMode(AudioManager.RINGER_MODE_NORMAL)
+
@Before
fun setup() {
MockitoAnnotations.initMocks(this)
@@ -82,7 +84,7 @@ class AudioRepositoryTest {
`when`(audioManager.communicationDevice).thenReturn(communicationDevice)
`when`(audioManager.getStreamMinVolume(anyInt())).thenReturn(MIN_VOLUME)
`when`(audioManager.getStreamMaxVolume(anyInt())).thenReturn(MAX_VOLUME)
- `when`(audioManager.ringerModeInternal).thenReturn(AudioManager.RINGER_MODE_NORMAL)
+ `when`(audioManager.ringerModeInternal).then { ringerModeInternal.value }
`when`(audioManager.setStreamVolume(anyInt(), anyInt(), anyInt())).then {
val streamType = it.arguments[0] as Int
volumeByStream[it.arguments[0] as Int] = it.arguments[1] as Int
@@ -103,6 +105,10 @@ class AudioRepositoryTest {
`when`(audioManager.isStreamMute(anyInt())).thenAnswer {
isMuteByStream.getOrDefault(it.arguments[0] as Int, false)
}
+ `when`(audioManager.setRingerModeInternal(anyInt())).then {
+ ringerModeInternal = RingerMode(it.arguments[0] as Int)
+ Unit
+ }
underTest =
AudioRepositoryImpl(
@@ -137,7 +143,7 @@ class AudioRepositoryTest {
underTest.ringerMode.onEach { modes.add(it) }.launchIn(backgroundScope)
runCurrent()
- `when`(audioManager.ringerModeInternal).thenReturn(AudioManager.RINGER_MODE_SILENT)
+ ringerModeInternal = RingerMode(AudioManager.RINGER_MODE_SILENT)
triggerEvent(AudioManagerEvent.InternalRingerModeChanged)
runCurrent()
@@ -150,6 +156,19 @@ class AudioRepositoryTest {
}
@Test
+ fun changingRingerMode_changesRingerModeInternal() {
+ testScope.runTest {
+ underTest.setRingerModeInternal(
+ AudioStream(AudioManager.STREAM_SYSTEM),
+ RingerMode(AudioManager.RINGER_MODE_SILENT),
+ )
+ runCurrent()
+
+ assertThat(ringerModeInternal).isEqualTo(RingerMode(AudioManager.RINGER_MODE_SILENT))
+ }
+ }
+
+ @Test
fun communicationDeviceChanges_repositoryEmits() {
testScope.runTest {
var device: AudioDeviceInfo? = null
diff --git a/packages/SystemUI/Android.bp b/packages/SystemUI/Android.bp
index d26a9066e075..a9e81c77acad 100644
--- a/packages/SystemUI/Android.bp
+++ b/packages/SystemUI/Android.bp
@@ -756,6 +756,7 @@ android_library {
"notification_flags_lib",
"PlatformComposeCore",
"PlatformComposeSceneTransitionLayout",
+ "PlatformComposeSceneTransitionLayoutTestsUtils",
"androidx.compose.runtime_runtime",
"androidx.compose.material3_material3",
"androidx.compose.material_material-icons-extended",
diff --git a/packages/SystemUI/aconfig/systemui.aconfig b/packages/SystemUI/aconfig/systemui.aconfig
index 892f778ff8c0..ad14035d9d0a 100644
--- a/packages/SystemUI/aconfig/systemui.aconfig
+++ b/packages/SystemUI/aconfig/systemui.aconfig
@@ -288,6 +288,16 @@ flag {
}
flag {
+ name: "qs_quick_rebind_active_tiles"
+ namespace: "systemui"
+ description: "Rebind active custom tiles quickly."
+ bug: "362526228"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "coroutine_tracing"
namespace: "systemui"
description: "Adds thread-local data to System UI's global coroutine scopes to "
@@ -606,16 +616,6 @@ flag {
}
flag {
- name: "screenshot_save_image_exporter"
- namespace: "systemui"
- description: "Save all screenshots using ImageExporter"
- bug: "352308052"
- metadata {
- purpose: PURPOSE_BUGFIX
- }
-}
-
-flag {
name: "screenshot_ui_controller_refactor"
namespace: "systemui"
description: "Simplify and refactor ScreenshotController"
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt b/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt
index 7fb88e8d1fcc..ae92d259d62b 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/BouncerScene.kt
@@ -99,8 +99,8 @@ private fun SceneScope.BouncerScene(
BouncerContent(
viewModel,
dialogFactory,
- Modifier.sysuiResTag(Bouncer.TestTags.Root)
- .element(Bouncer.Elements.Content)
+ Modifier.element(Bouncer.Elements.Content)
+ .sysuiResTag(Bouncer.TestTags.Root)
.fillMaxSize()
)
}
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/PinInputDisplay.kt b/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/PinInputDisplay.kt
index ba885f7da2cf..1f98cd8e07c0 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/PinInputDisplay.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/bouncer/ui/composable/PinInputDisplay.kt
@@ -65,7 +65,6 @@ import androidx.compose.ui.res.stringResource
import androidx.compose.ui.unit.Constraints
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
-import androidx.compose.ui.window.Dialog
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.compose.PlatformOutlinedButton
import com.android.compose.animation.Easings
@@ -355,7 +354,10 @@ private class PinInputRow(
fun Content(modifier: Modifier) {
// Wrap PIN entry in a Box so it is visible to accessibility (even if empty).
- Box(modifier = modifier.fillMaxWidth().wrapContentHeight()) {
+ Box(
+ modifier = modifier.fillMaxWidth().wrapContentHeight(),
+ contentAlignment = Alignment.Center,
+ ) {
Row(
modifier
.heightIn(min = shapeAnimations.shapeSize)
diff --git a/packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/TextExt.kt b/packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/TextExt.kt
index e1f73e304b9e..4e8121f14e4b 100644
--- a/packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/TextExt.kt
+++ b/packages/SystemUI/compose/features/src/com/android/systemui/common/ui/compose/TextExt.kt
@@ -17,9 +17,12 @@
package com.android.systemui.common.ui.compose
+import android.content.Context
import androidx.compose.runtime.Composable
import androidx.compose.ui.res.stringResource
+import androidx.compose.ui.text.AnnotatedString
import com.android.systemui.common.shared.model.Text
+import com.android.systemui.common.shared.model.Text.Companion.loadText
/** Returns the loaded [String] or `null` if there isn't one. */
@Composable
@@ -29,3 +32,7 @@ fun Text.load(): String? {
is Text.Resource -> stringResource(res)
}
}
+
+fun Text.toAnnotatedString(context: Context): AnnotatedString? {
+ return loadText(context)?.let { AnnotatedString(it) }
+}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt
index b30f2b7002ce..0fc88b22a4d0 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/AnimateSharedAsState.kt
@@ -121,7 +121,7 @@ fun ContentScope.animateContentFloatAsState(
@Deprecated(
"Use animateContentFloatAsState() instead",
- replaceWith = ReplaceWith("animateContentFloatAsState(value, key, canOverflow)")
+ replaceWith = ReplaceWith("animateContentFloatAsState(value, key, canOverflow)"),
)
@Composable
fun ContentScope.animateSceneFloatAsState(
@@ -172,14 +172,11 @@ fun ContentScope.animateContentDpAsState(
@Deprecated(
"Use animateContentDpAsState() instead",
- replaceWith = ReplaceWith("animateContentDpAsState(value, key, canOverflow)")
+ replaceWith = ReplaceWith("animateContentDpAsState(value, key, canOverflow)"),
)
@Composable
-fun ContentScope.animateSceneDpAsState(
- value: Dp,
- key: ValueKey,
- canOverflow: Boolean = true,
-) = animateContentDpAsState(value, key, canOverflow)
+fun ContentScope.animateSceneDpAsState(value: Dp, key: ValueKey, canOverflow: Boolean = true) =
+ animateContentDpAsState(value, key, canOverflow)
/**
* Animate a shared element Dp value.
@@ -214,10 +211,7 @@ private object SharedDpType : SharedValueType<Dp, Dp> {
* @see ContentScope.animateContentValueAsState
*/
@Composable
-fun ContentScope.animateContentColorAsState(
- value: Color,
- key: ValueKey,
-): AnimatedState<Color> {
+fun ContentScope.animateContentColorAsState(value: Color, key: ValueKey): AnimatedState<Color> {
return animateContentValueAsState(value, key, SharedColorType, canOverflow = false)
}
@@ -227,10 +221,7 @@ fun ContentScope.animateContentColorAsState(
* @see ElementScope.animateElementValueAsState
*/
@Composable
-fun ElementScope<*>.animateElementColorAsState(
- value: Color,
- key: ValueKey,
-): AnimatedState<Color> {
+fun ElementScope<*>.animateElementColorAsState(value: Color, key: ValueKey): AnimatedState<Color> {
return animateElementValueAsState(value, key, SharedColorType, canOverflow = false)
}
@@ -274,12 +265,7 @@ private object SharedColorType : SharedValueType<Color, ColorDelta> {
* Note: This class is necessary because Color() checks the bounds of its values and UncheckedColor
* is internal.
*/
-private class ColorDelta(
- val red: Float,
- val green: Float,
- val blue: Float,
- val alpha: Float,
-)
+private class ColorDelta(val red: Float, val green: Float, val blue: Float, val alpha: Float)
@Composable
internal fun <T> animateSharedValueAsState(
@@ -331,7 +317,7 @@ internal fun <T> animateSharedValueAsState(
private fun <T, Delta> sharedValue(
layoutImpl: SceneTransitionLayoutImpl,
key: ValueKey,
- element: ElementKey?
+ element: ElementKey?,
): SharedValue<T, Delta> {
return layoutImpl.sharedValues[key]?.get(element)?.let { it as SharedValue<T, Delta> }
?: error(valueReadTooEarlyMessage(key))
@@ -342,9 +328,7 @@ private fun valueReadTooEarlyMessage(key: ValueKey) =
"means that you are reading it during composition, which you should not do. See the " +
"documentation of AnimatedState for more information."
-internal class SharedValue<T, Delta>(
- val type: SharedValueType<T, Delta>,
-) {
+internal class SharedValue<T, Delta>(val type: SharedValueType<T, Delta>) {
/** The target value of this shared value for each content. */
val targetValues = SnapshotStateMap<ContentKey, T>()
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
index 007b84a2954a..f38a31026664 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/DraggableHandler.kt
@@ -109,12 +109,12 @@ internal class DraggableHandlerImpl(
return (upOrLeft != null &&
contentTransition.isTransitioningBetween(
fromContent.key,
- upOrLeft.toContent(currentScene)
+ upOrLeft.toContent(currentScene),
)) ||
(downOrRight != null &&
contentTransition.isTransitioningBetween(
fromContent.key,
- downOrRight.toContent(currentScene)
+ downOrRight.toContent(currentScene),
))
}
@@ -163,7 +163,7 @@ internal class DraggableHandlerImpl(
private fun updateDragController(
swipes: Swipes,
- swipeAnimation: SwipeAnimation<*>
+ swipeAnimation: SwipeAnimation<*>,
): DragControllerImpl {
val newDragController = DragControllerImpl(this, swipes, swipeAnimation)
newDragController.updateTransition(swipeAnimation, force = true)
@@ -171,10 +171,7 @@ internal class DraggableHandlerImpl(
return newDragController
}
- internal fun createSwipeAnimation(
- swipes: Swipes,
- result: UserActionResult,
- ): SwipeAnimation<*> {
+ internal fun createSwipeAnimation(swipes: Swipes, result: UserActionResult): SwipeAnimation<*> {
val upOrLeftResult = swipes.upOrLeftResult
val downOrRightResult = swipes.downOrRightResult
val isUpOrLeft =
@@ -266,7 +263,7 @@ private class DragControllerImpl(
layoutState.startTransitionImmediately(
animationScope = draggableHandler.layoutImpl.animationScope,
newTransition.contentTransition,
- true
+ true,
)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Element.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Element.kt
index a076f22a74d7..1061cc4f5989 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Element.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Element.kt
@@ -263,7 +263,7 @@ internal class ElementNode(
@ExperimentalComposeUiApi
override fun MeasureScope.measure(
measurable: Measurable,
- constraints: Constraints
+ constraints: Constraints,
): MeasureResult {
check(isLookingAhead)
@@ -344,7 +344,7 @@ internal class ElementNode(
private fun ApproachMeasureScope.doNotPlace(
measurable: Measurable,
- constraints: Constraints
+ constraints: Constraints,
): MeasureResult {
recursivelyClearPlacementValues()
stateInContent.lastSize = Element.SizeUnspecified
@@ -355,7 +355,7 @@ internal class ElementNode(
private fun ApproachMeasureScope.placeNormally(
measurable: Measurable,
- constraints: Constraints
+ constraints: Constraints,
): MeasureResult {
val placeable = measurable.measure(constraints)
stateInContent.lastSize = placeable.size()
@@ -670,10 +670,7 @@ private fun prepareInterruption(
* Reconcile the state of [element] in the formContent and toContent of [transition] so that the
* values before interruption have their expected values, taking shared transitions into account.
*/
-private fun reconcileStates(
- element: Element,
- transition: TransitionState.Transition,
-) {
+private fun reconcileStates(element: Element, transition: TransitionState.Transition) {
val fromContentState = element.stateByContent[transition.fromContent] ?: return
val toContentState = element.stateByContent[transition.toContent] ?: return
if (!isSharedElementEnabled(element.key, transition)) {
@@ -1139,7 +1136,7 @@ private fun ContentDrawScope.getDrawScale(
Offset.Unspecified
} else {
a.pivot.specifiedOrCenter() - b.pivot.specifiedOrCenter()
- }
+ },
)
},
add = { a, b, bProgress ->
@@ -1151,9 +1148,9 @@ private fun ContentDrawScope.getDrawScale(
Offset.Unspecified
} else {
a.pivot.specifiedOrCenter() + b.pivot.specifiedOrCenter() * bProgress
- }
+ },
)
- }
+ },
)
stateInContent.lastScale = interruptedScale
@@ -1371,7 +1368,7 @@ private inline fun <T> computeValue(
lerp(
lerp(previewTargetValue, targetValueOrNull ?: idleValue, previewRangeProgress),
idleValue,
- transformation?.range?.progress(transition.progress) ?: transition.progress
+ transformation?.range?.progress(transition.progress) ?: transition.progress,
)
} else {
if (targetValueOrNull == null) {
@@ -1384,7 +1381,7 @@ private inline fun <T> computeValue(
lerp(
lerp(idleValue, previewTargetValue, previewRangeProgress),
targetValueOrNull,
- transformation.range?.progress(transition.progress) ?: transition.progress
+ transformation.range?.progress(transition.progress) ?: transition.progress,
)
}
}
@@ -1399,14 +1396,7 @@ private inline fun <T> computeValue(
val idleValue = contentValue(contentState)
val targetValue =
- transformation.transform(
- layoutImpl,
- content,
- element,
- contentState,
- transition,
- idleValue,
- )
+ transformation.transform(layoutImpl, content, element, contentState, transition, idleValue)
// Make sure we don't read progress if values are the same and we don't need to interpolate, so
// we don't invalidate the phase where this is read.
@@ -1433,7 +1423,7 @@ private inline fun <T> interpolateSharedElement(
fromState: Element.State,
toState: Element.State,
isSpecified: (T) -> Boolean,
- lerp: (T, T, Float) -> T
+ lerp: (T, T, Float) -> T,
): T {
val start = contentValue(fromState)
val end = contentValue(toState)
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/InterruptionHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/InterruptionHandler.kt
index cb18c6729170..205714608e3c 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/InterruptionHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/InterruptionHandler.kt
@@ -79,9 +79,6 @@ object DefaultInterruptionHandler : InterruptionHandler {
interrupted: TransitionState.Transition.ChangeScene,
newTargetScene: SceneKey,
): InterruptionResult {
- return InterruptionResult(
- animateFrom = interrupted.currentScene,
- chain = true,
- )
+ return InterruptionResult(animateFrom = interrupted.currentScene, chain = true)
}
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt
index ced177ccb9a0..f9a9eeb0d34f 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/Key.kt
@@ -49,10 +49,7 @@ sealed class ContentKey(debugName: String, identity: Any) : Key(debugName, ident
}
/** Key for a scene. */
-class SceneKey(
- debugName: String,
- identity: Any = Object(),
-) : ContentKey(debugName, identity) {
+class SceneKey(debugName: String, identity: Any = Object()) : ContentKey(debugName, identity) {
override val testTag: String = "scene:$debugName"
/** The unique [ElementKey] identifying this scene's root element. */
@@ -64,10 +61,7 @@ class SceneKey(
}
/** Key for an overlay. */
-class OverlayKey(
- debugName: String,
- identity: Any = Object(),
-) : ContentKey(debugName, identity) {
+class OverlayKey(debugName: String, identity: Any = Object()) : ContentKey(debugName, identity) {
override val testTag: String = "overlay:$debugName"
override fun toString(): String {
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MovableElement.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MovableElement.kt
index 471ad3fee9fb..1f26b71cf3e5 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MovableElement.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MovableElement.kt
@@ -86,7 +86,7 @@ private abstract class BaseElementScope<ContentScope>(
value: T,
key: ValueKey,
type: SharedValueType<T, *>,
- canOverflow: Boolean
+ canOverflow: Boolean,
): AnimatedState<T> {
return animateSharedValueAsState(
layoutImpl,
@@ -200,7 +200,7 @@ private fun shouldComposeMovableElement(
content,
element,
elementState,
- isInContent = { contents.contains(it) }
+ isInContent = { contents.contains(it) },
)
}
}
@@ -220,11 +220,7 @@ private fun movableElementContentWhenIdle(
elementState: TransitionState.Idle,
): ContentKey {
val contents = element.contentPicker.contents
- return elementContentWhenIdle(
- layoutImpl,
- elementState,
- isInContent = { contents.contains(it) },
- )
+ return elementContentWhenIdle(layoutImpl, elementState, isInContent = { contents.contains(it) })
}
/**
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt
index 0d05f4e8c613..fb9dde345251 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/MultiPointerDraggable.kt
@@ -200,7 +200,7 @@ internal class MultiPointerDraggableNode(
override fun onPointerEvent(
pointerEvent: PointerEvent,
pass: PointerEventPass,
- bounds: IntSize
+ bounds: IntSize,
) {
// The order is important here: the tracker is always called first.
pointerTracker.onPointerEvent(pointerEvent, pass, bounds)
@@ -234,8 +234,8 @@ internal class MultiPointerDraggableNode(
pointersDown == 0 -> {
startedPosition = null
- // This is the last pointer up
- velocityTracker.addPointerInputChange(changes.single())
+ val lastPointerUp = changes.single { it.id == velocityPointerId }
+ velocityTracker.addPointerInputChange(lastPointerUp)
}
// The first pointer down, startedPosition was not set.
@@ -271,7 +271,12 @@ internal class MultiPointerDraggableNode(
// If the previous pointer has been removed, we use the first available
// change to keep tracking the velocity.
- velocityPointerId = pointerChange.id
+ velocityPointerId =
+ if (pointerChange.pressed) {
+ pointerChange.id
+ } else {
+ changes.first { it.pressed }.id
+ }
velocityTracker.addPointerInputChange(pointerChange)
}
@@ -312,13 +317,13 @@ internal class MultiPointerDraggableNode(
velocityTracker.calculateVelocity(maxVelocity)
}
.toFloat(),
- onFling = { controller.onStop(it, canChangeContent = true) }
+ onFling = { controller.onStop(it, canChangeContent = true) },
)
},
onDragCancel = { controller ->
startFlingGesture(
initialVelocity = 0f,
- onFling = { controller.onStop(it, canChangeContent = true) }
+ onFling = { controller.onStop(it, canChangeContent = true) },
)
},
swipeDetector = swipeDetector,
@@ -369,10 +374,7 @@ internal class MultiPointerDraggableNode(
// PreScroll phase
val consumedByPreScroll =
dispatcher
- .dispatchPreScroll(
- available = availableOnPreScroll.toOffset(),
- source = source,
- )
+ .dispatchPreScroll(available = availableOnPreScroll.toOffset(), source = source)
.toFloat()
// Scroll phase
@@ -484,12 +486,12 @@ internal class MultiPointerDraggableNode(
Orientation.Horizontal ->
awaitHorizontalTouchSlopOrCancellation(
consumablePointer.id,
- onSlopReached
+ onSlopReached,
)
Orientation.Vertical ->
awaitVerticalTouchSlopOrCancellation(
consumablePointer.id,
- onSlopReached
+ onSlopReached,
)
}
@@ -553,7 +555,7 @@ internal class MultiPointerDraggableNode(
}
private suspend fun AwaitPointerEventScope.awaitConsumableEvent(
- pass: () -> PointerEventPass,
+ pass: () -> PointerEventPass
): PointerEvent {
fun canBeConsumed(changes: List<PointerInputChange>): Boolean {
// At least one pointer down AND
@@ -661,7 +663,4 @@ internal fun interface PointersInfoOwner {
fun pointersInfo(): PointersInfo
}
-internal data class PointersInfo(
- val startedPosition: Offset?,
- val pointersDown: Int,
-)
+internal data class PointersInfo(val startedPosition: Offset?, val pointersDown: Int)
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/ObservableTransitionState.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/ObservableTransitionState.kt
index 8ae3a1145e24..9f2ac24b844e 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/ObservableTransitionState.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/ObservableTransitionState.kt
@@ -57,10 +57,8 @@ sealed interface ObservableTransitionState {
/** No transition/animation is currently running. */
data class Idle
@JvmOverloads
- constructor(
- val currentScene: SceneKey,
- val currentOverlays: Set<OverlayKey> = emptySet(),
- ) : ObservableTransitionState
+ constructor(val currentScene: SceneKey, val currentOverlays: Set<OverlayKey> = emptySet()) :
+ ObservableTransitionState
/** There is a transition animating between two scenes. */
sealed class Transition(
@@ -219,10 +217,7 @@ fun SceneTransitionLayoutState.observableTransitionState(): Flow<ObservableTrans
return snapshotFlow {
when (val state = transitionState) {
is TransitionState.Idle ->
- ObservableTransitionState.Idle(
- state.currentScene,
- state.currentOverlays,
- )
+ ObservableTransitionState.Idle(state.currentScene, state.currentOverlays)
is TransitionState.Transition.ChangeScene -> {
ObservableTransitionState.Transition.ChangeScene(
fromScene = state.fromScene,
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/PredictiveBackHandler.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/PredictiveBackHandler.kt
index 8480d3afaed4..b00c8ade07eb 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/PredictiveBackHandler.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/PredictiveBackHandler.kt
@@ -35,9 +35,7 @@ internal fun PredictiveBackHandler(
layoutImpl: SceneTransitionLayoutImpl,
result: UserActionResult?,
) {
- PredictiveBackHandler(
- enabled = result != null,
- ) { events: Flow<BackEventCompat> ->
+ PredictiveBackHandler(enabled = result != null) { events: Flow<BackEventCompat> ->
if (result == null) {
// Note: We have to collect progress otherwise PredictiveBackHandler will throw.
events.first()
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
index 004bb40bb0ad..f20548b1f81b 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayout.kt
@@ -585,7 +585,7 @@ fun interface UserActionDistance {
*/
fun UserActionDistanceScope.absoluteDistance(
fromSceneSize: IntSize,
- orientation: Orientation
+ orientation: Orientation,
): Float
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
index f36c0fa2d75c..fe052344023c 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutImpl.kt
@@ -253,7 +253,7 @@ internal class SceneTransitionLayoutImpl(
key: OverlayKey,
userActions: Map<UserAction, UserActionResult>,
alignment: Alignment,
- content: @Composable (ContentScope.() -> Unit)
+ content: @Composable (ContentScope.() -> Unit),
) {
overlaysDefined = true
overlaysToRemove.remove(key)
@@ -291,7 +291,7 @@ internal class SceneTransitionLayoutImpl(
private fun resolveUserActions(
key: ContentKey,
userActions: Map<UserAction, UserActionResult>,
- layoutDirection: LayoutDirection
+ layoutDirection: LayoutDirection,
): Map<UserAction.Resolved, UserActionResult> {
return userActions
.mapKeys { it.key.resolve(layoutDirection) }
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt
index c2d5dd053148..dbff8a4f7f45 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitionLayoutState.kt
@@ -328,9 +328,7 @@ internal class MutableSceneTransitionLayoutStateImpl(
): Job {
// Note that we start with UNDISPATCHED so that startTransition() is called directly and
// transition becomes the current [transitionState] right after this call.
- return animationScope.launch(
- start = CoroutineStart.UNDISPATCHED,
- ) {
+ return animationScope.launch(start = CoroutineStart.UNDISPATCHED) {
startTransition(transition, chain)
}
}
@@ -461,7 +459,7 @@ internal class MutableSceneTransitionLayoutStateImpl(
val indicator = if (finishedTransitions.contains(transition)) "x" else " "
appendLine(" [$indicator] $from => $to ($transition)")
}
- }
+ },
)
}
@@ -621,7 +619,7 @@ internal class MutableSceneTransitionLayoutStateImpl(
override fun showOverlay(
overlay: OverlayKey,
animationScope: CoroutineScope,
- transitionKey: TransitionKey?
+ transitionKey: TransitionKey?,
) {
checkThread()
@@ -654,7 +652,7 @@ internal class MutableSceneTransitionLayoutStateImpl(
) {
animate(
replacedTransition = currentState,
- reversed = overlay == currentState.fromContent
+ reversed = overlay == currentState.fromContent,
)
} else {
animate()
@@ -664,7 +662,7 @@ internal class MutableSceneTransitionLayoutStateImpl(
override fun hideOverlay(
overlay: OverlayKey,
animationScope: CoroutineScope,
- transitionKey: TransitionKey?
+ transitionKey: TransitionKey?,
) {
checkThread()
@@ -705,7 +703,7 @@ internal class MutableSceneTransitionLayoutStateImpl(
from: OverlayKey,
to: OverlayKey,
animationScope: CoroutineScope,
- transitionKey: TransitionKey?
+ transitionKey: TransitionKey?,
) {
checkThread()
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt
index e65ed9b7dc97..b358faf2c418 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SceneTransitions.kt
@@ -50,7 +50,7 @@ internal constructor(
private val transitionCache =
mutableMapOf<
ContentKey,
- MutableMap<ContentKey, MutableMap<TransitionKey?, TransitionSpecImpl>>
+ MutableMap<ContentKey, MutableMap<TransitionKey?, TransitionSpecImpl>>,
>()
private val overscrollCache =
@@ -70,7 +70,7 @@ internal constructor(
private fun findSpec(
from: ContentKey,
to: ContentKey,
- key: TransitionKey?
+ key: TransitionKey?,
): TransitionSpecImpl {
val spec = transition(from, to, key) { it.from == from && it.to == to }
if (spec != null) {
@@ -250,7 +250,7 @@ internal class TransitionSpecImpl(
override val to: ContentKey?,
private val previewTransformationSpec: (() -> TransformationSpecImpl)? = null,
private val reversePreviewTransformationSpec: (() -> TransformationSpecImpl)? = null,
- private val transformationSpec: () -> TransformationSpecImpl
+ private val transformationSpec: () -> TransformationSpecImpl,
) : TransitionSpec {
override fun reversed(): TransitionSpecImpl {
return TransitionSpecImpl(
@@ -265,9 +265,9 @@ internal class TransitionSpecImpl(
progressSpec = reverse.progressSpec,
swipeSpec = reverse.swipeSpec,
distance = reverse.distance,
- transformations = reverse.transformations.map { it.reversed() }
+ transformations = reverse.transformations.map { it.reversed() },
)
- }
+ },
)
}
@@ -382,11 +382,7 @@ internal class TransformationSpecImpl(
return ElementTransformations(shared, offset, size, drawScale, alpha)
}
- private fun throwIfNotNull(
- previous: Transformation?,
- element: ElementKey,
- name: String,
- ) {
+ private fun throwIfNotNull(previous: Transformation?, element: ElementKey, name: String) {
if (previous != null) {
error("$element has multiple $name transformations")
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt
index 966bda410231..84dce0d730c4 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt
@@ -54,7 +54,7 @@ internal fun createSwipeAnimation(
result: UserActionResult,
isUpOrLeft: Boolean,
orientation: Orientation,
- distance: Float = DistanceUnspecified
+ distance: Float = DistanceUnspecified,
): SwipeAnimation<*> {
var lastDistance = distance
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeToScene.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeToScene.kt
index dc7eda5b9cf6..98d4aaa91458 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeToScene.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeToScene.kt
@@ -39,14 +39,14 @@ import com.android.compose.animation.scene.content.Content
@Stable
internal fun Modifier.swipeToScene(
draggableHandler: DraggableHandlerImpl,
- swipeDetector: SwipeDetector
+ swipeDetector: SwipeDetector,
): Modifier {
return this.then(SwipeToSceneElement(draggableHandler, swipeDetector))
}
private data class SwipeToSceneElement(
val draggableHandler: DraggableHandlerImpl,
- val swipeDetector: SwipeDetector
+ val swipeDetector: SwipeDetector,
) : ModifierNodeElement<SwipeToSceneNode>() {
override fun create(): SwipeToSceneNode = SwipeToSceneNode(draggableHandler, swipeDetector)
@@ -183,12 +183,12 @@ internal fun interface ScrollBehaviorOwner {
*/
private class ScrollBehaviorOwnerNode(
override val traverseKey: Any,
- val nestedScrollHandlerImpl: NestedScrollHandlerImpl
+ val nestedScrollHandlerImpl: NestedScrollHandlerImpl,
) : Modifier.Node(), TraversableNode, ScrollBehaviorOwner {
override fun updateScrollBehaviors(
topOrLeftBehavior: NestedScrollBehavior,
bottomOrRightBehavior: NestedScrollBehavior,
- isExternalOverscrollGesture: () -> Boolean
+ isExternalOverscrollGesture: () -> Boolean,
) {
nestedScrollHandlerImpl.topOrLeftBehavior = topOrLeftBehavior
nestedScrollHandlerImpl.bottomOrRightBehavior = bottomOrRightBehavior
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
index 1f82e0bd026a..763dc6bf49e0 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDsl.kt
@@ -333,7 +333,7 @@ object HighestZIndexContentPicker : ElementContentPicker {
element: ElementKey,
transition: TransitionState.Transition,
fromContentZIndex: Float,
- toContentZIndex: Float
+ toContentZIndex: Float,
): ContentKey {
return if (fromContentZIndex > toContentZIndex) {
transition.fromContent
@@ -354,7 +354,7 @@ object HighestZIndexContentPicker : ElementContentPicker {
element: ElementKey,
transition: TransitionState.Transition,
fromContentZIndex: Float,
- toContentZIndex: Float
+ toContentZIndex: Float,
): ContentKey {
return HighestZIndexContentPicker.contentDuringTransition(
element,
@@ -375,7 +375,7 @@ object LowestZIndexContentPicker : ElementContentPicker {
element: ElementKey,
transition: TransitionState.Transition,
fromContentZIndex: Float,
- toContentZIndex: Float
+ toContentZIndex: Float,
): ContentKey {
return if (fromContentZIndex < toContentZIndex) {
transition.fromContent
@@ -396,7 +396,7 @@ object LowestZIndexContentPicker : ElementContentPicker {
element: ElementKey,
transition: TransitionState.Transition,
fromContentZIndex: Float,
- toContentZIndex: Float
+ toContentZIndex: Float,
): ContentKey {
return LowestZIndexContentPicker.contentDuringTransition(
element,
@@ -423,9 +423,8 @@ object LowestZIndexContentPicker : ElementContentPicker {
* is not the same as when going from scene B to scene A, so it's not usable in situations where
* z-ordering during the transition matters.
*/
-class MovableElementContentPicker(
- override val contents: Set<ContentKey>,
-) : StaticElementContentPicker {
+class MovableElementContentPicker(override val contents: Set<ContentKey>) :
+ StaticElementContentPicker {
override fun contentDuringTransition(
element: ElementKey,
transition: TransitionState.Transition,
@@ -501,7 +500,7 @@ interface PropertyTransformationBuilder {
matcher: ElementMatcher,
scaleX: Float = 1f,
scaleY: Float = 1f,
- pivot: Offset = Offset.Unspecified
+ pivot: Offset = Offset.Unspecified,
)
/**
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDslImpl.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDslImpl.kt
index da4c8d8db752..7ec5e4f4f149 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDslImpl.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/TransitionDslImpl.kt
@@ -41,9 +41,7 @@ import com.android.compose.animation.scene.transformation.Transformation
import com.android.compose.animation.scene.transformation.TransformationRange
import com.android.compose.animation.scene.transformation.Translate
-internal fun transitionsImpl(
- builder: SceneTransitionsBuilder.() -> Unit,
-): SceneTransitions {
+internal fun transitionsImpl(builder: SceneTransitionsBuilder.() -> Unit): SceneTransitions {
val impl = SceneTransitionsBuilderImpl().apply(builder)
return SceneTransitions(
impl.defaultSwipeSpec,
@@ -67,7 +65,7 @@ private class SceneTransitionsBuilderImpl : SceneTransitionsBuilder {
key: TransitionKey?,
preview: (TransitionBuilder.() -> Unit)?,
reversePreview: (TransitionBuilder.() -> Unit)?,
- builder: TransitionBuilder.() -> Unit
+ builder: TransitionBuilder.() -> Unit,
): TransitionSpec {
return transition(from = null, to = to, key = key, preview, reversePreview, builder)
}
@@ -78,7 +76,7 @@ private class SceneTransitionsBuilderImpl : SceneTransitionsBuilder {
key: TransitionKey?,
preview: (TransitionBuilder.() -> Unit)?,
reversePreview: (TransitionBuilder.() -> Unit)?,
- builder: TransitionBuilder.() -> Unit
+ builder: TransitionBuilder.() -> Unit,
): TransitionSpec {
return transition(from = from, to = to, key = key, preview, reversePreview, builder)
}
@@ -86,7 +84,7 @@ private class SceneTransitionsBuilderImpl : SceneTransitionsBuilder {
override fun overscroll(
content: ContentKey,
orientation: Orientation,
- builder: OverscrollBuilder.() -> Unit
+ builder: OverscrollBuilder.() -> Unit,
): OverscrollSpec {
val impl = OverscrollBuilderImpl().apply(builder)
check(impl.transformations.isNotEmpty()) {
@@ -150,7 +148,7 @@ private class SceneTransitionsBuilderImpl : SceneTransitionsBuilder {
to,
previewTransformationSpec,
reversePreviewTransformationSpec,
- transformationSpec
+ transformationSpec,
)
transitionSpecs.add(spec)
return spec
@@ -167,7 +165,7 @@ internal abstract class BaseTransitionBuilderImpl : BaseTransitionBuilder {
start: Float?,
end: Float?,
easing: Easing,
- builder: PropertyTransformationBuilder.() -> Unit
+ builder: PropertyTransformationBuilder.() -> Unit,
) {
range = TransformationRange(start, end, easing)
builder()
@@ -202,7 +200,7 @@ internal abstract class BaseTransitionBuilderImpl : BaseTransitionBuilder {
override fun translate(
matcher: ElementMatcher,
edge: Edge,
- startsOutsideLayoutBounds: Boolean
+ startsOutsideLayoutBounds: Boolean,
) {
transformation(EdgeTranslate(matcher, edge, startsOutsideLayoutBounds))
}
@@ -256,7 +254,7 @@ internal class TransitionBuilderImpl : BaseTransitionBuilderImpl(), TransitionBu
startMillis: Int?,
endMillis: Int?,
easing: Easing,
- builder: PropertyTransformationBuilder.() -> Unit
+ builder: PropertyTransformationBuilder.() -> Unit,
) {
if (startMillis != null && (startMillis < 0 || startMillis > durationMillis)) {
error("invalid start value: startMillis=$startMillis durationMillis=$durationMillis")
@@ -278,7 +276,7 @@ internal open class OverscrollBuilderImpl : BaseTransitionBuilderImpl(), Overscr
override fun translate(
matcher: ElementMatcher,
x: OverscrollScope.() -> Float,
- y: OverscrollScope.() -> Float
+ y: OverscrollScope.() -> Float,
) {
transformation(OverscrollTranslate(matcher, x, y))
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/UserActionDistanceScopeImpl.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/UserActionDistanceScopeImpl.kt
index 9851b32c42c4..b7fa0d497200 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/UserActionDistanceScopeImpl.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/UserActionDistanceScopeImpl.kt
@@ -19,9 +19,8 @@ package com.android.compose.animation.scene
import androidx.compose.ui.geometry.Offset
import androidx.compose.ui.unit.IntSize
-internal class ElementStateScopeImpl(
- private val layoutImpl: SceneTransitionLayoutImpl,
-) : ElementStateScope {
+internal class ElementStateScopeImpl(private val layoutImpl: SceneTransitionLayoutImpl) :
+ ElementStateScope {
override fun ElementKey.targetSize(scene: SceneKey): IntSize? {
return layoutImpl.elements[this]?.stateByContent?.get(scene)?.targetSize.takeIf {
it != Element.SizeUnspecified
@@ -39,9 +38,8 @@ internal class ElementStateScopeImpl(
}
}
-internal class UserActionDistanceScopeImpl(
- private val layoutImpl: SceneTransitionLayoutImpl,
-) : UserActionDistanceScope, ElementStateScope by layoutImpl.elementStateScope {
+internal class UserActionDistanceScopeImpl(private val layoutImpl: SceneTransitionLayoutImpl) :
+ UserActionDistanceScope, ElementStateScope by layoutImpl.elementStateScope {
override val density: Float
get() = layoutImpl.density.density
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/content/Content.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/content/Content.kt
index 59dd896ad9ea..c8407b13db66 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/content/Content.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/content/Content.kt
@@ -106,7 +106,7 @@ internal class ContentScopeImpl(
override fun Element(
key: ElementKey,
modifier: Modifier,
- content: @Composable (ElementScope<ElementContentScope>.() -> Unit)
+ content: @Composable (ElementScope<ElementContentScope>.() -> Unit),
) {
Element(layoutImpl, this@ContentScopeImpl.content, key, modifier, content)
}
@@ -115,7 +115,7 @@ internal class ContentScopeImpl(
override fun MovableElement(
key: MovableElementKey,
modifier: Modifier,
- content: @Composable (ElementScope<MovableElementContentScope>.() -> Unit)
+ content: @Composable (ElementScope<MovableElementContentScope>.() -> Unit),
) {
MovableElement(layoutImpl, this@ContentScopeImpl.content, key, modifier, content)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/content/state/TransitionState.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/content/state/TransitionState.kt
index a47caaa15f18..364c2036e02d 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/content/state/TransitionState.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/content/state/TransitionState.kt
@@ -184,7 +184,7 @@ sealed interface TransitionState {
private fun computeCurrentOverlays(
include: OverlayKey,
- exclude: OverlayKey
+ exclude: OverlayKey,
): Set<OverlayKey> {
return buildSet {
addAll(currentOverlaysWhenTransitionStarted)
@@ -336,9 +336,7 @@ sealed interface TransitionState {
return specForCurrentScene.transformationSpec.transformations.isNotEmpty()
}
- internal open fun interruptionProgress(
- layoutImpl: SceneTransitionLayoutImpl,
- ): Float {
+ internal open fun interruptionProgress(layoutImpl: SceneTransitionLayoutImpl): Float {
if (!layoutImpl.state.enableInterruptions) {
return 0f
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/modifiers/SizeMatcher.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/modifiers/SizeMatcher.kt
index a4bd2be45297..4698e5849d02 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/modifiers/SizeMatcher.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/modifiers/SizeMatcher.kt
@@ -119,9 +119,8 @@ fun Modifier.sizeMatcherDestination(matcher: SizeMatcher): Modifier {
return this.then(SizeMatcherDestinationElement(matcher))
}
-private data class SizeMatcherSourceNodeElement(
- private val matcher: SizeMatcher,
-) : ModifierNodeElement<SizeMatcherSourceNode>() {
+private data class SizeMatcherSourceNodeElement(private val matcher: SizeMatcher) :
+ ModifierNodeElement<SizeMatcherSourceNode>() {
override fun create(): SizeMatcherSourceNode = SizeMatcherSourceNode(matcher)
override fun update(node: SizeMatcherSourceNode) {
@@ -129,9 +128,8 @@ private data class SizeMatcherSourceNodeElement(
}
}
-private class SizeMatcherSourceNode(
- private var matcher: SizeMatcher,
-) : Modifier.Node(), LayoutModifierNode {
+private class SizeMatcherSourceNode(private var matcher: SizeMatcher) :
+ Modifier.Node(), LayoutModifierNode {
override fun onAttach() {
matcher.source = this
}
@@ -150,7 +148,7 @@ private class SizeMatcherSourceNode(
override fun MeasureScope.measure(
measurable: Measurable,
- constraints: Constraints
+ constraints: Constraints,
): MeasureResult {
return measurable.measure(constraints).run {
matcher.sourceSize = IntSize(width, height)
@@ -159,9 +157,8 @@ private class SizeMatcherSourceNode(
}
}
-private data class SizeMatcherDestinationElement(
- private val matcher: SizeMatcher,
-) : ModifierNodeElement<SizeMatcherDestinationNode>() {
+private data class SizeMatcherDestinationElement(private val matcher: SizeMatcher) :
+ ModifierNodeElement<SizeMatcherDestinationNode>() {
override fun create(): SizeMatcherDestinationNode = SizeMatcherDestinationNode(matcher)
override fun update(node: SizeMatcherDestinationNode) {
@@ -169,9 +166,8 @@ private data class SizeMatcherDestinationElement(
}
}
-private class SizeMatcherDestinationNode(
- private var matcher: SizeMatcher,
-) : Modifier.Node(), LayoutModifierNode {
+private class SizeMatcherDestinationNode(private var matcher: SizeMatcher) :
+ Modifier.Node(), LayoutModifierNode {
override fun onAttach() {
this.matcher.destinations.add(this)
}
@@ -190,7 +186,7 @@ private class SizeMatcherDestinationNode(
override fun MeasureScope.measure(
measurable: Measurable,
- constraints: Constraints
+ constraints: Constraints,
): MeasureResult {
val preferredSize = matcher.sourceSize
val preferredConstraints = Constraints.fixed(preferredSize.width, preferredSize.height)
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/AnchoredTranslate.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/AnchoredTranslate.kt
index 05878c2d3f08..86e06ab1f243 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/AnchoredTranslate.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/AnchoredTranslate.kt
@@ -61,15 +61,9 @@ internal class AnchoredTranslate(
val offset = anchorToOffset - anchorFromOffset
return if (content == transition.toContent) {
- Offset(
- value.x - offset.x,
- value.y - offset.y,
- )
+ Offset(value.x - offset.x, value.y - offset.y)
} else {
- Offset(
- value.x + offset.x,
- value.y + offset.y,
- )
+ Offset(value.x + offset.x, value.y + offset.y)
}
}
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/EdgeTranslate.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/EdgeTranslate.kt
index a32c7dd09f95..031f50e17225 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/EdgeTranslate.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/EdgeTranslate.kt
@@ -36,7 +36,7 @@ internal class EdgeTranslate(
element: Element,
stateInContent: Element.State,
transition: TransitionState.Transition,
- value: Offset
+ value: Offset,
): Offset {
val sceneSize = layoutImpl.content(content).targetSize
val elementSize = stateInContent.targetSize
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Fade.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Fade.kt
index 4528eefedb3e..078aa0f7efe9 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Fade.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Fade.kt
@@ -23,16 +23,14 @@ import com.android.compose.animation.scene.SceneTransitionLayoutImpl
import com.android.compose.animation.scene.content.state.TransitionState
/** Fade an element in or out. */
-internal class Fade(
- override val matcher: ElementMatcher,
-) : PropertyTransformation<Float> {
+internal class Fade(override val matcher: ElementMatcher) : PropertyTransformation<Float> {
override fun transform(
layoutImpl: SceneTransitionLayoutImpl,
content: ContentKey,
element: Element,
stateInContent: Element.State,
transition: TransitionState.Transition,
- value: Float
+ value: Float,
): Float {
// Return the alpha value of [element] either when it starts fading in or when it finished
// fading out, which is `0` in both cases.
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Transformation.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Transformation.kt
index 505ad04c598c..9bb302307359 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Transformation.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Transformation.kt
@@ -83,17 +83,13 @@ internal class RangedPropertyTransformation<T>(
override fun reversed(): Transformation {
return RangedPropertyTransformation(
delegate.reversed() as PropertyTransformation<T>,
- range.reversed()
+ range.reversed(),
)
}
}
/** The progress-based range of a [PropertyTransformation]. */
-data class TransformationRange(
- val start: Float,
- val end: Float,
- val easing: Easing,
-) {
+data class TransformationRange(val start: Float, val end: Float, val easing: Easing) {
constructor(
start: Float? = null,
end: Float? = null,
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Translate.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Translate.kt
index 8f845866a0f3..70142717fffe 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Translate.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transformation/Translate.kt
@@ -40,12 +40,7 @@ internal class Translate(
transition: TransitionState.Transition,
value: Offset,
): Offset {
- return with(layoutImpl.density) {
- Offset(
- value.x + x.toPx(),
- value.y + y.toPx(),
- )
- }
+ return with(layoutImpl.density) { Offset(value.x + x.toPx(), value.y + y.toPx()) }
}
}
@@ -71,10 +66,7 @@ internal class OverscrollTranslate(
val overscrollScope =
cachedOverscrollScope.getFromCacheOrCompute(layoutImpl.density, overscrollProperties)
- return Offset(
- x = value.x + overscrollScope.x(),
- y = value.y + overscrollScope.y(),
- )
+ return Offset(x = value.x + overscrollScope.x(), y = value.y + overscrollScope.y())
}
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transition/link/StateLink.kt b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transition/link/StateLink.kt
index c830ca4fa7c0..2aec5091c3e5 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transition/link/StateLink.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/transition/link/StateLink.kt
@@ -50,9 +50,7 @@ class StateLink(target: SceneTransitionLayoutState, val transitionLinks: List<Tr
error("From and To can't be the same")
}
- internal fun isMatchingLink(
- transition: TransitionState.Transition,
- ): Boolean {
+ internal fun isMatchingLink(transition: TransitionState.Transition): Boolean {
return (sourceFrom == null || sourceFrom == transition.fromContent) &&
(sourceTo == null || sourceTo == transition.toContent)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/grid/Grids.kt b/packages/SystemUI/compose/scene/src/com/android/compose/grid/Grids.kt
index 790665aebe3e..f49939ba3a2d 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/grid/Grids.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/grid/Grids.kt
@@ -99,10 +99,7 @@ private fun Grid(
}
}
- Layout(
- modifier = modifier,
- content = content,
- ) { measurables, constraints ->
+ Layout(modifier = modifier, content = content) { measurables, constraints ->
val cells = measurables.size
val columns: Int
val rows: Int
@@ -142,7 +139,7 @@ private fun Grid(
(constraints.maxHeight - totalVerticalSpacingBetweenChildren) / rows
} else {
Constraints.Infinity
- }
+ },
)
val placeables = buildList {
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/MathHelpers.kt b/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/MathHelpers.kt
index e78ab297bfba..0447c36ea3f4 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/MathHelpers.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/MathHelpers.kt
@@ -27,7 +27,7 @@ import com.android.compose.animation.scene.Scale
fun lerp(start: IntSize, stop: IntSize, fraction: Float): IntSize {
return IntSize(
lerp(start.width, stop.width, fraction),
- lerp(start.height, stop.height, fraction)
+ lerp(start.height, stop.height, fraction),
)
}
@@ -43,6 +43,6 @@ fun lerp(start: Scale, stop: Scale, fraction: Float): Scale {
return Scale(
lerp(start.scaleX, stop.scaleX, fraction),
lerp(start.scaleY, stop.scaleY, fraction),
- pivot
+ pivot,
)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt b/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt
index a13e9441523a..f08a18046537 100644
--- a/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/compose/ui/util/SpaceVectorConverter.kt
@@ -22,8 +22,11 @@ import androidx.compose.ui.unit.Velocity
interface SpaceVectorConverter {
fun Offset.toFloat(): Float
+
fun Velocity.toFloat(): Float
+
fun Float.toOffset(): Offset
+
fun Float.toVelocity(): Velocity
}
@@ -36,15 +39,21 @@ fun SpaceVectorConverter(orientation: Orientation) =
private val HorizontalConverter =
object : SpaceVectorConverter {
override fun Offset.toFloat() = x
+
override fun Velocity.toFloat() = x
+
override fun Float.toOffset() = Offset(this, 0f)
+
override fun Float.toVelocity() = Velocity(this, 0f)
}
private val VerticalConverter =
object : SpaceVectorConverter {
override fun Offset.toFloat() = y
+
override fun Velocity.toFloat() = y
+
override fun Float.toOffset() = Offset(0f, this)
+
override fun Float.toVelocity() = Velocity(0f, this)
}
diff --git a/packages/SystemUI/compose/scene/src/com/android/systemui/communal/ui/compose/CommunalSwipeDetector.kt b/packages/SystemUI/compose/scene/src/com/android/systemui/communal/ui/compose/CommunalSwipeDetector.kt
index 41b015a2ede8..00e5405dd904 100644
--- a/packages/SystemUI/compose/scene/src/com/android/systemui/communal/ui/compose/CommunalSwipeDetector.kt
+++ b/packages/SystemUI/compose/scene/src/com/android/systemui/communal/ui/compose/CommunalSwipeDetector.kt
@@ -43,7 +43,7 @@ class CommunalSwipeDetector(private var lastDirection: SwipeSource.Resolved? = n
layoutSize: IntSize,
position: IntOffset,
density: Density,
- orientation: Orientation
+ orientation: Orientation,
): SwipeSource.Resolved? {
return lastDirection
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/AnimatedSharedAsStateTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/AnimatedSharedAsStateTest.kt
index a491349ca757..3644b3069fb3 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/AnimatedSharedAsStateTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/AnimatedSharedAsStateTest.kt
@@ -53,12 +53,7 @@ import org.junit.runner.RunWith
class AnimatedSharedAsStateTest {
@get:Rule val rule = createComposeRule()
- private data class Values(
- val int: Int,
- val float: Float,
- val dp: Dp,
- val color: Color,
- )
+ private data class Values(val int: Int, val float: Float, val dp: Dp, val color: Color)
private fun lerp(start: Values, stop: Values, fraction: Float): Values {
return Values(
@@ -70,10 +65,7 @@ class AnimatedSharedAsStateTest {
}
@Composable
- private fun ContentScope.Foo(
- targetValues: Values,
- onCurrentValueChanged: (Values) -> Unit,
- ) {
+ private fun ContentScope.Foo(targetValues: Values, onCurrentValueChanged: (Values) -> Unit) {
val key = TestElements.Foo
Element(key, Modifier) {
val int by animateElementIntAsState(targetValues.int, key = TestValues.Value1)
@@ -245,7 +237,7 @@ class AnimatedSharedAsStateTest {
fromSceneContent = {
SceneValues(
targetValues = fromValues,
- onCurrentValueChanged = { lastValueInFrom = it }
+ onCurrentValueChanged = { lastValueInFrom = it },
)
},
toSceneContent = {
@@ -457,7 +449,7 @@ class AnimatedSharedAsStateTest {
rule.runOnUiThread {
MutableSceneTransitionLayoutStateImpl(
SceneA,
- transitions { overscrollDisabled(SceneB, Orientation.Horizontal) }
+ transitions { overscrollDisabled(SceneB, Orientation.Horizontal) },
)
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt
index 5b5935633166..fca92ca804fa 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt
@@ -53,9 +53,7 @@ private val LAYOUT_SIZE = IntSize(SCREEN_SIZE.toInt(), SCREEN_SIZE.toInt())
@RunWith(AndroidJUnit4::class)
class DraggableHandlerTest {
- private class TestGestureScope(
- val testScope: MonotonicClockTestScope,
- ) {
+ private class TestGestureScope(val testScope: MonotonicClockTestScope) {
var canChangeScene: (SceneKey) -> Boolean = { true }
val layoutState =
MutableSceneTransitionLayoutStateImpl(
@@ -83,24 +81,14 @@ class DraggableHandlerTest {
}
private val scenesBuilder: SceneTransitionLayoutScope.() -> Unit = {
- scene(
- key = SceneA,
- userActions = mutableUserActionsA,
- ) {
- Text("SceneA")
- }
- scene(
- key = SceneB,
- userActions = mutableUserActionsB,
- ) {
- Text("SceneB")
- }
+ scene(key = SceneA, userActions = mutableUserActionsA) { Text("SceneA") }
+ scene(key = SceneB, userActions = mutableUserActionsB) { Text("SceneB") }
scene(
key = SceneC,
userActions =
mapOf(
Swipe.Up to SceneB,
- Swipe(SwipeDirection.Up, fromSource = Edge.Bottom) to SceneA
+ Swipe(SwipeDirection.Up, fromSource = Edge.Bottom) to SceneA,
),
) {
Text("SceneC")
@@ -110,16 +98,12 @@ class DraggableHandlerTest {
userActions =
mapOf(
Swipe.Up to UserActionResult.HideOverlay(OverlayA),
- Swipe.Down to UserActionResult.ReplaceByOverlay(OverlayB)
+ Swipe.Down to UserActionResult.ReplaceByOverlay(OverlayB),
),
) {
Text("OverlayA")
}
- overlay(
- key = OverlayB,
- ) {
- Text("OverlayB")
- }
+ overlay(key = OverlayB) { Text("OverlayB") }
}
val transitionInterceptionThreshold = 0.05f
@@ -144,7 +128,7 @@ class DraggableHandlerTest {
fun nestedScrollConnection(
nestedScrollBehavior: NestedScrollBehavior,
- isExternalOverscrollGesture: Boolean = false
+ isExternalOverscrollGesture: Boolean = false,
) =
NestedScrollHandlerImpl(
layoutImpl = layoutImpl,
@@ -154,7 +138,7 @@ class DraggableHandlerTest {
isExternalOverscrollGesture = { isExternalOverscrollGesture },
pointersInfoOwner = {
PointersInfo(startedPosition = Offset.Zero, pointersDown = 1)
- }
+ },
)
.connection
@@ -202,7 +186,7 @@ class DraggableHandlerTest {
progress: Float? = null,
previewProgress: Float? = null,
isInPreviewStage: Boolean? = null,
- isUserInputOngoing: Boolean? = null
+ isUserInputOngoing: Boolean? = null,
): Transition {
val transition = assertThat(transitionState).isSceneTransition()
currentScene?.let { assertThat(transition).hasCurrentScene(it) }
@@ -269,7 +253,7 @@ class DraggableHandlerTest {
fun DragController.onDragStopped(
velocity: Float,
canChangeScene: Boolean = true,
- expectedConsumed: Boolean = true
+ expectedConsumed: Boolean = true,
) {
val consumed = onStop(velocity, canChangeScene)
assertThat(consumed).isEqualTo(if (expectedConsumed) velocity else 0f)
@@ -280,16 +264,13 @@ class DraggableHandlerTest {
consumedByScroll: Offset = Offset.Zero,
) {
val consumedByPreScroll =
- onPreScroll(
- available = available,
- source = NestedScrollSource.Drag,
- )
+ onPreScroll(available = available, source = NestedScrollSource.Drag)
val consumed = consumedByPreScroll + consumedByScroll
onPostScroll(
consumed = consumed,
available = available - consumed,
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
}
@@ -376,7 +357,7 @@ class DraggableHandlerTest {
currentScene = SceneA,
isInPreviewStage = true,
previewProgress = 0.1f,
- progress = 0f
+ progress = 0f,
)
// wait for the stop animation
@@ -415,7 +396,7 @@ class DraggableHandlerTest {
currentScene = SceneA,
fromScene = SceneA,
toScene = SceneB,
- progress = 0.6f
+ progress = 0.6f,
)
// Reverse direction such that A -> C now with 0.4
@@ -424,7 +405,7 @@ class DraggableHandlerTest {
currentScene = SceneA,
fromScene = SceneA,
toScene = SceneC,
- progress = 0.4f
+ progress = 0.4f,
)
// After the drag stopped scene C should be committed
@@ -463,7 +444,7 @@ class DraggableHandlerTest {
currentScene = SceneC,
fromScene = SceneC,
toScene = SceneB,
- progress = -0.1f
+ progress = -0.1f,
)
// Reverse drag direction, it will consume the previous drag
@@ -472,7 +453,7 @@ class DraggableHandlerTest {
currentScene = SceneC,
fromScene = SceneC,
toScene = SceneB,
- progress = 0.0f
+ progress = 0.0f,
)
// Continue reverse drag direction, it should record progress to Scene B
@@ -481,7 +462,7 @@ class DraggableHandlerTest {
currentScene = SceneC,
fromScene = SceneC,
toScene = SceneB,
- progress = 0.1f
+ progress = 0.1f,
)
}
@@ -492,13 +473,13 @@ class DraggableHandlerTest {
// Start dragging from the bottom
onDragStarted(
startedPosition = Offset(SCREEN_SIZE * 0.5f, SCREEN_SIZE),
- overSlop = up(fractionOfScreen = 0.1f)
+ overSlop = up(fractionOfScreen = 0.1f),
)
assertTransition(
currentScene = SceneC,
fromScene = SceneC,
toScene = SceneA,
- progress = 0.1f
+ progress = 0.1f,
)
}
@@ -509,14 +490,14 @@ class DraggableHandlerTest {
currentScene = SceneA,
fromScene = SceneA,
toScene = SceneC,
- progress = 0.3f
+ progress = 0.3f,
)
dragController.onDragDelta(pixels = up(fractionOfScreen = 0.3f))
assertTransition(
currentScene = SceneA,
fromScene = SceneA,
toScene = SceneC,
- progress = 0.0f
+ progress = 0.0f,
)
}
@@ -537,7 +518,7 @@ class DraggableHandlerTest {
currentScene = SceneA,
fromScene = SceneA,
toScene = SceneB,
- progress = 0.2f
+ progress = 0.2f,
)
// Start animation A -> B with progress 0.2 -> 1.0
@@ -552,7 +533,7 @@ class DraggableHandlerTest {
currentScene = SceneB,
fromScene = SceneB,
toScene = SceneC,
- progress = 0.2f
+ progress = 0.2f,
)
// After the drag stopped scene C should be committed
@@ -646,7 +627,7 @@ class DraggableHandlerTest {
val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview)
nestedScroll.onPreScroll(
available = downOffset(fractionOfScreen = 0.1f),
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
assertIdle(currentScene = SceneA)
}
@@ -658,7 +639,7 @@ class DraggableHandlerTest {
nestedScroll.onPostScroll(
consumed = Offset.Zero,
available = Offset.Zero,
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
assertIdle(currentScene = SceneA)
@@ -672,7 +653,7 @@ class DraggableHandlerTest {
nestedScroll.onPostScroll(
consumed = Offset.Zero,
available = downOffset(fractionOfScreen = 0.1f),
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
assertTransition(currentScene = SceneA)
@@ -692,7 +673,7 @@ class DraggableHandlerTest {
val consumed =
nestedScroll.onPreScroll(
available = downOffset(fractionOfScreen = 0.1f),
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
assertThat(progress).isEqualTo(0.2f)
@@ -700,7 +681,7 @@ class DraggableHandlerTest {
nestedScroll.onPostScroll(
consumed = consumed,
available = Offset.Zero,
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
assertThat(progress).isEqualTo(0.2f)
@@ -711,7 +692,7 @@ class DraggableHandlerTest {
private fun TestGestureScope.preScrollAfterSceneTransition(
firstScroll: Float,
- secondScroll: Float
+ secondScroll: Float,
) {
val nestedScroll = nestedScrollConnection(nestedScrollBehavior = EdgeWithPreview)
// start scene transition
@@ -723,7 +704,7 @@ class DraggableHandlerTest {
// a pre scroll event, that could be intercepted by DraggableHandlerImpl
nestedScroll.onPreScroll(
available = Offset(0f, secondScroll),
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
}
@@ -835,7 +816,7 @@ class DraggableHandlerTest {
// scroll consumed in child
nestedScroll.scroll(
available = downOffset(fractionOfScreen = 0.1f),
- consumedByScroll = downOffset(fractionOfScreen = 0.1f)
+ consumedByScroll = downOffset(fractionOfScreen = 0.1f),
)
// scroll offsetY10 is all available for parents
@@ -879,13 +860,11 @@ class DraggableHandlerTest {
val nestedScroll =
nestedScrollConnection(
nestedScrollBehavior = EdgeWithPreview,
- isExternalOverscrollGesture = true
+ isExternalOverscrollGesture = true,
)
// scroll not consumed in child
- nestedScroll.scroll(
- available = downOffset(fractionOfScreen = 0.1f),
- )
+ nestedScroll.scroll(available = downOffset(fractionOfScreen = 0.1f))
// scroll offsetY10 is all available for parents
nestedScroll.scroll(available = downOffset(fractionOfScreen = 0.1f))
@@ -1015,7 +994,7 @@ class DraggableHandlerTest {
layoutState.startTransitionImmediately(
animationScope = testScope.backgroundScope,
- transition(SceneA, SceneB)
+ transition(SceneA, SceneB),
)
assertThat(draggableHandler.shouldImmediatelyIntercept(startedPosition = null)).isFalse()
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt
index 60596de29f05..20a1e3c02dd0 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ElementTest.kt
@@ -229,11 +229,7 @@ class ElementTest {
scene(SceneA) {
Box(Modifier.size(layoutSize)) {
// Transformed element
- Element(
- TestElements.Bar,
- elementSize,
- elementOffset,
- )
+ Element(TestElements.Bar, elementSize, elementOffset)
}
}
scene(SceneB) { Box(Modifier.size(layoutSize)) }
@@ -534,10 +530,7 @@ class ElementTest {
scene(SceneA) {
// The pages are full-size and beyondBoundsPageCount is 0, so at rest only one
// page should be composed.
- HorizontalPager(
- pagerState,
- beyondViewportPageCount = 0,
- ) { page ->
+ HorizontalPager(pagerState, beyondViewportPageCount = 0) { page ->
when (page) {
0 -> Box(Modifier.element(TestElements.Foo).fillMaxSize())
1 -> Box(Modifier.fillMaxSize())
@@ -606,7 +599,7 @@ class ElementTest {
scaleSize(TestElements.Foo, width = 2f, height = 0.5f)
translate(TestElements.Foo, x = 10.dp, y = 10.dp)
fade(TestElements.Foo)
- }
+ },
) {
before { assertThat(fooCompositions).isEqualTo(1) }
at(16) { assertThat(fooCompositions).isEqualTo(1) }
@@ -627,7 +620,7 @@ class ElementTest {
from(SceneA, to = SceneB) {
scaleSize(TestElements.Foo, width = 2f, height = 2f)
}
- }
+ },
)
}
@@ -676,13 +669,13 @@ class ElementTest {
touchSlop = LocalViewConfiguration.current.touchSlop
SceneTransitionLayout(
state = state,
- modifier = Modifier.size(layoutWidth, layoutHeight)
+ modifier = Modifier.size(layoutWidth, layoutHeight),
) {
scene(key = SceneA, userActions = mapOf(Swipe.Down to SceneB)) {
animateContentFloatAsState(
value = animatedFloatRange.start,
key = TestValues.Value1,
- false
+ false,
)
Spacer(Modifier.fillMaxSize())
}
@@ -691,7 +684,7 @@ class ElementTest {
animateContentFloatAsState(
value = animatedFloatRange.endInclusive,
key = TestValues.Value1,
- canOverflow = false
+ canOverflow = false,
)
Spacer(Modifier.element(TestElements.Foo).fillMaxSize())
LaunchedEffect(Unit) {
@@ -786,7 +779,7 @@ class ElementTest {
progressConverter = ProgressConverter.linear()
translate(TestElements.Foo, y = overscrollTranslateY)
}
- }
+ },
)
as MutableSceneTransitionLayoutStateImpl
}
@@ -795,7 +788,7 @@ class ElementTest {
touchSlop = LocalViewConfiguration.current.touchSlop
SceneTransitionLayout(
state = state,
- modifier = Modifier.size(layoutWidth, layoutHeight)
+ modifier = Modifier.size(layoutWidth, layoutHeight),
) {
scene(SceneA) { Spacer(Modifier.fillMaxSize()) }
scene(SceneB, userActions = mapOf(Swipe.Up to SceneA)) {
@@ -804,7 +797,7 @@ class ElementTest {
// A scrollable that does not consume the scroll gesture
.scrollable(
rememberScrollableState(consumeScrollDelta = { 0f }),
- Orientation.Vertical
+ Orientation.Vertical,
)
.fillMaxSize()
) {
@@ -869,18 +862,18 @@ class ElementTest {
touchSlop = LocalViewConfiguration.current.touchSlop
SceneTransitionLayout(
state = state,
- modifier = Modifier.size(layoutWidth, layoutHeight)
+ modifier = Modifier.size(layoutWidth, layoutHeight),
) {
scene(
SceneA,
- userActions = mapOf(Swipe(SwipeDirection.Down, pointerCount = 2) to SceneB)
+ userActions = mapOf(Swipe(SwipeDirection.Down, pointerCount = 2) to SceneB),
) {
Box(
Modifier
// A scrollable that does not consume the scroll gesture
.scrollable(
rememberScrollableState(consumeScrollDelta = { 0f }),
- Orientation.Vertical
+ Orientation.Vertical,
)
.fillMaxSize()
) {
@@ -1203,7 +1196,7 @@ class ElementTest {
startsOutsideLayoutBounds = false,
)
}
- }
+ },
)
}
@@ -1621,7 +1614,7 @@ class ElementTest {
rule.runOnUiThread {
MutableSceneTransitionLayoutStateImpl(
SceneA,
- transitions { overscrollDisabled(SceneA, Orientation.Horizontal) }
+ transitions { overscrollDisabled(SceneA, Orientation.Horizontal) },
)
}
@@ -1644,7 +1637,7 @@ class ElementTest {
from = SceneA,
to = SceneB,
progress = { -1f },
- orientation = Orientation.Horizontal
+ orientation = Orientation.Horizontal,
)
)
}
@@ -1666,7 +1659,7 @@ class ElementTest {
rule.runOnUiThread {
MutableSceneTransitionLayoutStateImpl(
SceneA,
- transitions { from(SceneA, to = SceneB) { fade(TestElements.Foo) } }
+ transitions { from(SceneA, to = SceneB) { fade(TestElements.Foo) } },
)
}
@@ -1730,7 +1723,7 @@ class ElementTest {
rule.runOnUiThread {
MutableSceneTransitionLayoutStateImpl(
SceneA,
- transitions { from(SceneA, to = SceneB) { fade(TestElements.Foo) } }
+ transitions { from(SceneA, to = SceneB) { fade(TestElements.Foo) } },
)
}
@@ -1781,7 +1774,7 @@ class ElementTest {
transitions {
overscrollDisabled(SceneA, Orientation.Horizontal)
overscrollDisabled(SceneB, Orientation.Horizontal)
- }
+ },
)
}
@@ -1830,7 +1823,7 @@ class ElementTest {
transitions {
overscrollDisabled(SceneA, Orientation.Horizontal)
overscrollDisabled(SceneB, Orientation.Horizontal)
- }
+ },
)
}
@@ -1886,7 +1879,7 @@ class ElementTest {
progressConverter = ProgressConverter.linear()
translate(TestElements.Foo, y = 15.dp)
}
- }
+ },
)
}
@@ -2053,7 +2046,7 @@ class ElementTest {
from(SceneB, to = SceneC) {
scaleSize(TestElements.Foo, width = 2f, height = 3f)
}
- }
+ },
)
}
@@ -2171,7 +2164,7 @@ class ElementTest {
rule.runOnIdle {
MutableSceneTransitionLayoutStateImpl(
SceneA,
- transitions { overscrollDisabled(SceneA, Orientation.Horizontal) }
+ transitions { overscrollDisabled(SceneA, Orientation.Horizontal) },
)
}
@@ -2231,7 +2224,7 @@ class ElementTest {
// In B => A, Foo is shared.
sharedElement(TestElements.Foo, enabled = true)
}
- }
+ },
)
}
@@ -2363,7 +2356,7 @@ class ElementTest {
},
previewProgress = 0.5f,
progress = 0f,
- isInPreviewStage = true
+ isInPreviewStage = true,
)
// verify that preview transition for exiting elements is halfway played from
@@ -2419,7 +2412,7 @@ class ElementTest {
},
previewProgress = 0.5f,
progress = 0.5f,
- isInPreviewStage = false
+ isInPreviewStage = false,
)
// verify that exiting elements remain in the preview-end state if no further transition is
@@ -2459,13 +2452,13 @@ class ElementTest {
transition: TransitionBuilder.() -> Unit,
progress: Float = 0f,
previewProgress: Float = 0.5f,
- isInPreviewStage: Boolean = true
+ isInPreviewStage: Boolean = true,
): SceneTransitionLayoutImpl {
val state =
rule.runOnIdle {
MutableSceneTransitionLayoutStateImpl(
from,
- transitions { from(from, to = to, preview = preview, builder = transition) }
+ transitions { from(from, to = to, preview = preview, builder = transition) },
)
}
@@ -2489,7 +2482,7 @@ class ElementTest {
to = to,
progress = { progress },
previewProgress = { previewProgress },
- isInPreviewStage = { isInPreviewStage }
+ isInPreviewStage = { isInPreviewStage },
)
scope.launch { state.startTransition(bToA) }
rule.waitForIdle()
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/InterruptionHandlerTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/InterruptionHandlerTest.kt
index bc929bd6b4ce..b87cc5c88335 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/InterruptionHandlerTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/InterruptionHandlerTest.kt
@@ -70,7 +70,7 @@ class InterruptionHandlerTest {
object : InterruptionHandler {
override fun onInterruption(
interrupted: TransitionState.Transition.ChangeScene,
- newTargetScene: SceneKey
+ newTargetScene: SceneKey,
): InterruptionResult {
return InterruptionResult(
animateFrom = interrupted.currentScene,
@@ -88,7 +88,7 @@ class InterruptionHandlerTest {
.comparingElementsUsing(FromToCurrentTriple)
.containsExactly(
// B to C.
- Triple(SceneB, SceneC, SceneC),
+ Triple(SceneB, SceneC, SceneC)
)
.inOrder()
}
@@ -105,7 +105,7 @@ class InterruptionHandlerTest {
object : InterruptionHandler {
override fun onInterruption(
interrupted: TransitionState.Transition.ChangeScene,
- newTargetScene: SceneKey
+ newTargetScene: SceneKey,
): InterruptionResult {
return InterruptionResult(
animateFrom =
@@ -217,7 +217,7 @@ class InterruptionHandlerTest {
{ transition: TransitionState.Transition.ChangeScene? ->
Triple(transition?.fromScene, transition?.toScene, transition?.currentScene)
},
- "(from, to, current) triple"
+ "(from, to, current) triple",
)
}
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MovableElementTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MovableElementTest.kt
index e4879d9d8a31..7c9e9ce7c031 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MovableElementTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MovableElementTest.kt
@@ -161,7 +161,7 @@ class MovableElementTest {
element: ElementKey,
transition: TransitionState.Transition,
fromContentZIndex: Float,
- toContentZIndex: Float
+ toContentZIndex: Float,
): ContentKey {
transition as TransitionState.Transition.ChangeScene
assertThat(transition).hasFromScene(SceneA)
@@ -177,7 +177,7 @@ class MovableElementTest {
SceneB
}
}
- }
+ },
)
rule.testTransition(
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt
index bf192e7708d0..af717ac7d50b 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/MultiPointerDraggableTest.kt
@@ -259,7 +259,7 @@ class MultiPointerDraggableTest {
it
}
),
- Orientation.Vertical
+ Orientation.Vertical,
)
.fillMaxSize()
)
@@ -438,6 +438,9 @@ class MultiPointerDraggableTest {
continueDraggingDown()
assertThat(stopped).isTrue()
+
+ // Complete the gesture
+ rule.onRoot().performTouchInput { up() }
}
@Test
@@ -640,7 +643,7 @@ class MultiPointerDraggableTest {
override fun onPostScroll(
consumed: Offset,
available: Offset,
- source: NestedScrollSource
+ source: NestedScrollSource,
): Offset {
availableOnPostScroll = available.y
return Offset.Zero
@@ -653,7 +656,7 @@ class MultiPointerDraggableTest {
override suspend fun onPostFling(
consumed: Velocity,
- available: Velocity
+ available: Velocity,
): Velocity {
availableOnPostFling = available.y
return Velocity.Zero
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt
index d58a0a3cc0aa..5edb99ea0795 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/NestedScrollToSceneTest.kt
@@ -51,7 +51,7 @@ class NestedScrollToSceneTest {
private val layoutHeight = 400.dp
private fun setup2ScenesAndScrollTouchSlop(
- modifierSceneA: @Composable ContentScope.() -> Modifier = { Modifier },
+ modifierSceneA: @Composable ContentScope.() -> Modifier = { Modifier }
): MutableSceneTransitionLayoutState {
val state =
rule.runOnUiThread {
@@ -62,7 +62,7 @@ class NestedScrollToSceneTest {
touchSlop = LocalViewConfiguration.current.touchSlop
SceneTransitionLayout(
state = state,
- modifier = Modifier.size(layoutWidth, layoutHeight)
+ modifier = Modifier.size(layoutWidth, layoutHeight),
) {
scene(SceneA, userActions = mapOf(Swipe.Up to SceneB)) {
Spacer(modifierSceneA().fillMaxSize())
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ObservableTransitionStateTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ObservableTransitionStateTest.kt
index f3161f36bbf0..596e2cda95bb 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ObservableTransitionStateTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/ObservableTransitionStateTest.kt
@@ -47,12 +47,7 @@ class ObservableTransitionStateTest {
@Test
fun testObservableTransitionState() = runTest {
val state =
- rule.runOnUiThread {
- MutableSceneTransitionLayoutState(
- SceneA,
- EmptyTestTransitions,
- )
- }
+ rule.runOnUiThread { MutableSceneTransitionLayoutState(SceneA, EmptyTestTransitions) }
// Collect the current observable state into [observableState].
// TODO(b/290184746): Use collectValues {} once it is extracted into a library that can be
@@ -82,7 +77,7 @@ class ObservableTransitionStateTest {
scene(SceneA) {}
scene(SceneB) {}
}
- }
+ },
) {
before {
assertThat(observableState()).isEqualTo(ObservableTransitionState.Idle(SceneA))
@@ -157,7 +152,7 @@ class ObservableTransitionStateTest {
rule.runOnUiThread {
MutableSceneTransitionLayoutState(
SceneA,
- transitions = transitions { from(SceneA, to = SceneB, preview = {}) }
+ transitions = transitions { from(SceneA, to = SceneB, preview = {}) },
)
}
rule.setContent {
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/OverlayTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/OverlayTest.kt
index 471362ba19e9..a001fa975391 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/OverlayTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/OverlayTest.kt
@@ -664,7 +664,7 @@ class OverlayTest {
overscroll(OverlayA, orientation = Orientation.Horizontal) {
translate(ElementKey("elementThatDoesNotExist"), x = 10.dp)
}
- }
+ },
)
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/PredictiveBackHandlerTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/PredictiveBackHandlerTest.kt
index 9284ffddcee3..4224a0ccfd34 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/PredictiveBackHandlerTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/PredictiveBackHandlerTest.kt
@@ -78,10 +78,10 @@ class PredictiveBackHandlerTest {
spec =
tween(
durationMillis = transitionFrames * 16,
- easing = LinearEasing
+ easing = LinearEasing,
)
}
- }
+ },
)
}
rule.setContent {
@@ -144,7 +144,7 @@ class PredictiveBackHandlerTest {
rule.runOnUiThread {
MutableSceneTransitionLayoutState(
SceneA,
- transitions = transitions { from(SceneA, to = SceneB, preview = {}) }
+ transitions = transitions { from(SceneA, to = SceneB, preview = {}) },
)
}
rule.setContent {
@@ -243,7 +243,7 @@ class PredictiveBackHandlerTest {
rule.runOnUiThread {
MutableSceneTransitionLayoutState(
SceneA,
- initialOverlays = setOf(OverlayA, OverlayB)
+ initialOverlays = setOf(OverlayA, OverlayB),
)
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutStateTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutStateTest.kt
index d356c25262e8..f3a34884c756 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutStateTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutStateTest.kt
@@ -66,7 +66,7 @@ class SceneTransitionLayoutStateTest {
val state = MutableSceneTransitionLayoutStateImpl(SceneA, SceneTransitions.Empty)
state.startTransitionImmediately(
animationScope = backgroundScope,
- transition(from = SceneA, to = SceneB)
+ transition(from = SceneA, to = SceneB),
)
assertThat(state.isTransitioning()).isTrue()
@@ -137,20 +137,20 @@ class SceneTransitionLayoutStateTest {
sourceFrom: SceneKey? = SceneA,
sourceTo: SceneKey? = SceneB,
targetFrom: SceneKey? = SceneC,
- targetTo: SceneKey = SceneD
+ targetTo: SceneKey = SceneD,
): Pair<MutableSceneTransitionLayoutStateImpl, MutableSceneTransitionLayoutStateImpl> {
val parentState = MutableSceneTransitionLayoutState(parentInitialScene)
val link =
listOf(
StateLink(
parentState,
- listOf(StateLink.TransitionLink(sourceFrom, sourceTo, targetFrom, targetTo))
+ listOf(StateLink.TransitionLink(sourceFrom, sourceTo, targetFrom, targetTo)),
)
)
val childState = MutableSceneTransitionLayoutState(childInitialScene, stateLinks = link)
return Pair(
parentState as MutableSceneTransitionLayoutStateImpl,
- childState as MutableSceneTransitionLayoutStateImpl
+ childState as MutableSceneTransitionLayoutStateImpl,
)
}
@@ -179,7 +179,7 @@ class SceneTransitionLayoutStateTest {
listOf(
StateLink(
parentParentState,
- listOf(StateLink.TransitionLink(SceneC, SceneD, SceneB, SceneC))
+ listOf(StateLink.TransitionLink(SceneC, SceneD, SceneB, SceneC)),
)
)
val parentState =
@@ -189,7 +189,7 @@ class SceneTransitionLayoutStateTest {
listOf(
StateLink(
parentState,
- listOf(StateLink.TransitionLink(SceneA, SceneB, SceneC, SceneD))
+ listOf(StateLink.TransitionLink(SceneA, SceneB, SceneC, SceneD)),
)
)
val childState =
@@ -300,11 +300,7 @@ class SceneTransitionLayoutStateTest {
// Specific transition from A to B.
assertThat(
- state.setTargetScene(
- SceneB,
- animationScope = this,
- transitionKey = transitionkey,
- )
+ state.setTargetScene(SceneB, animationScope = this, transitionKey = transitionkey)
)
.isNotNull()
assertThat(state.currentTransition?.transformationSpec?.transformations).hasSize(2)
@@ -315,7 +311,7 @@ class SceneTransitionLayoutStateTest {
val state = MutableSceneTransitionLayoutStateImpl(SceneA, SceneTransitions.Empty)
state.startTransitionImmediately(
animationScope = backgroundScope,
- transition(from = SceneA, to = SceneB, current = { SceneA }, progress = { 0.2f })
+ transition(from = SceneA, to = SceneB, current = { SceneA }, progress = { 0.2f }),
)
assertThat(state.isTransitioning()).isTrue()
@@ -334,7 +330,7 @@ class SceneTransitionLayoutStateTest {
val state = MutableSceneTransitionLayoutStateImpl(SceneA, SceneTransitions.Empty)
state.startTransitionImmediately(
animationScope = backgroundScope,
- transition(from = SceneA, to = SceneB, progress = { 0.8f })
+ transition(from = SceneA, to = SceneB, progress = { 0.8f }),
)
assertThat(state.isTransitioning()).isTrue()
@@ -381,8 +377,8 @@ class SceneTransitionLayoutStateTest {
from = SceneA,
to = SceneB,
current = { currentScene },
- progress = { progress }
- )
+ progress = { progress },
+ ),
)
assertThat(state.isTransitioning()).isTrue()
@@ -445,11 +441,7 @@ class SceneTransitionLayoutStateTest {
progress: () -> Float,
sceneTransitions: SceneTransitions,
): MutableSceneTransitionLayoutStateImpl {
- val state =
- MutableSceneTransitionLayoutStateImpl(
- SceneA,
- sceneTransitions,
- )
+ val state = MutableSceneTransitionLayoutStateImpl(SceneA, sceneTransitions)
state.startTransitionImmediately(
animationScope = backgroundScope,
transition(
@@ -457,7 +449,7 @@ class SceneTransitionLayoutStateTest {
to = SceneB,
progress = progress,
orientation = Orientation.Vertical,
- )
+ ),
)
assertThat(state.isTransitioning()).isTrue()
return state
@@ -472,7 +464,7 @@ class SceneTransitionLayoutStateTest {
sceneTransitions =
transitions {
overscroll(SceneB, Orientation.Vertical) { fade(TestElements.Foo) }
- }
+ },
)
val transition = assertThat(state.transitionState).isSceneTransition()
assertThat(transition).hasNoOverscrollSpec()
@@ -503,7 +495,7 @@ class SceneTransitionLayoutStateTest {
sceneTransitions =
transitions {
overscroll(SceneA, Orientation.Vertical) { fade(TestElements.Foo) }
- }
+ },
)
val transition = assertThat(state.transitionState).isSceneTransition()
@@ -532,7 +524,7 @@ class SceneTransitionLayoutStateTest {
val state =
startOverscrollableTransistionFromAtoB(
progress = { progress.value },
- sceneTransitions = transitions {}
+ sceneTransitions = transitions {},
)
val transition = assertThat(state.transitionState).isSceneTransition()
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutTest.kt
index 63ab04ffe885..400f0b39a8e5 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SceneTransitionLayoutTest.kt
@@ -95,14 +95,8 @@ class SceneTransitionLayoutTest {
)
}
- SceneTransitionLayout(
- state = layoutState,
- modifier = Modifier.size(LayoutSize),
- ) {
- scene(
- SceneA,
- userActions = mapOf(Back to SceneB),
- ) {
+ SceneTransitionLayout(state = layoutState, modifier = Modifier.size(LayoutSize)) {
+ scene(SceneA, userActions = mapOf(Back to SceneB)) {
Box(Modifier.fillMaxSize()) {
SharedFoo(size = 50.dp, childOffset = 0.dp, Modifier.align(Alignment.TopEnd))
Text("SceneA")
@@ -250,7 +244,7 @@ class SceneTransitionLayoutTest {
sharedFoo.assertHeightIsEqualTo(75.dp)
sharedFoo.assertPositionInRootIsEqualTo(
expectedTop = 0.dp,
- expectedLeft = (LayoutSize - 50.dp) / 2
+ expectedLeft = (LayoutSize - 50.dp) / 2,
)
// The shared offset of the single child of SharedFoo() is 50dp in scene B and 0dp in Scene
@@ -325,7 +319,7 @@ class SceneTransitionLayoutTest {
rule.runOnUiThread {
MutableSceneTransitionLayoutStateImpl(
SceneA,
- transitions { overscrollDisabled(SceneB, Orientation.Horizontal) }
+ transitions { overscrollDisabled(SceneB, Orientation.Horizontal) },
)
}
@@ -371,7 +365,7 @@ class SceneTransitionLayoutTest {
from(SceneB, to = SceneC) {
spec = tween(duration.toInt(), easing = LinearEasing)
}
- }
+ },
)
}
@@ -447,7 +441,7 @@ class SceneTransitionLayoutTest {
}
private fun SemanticsNodeInteraction.offsetRelativeTo(
- other: SemanticsNodeInteraction,
+ other: SemanticsNodeInteraction
): DpOffset {
val node = fetchSemanticsNode()
val bounds = node.boundsInRoot
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
index e48cd81765cb..25e87132eb0e 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/SwipeToSceneTest.kt
@@ -385,12 +385,9 @@ class SwipeToSceneTest {
SceneTransitionLayout(
state = layoutState,
- modifier = Modifier.size(LayoutWidth, LayoutHeight)
+ modifier = Modifier.size(LayoutWidth, LayoutHeight),
) {
- scene(
- SceneA,
- userActions = mapOf(Swipe.Down to SceneB),
- ) {
+ scene(SceneA, userActions = mapOf(Swipe.Down to SceneB)) {
Spacer(Modifier.fillMaxSize())
}
scene(SceneB) { Spacer(Modifier.fillMaxSize()) }
@@ -507,7 +504,7 @@ class SwipeToSceneTest {
fade(TestElements.Foo)
fade(TestElements.Bar)
}
- }
+ },
)
var touchSlop = 0f
@@ -519,8 +516,8 @@ class SwipeToSceneTest {
userActions =
mapOf(
Swipe.Down to SceneB,
- Swipe.Up to UserActionResult(SceneB, transitionKey = transitionkey)
- )
+ Swipe.Up to UserActionResult(SceneB, transitionKey = transitionkey),
+ ),
) {
Box(Modifier.fillMaxSize())
}
@@ -565,7 +562,7 @@ class SwipeToSceneTest {
val state =
layoutState(
SceneA,
- transitions { from(SceneA, to = SceneB) { distance = swipeDistance } }
+ transitions { from(SceneA, to = SceneB) { distance = swipeDistance } },
)
val layoutSize = 200.dp
@@ -617,7 +614,7 @@ class SwipeToSceneTest {
progressConverter = ProgressConverter.linear()
translate(TestElements.Foo, x = { 20.dp.toPx() }, y = { 30.dp.toPx() })
}
- }
+ },
)
}
val layoutSize = 200.dp
@@ -801,7 +798,7 @@ class SwipeToSceneTest {
override fun onPostScroll(
consumed: Offset,
available: Offset,
- source: NestedScrollSource
+ source: NestedScrollSource,
): Offset {
availableOnPostScroll = available.y
return super.onPostScroll(consumed, available, source)
@@ -814,7 +811,7 @@ class SwipeToSceneTest {
transitions {
from(SceneA, to = SceneB) { distance = FixedDistance(swipeDistance) }
overscrollDisabled(SceneB, Orientation.Vertical)
- }
+ },
)
}
val layoutSize = 200.dp
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/TransitionDslTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/TransitionDslTest.kt
index f8068e612f11..223af8039fed 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/TransitionDslTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/TransitionDslTest.kt
@@ -62,7 +62,7 @@ class TransitionDslTest {
.comparingElementsUsing(
Correspondence.transforming<TransitionSpecImpl, Pair<ContentKey?, ContentKey?>>(
{ it?.from to it?.to },
- "has (from, to) equal to"
+ "has (from, to) equal to",
)
)
.containsExactly(
@@ -111,7 +111,7 @@ class TransitionDslTest {
fractionRange(
start = 0.1f,
end = 0.8f,
- easing = CubicBezierEasing(0.1f, 0.1f, 0f, 1f)
+ easing = CubicBezierEasing(0.1f, 0.1f, 0f, 1f),
) {
fade(TestElements.Foo)
}
@@ -126,11 +126,7 @@ class TransitionDslTest {
TransformationRange(start = 0.1f, end = 0.8f),
TransformationRange(start = 0.2f, end = TransformationRange.BoundUnspecified),
TransformationRange(start = TransformationRange.BoundUnspecified, end = 0.9f),
- TransformationRange(
- start = 0.1f,
- end = 0.8f,
- CubicBezierEasing(0.1f, 0.1f, 0f, 1f)
- ),
+ TransformationRange(start = 0.1f, end = 0.8f, CubicBezierEasing(0.1f, 0.1f, 0f, 1f)),
)
}
@@ -146,7 +142,7 @@ class TransitionDslTest {
timestampRange(
startMillis = 100,
endMillis = 300,
- easing = CubicBezierEasing(0.1f, 0.1f, 0f, 1f)
+ easing = CubicBezierEasing(0.1f, 0.1f, 0f, 1f),
) {
fade(TestElements.Foo)
}
@@ -164,7 +160,7 @@ class TransitionDslTest {
TransformationRange(
start = 100 / 500f,
end = 300 / 500f,
- easing = CubicBezierEasing(0.1f, 0.1f, 0f, 1f)
+ easing = CubicBezierEasing(0.1f, 0.1f, 0f, 1f),
),
)
}
@@ -200,7 +196,7 @@ class TransitionDslTest {
preview = { fractionRange(start = 0.1f, end = 0.8f) { fade(TestElements.Foo) } },
reversePreview = {
fractionRange(start = 0.5f, end = 0.6f) { fade(TestElements.Foo) }
- }
+ },
) {
spec = tween(500)
fractionRange(start = 0.1f, end = 0.8f) { fade(TestElements.Foo) }
@@ -226,9 +222,7 @@ class TransitionDslTest {
assertThat(previewTransformations)
.comparingElementsUsing(TRANSFORMATION_RANGE)
- .containsExactly(
- TransformationRange(start = 0.5f, end = 0.6f),
- )
+ .containsExactly(TransformationRange(start = 0.5f, end = 0.6f))
}
@Test
@@ -237,7 +231,7 @@ class TransitionDslTest {
from(
TestScenes.SceneA,
to = TestScenes.SceneB,
- preview = { fractionRange(start = 0.1f, end = 0.8f) { fade(TestElements.Foo) } }
+ preview = { fractionRange(start = 0.1f, end = 0.8f) { fade(TestElements.Foo) } },
) {
spec = tween(500)
fractionRange(start = 0.1f, end = 0.8f) { fade(TestElements.Foo) }
@@ -251,7 +245,7 @@ class TransitionDslTest {
transitions.transitionSpec(
from = TestScenes.SceneA,
to = TestScenes.SceneB,
- key = TransitionKey.PredictiveBack
+ key = TransitionKey.PredictiveBack,
)
val transformations = transitionSpec.transformationSpec().transformations
@@ -267,9 +261,7 @@ class TransitionDslTest {
assertThat(previewTransformations)
.comparingElementsUsing(TRANSFORMATION_RANGE)
- .containsExactly(
- TransformationRange(start = 0.1f, end = 0.8f),
- )
+ .containsExactly(TransformationRange(start = 0.1f, end = 0.8f))
}
@Test
@@ -339,7 +331,7 @@ class TransitionDslTest {
private val TRANSFORMATION_RANGE =
Correspondence.transforming<Transformation, TransformationRange?>(
{ it?.range },
- "has range equal to"
+ "has range equal to",
)
}
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/subjects/TransitionStateSubject.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/subjects/TransitionStateSubject.kt
index 44e0ba51f713..313379f4c74b 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/subjects/TransitionStateSubject.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/subjects/TransitionStateSubject.kt
@@ -39,7 +39,7 @@ fun assertThat(transition: TransitionState.Transition.ChangeScene): SceneTransit
/** Assert on a [TransitionState.Transition.ShowOrHideOverlay]. */
fun assertThat(
- transition: TransitionState.Transition.ShowOrHideOverlay,
+ transition: TransitionState.Transition.ShowOrHideOverlay
): ShowOrHideOverlayTransitionSubject {
return Truth.assertAbout(ShowOrHideOverlayTransitionSubject.showOrHideOverlayTransitions())
.that(transition)
@@ -47,17 +47,15 @@ fun assertThat(
/** Assert on a [TransitionState.Transition.ReplaceOverlay]. */
fun assertThat(
- transition: TransitionState.Transition.ReplaceOverlay,
+ transition: TransitionState.Transition.ReplaceOverlay
): ReplaceOverlayTransitionSubject {
return Truth.assertAbout(ReplaceOverlayTransitionSubject.replaceOverlayTransitions())
.that(transition)
}
class TransitionStateSubject
-private constructor(
- metadata: FailureMetadata,
- private val actual: TransitionState,
-) : Subject(metadata, actual) {
+private constructor(metadata: FailureMetadata, private val actual: TransitionState) :
+ Subject(metadata, actual) {
fun hasCurrentScene(sceneKey: SceneKey) {
check("currentScene").that(actual.currentScene).isEqualTo(sceneKey)
}
@@ -181,10 +179,8 @@ abstract class BaseTransitionSubject<T : TransitionState.Transition>(
}
class SceneTransitionSubject
-private constructor(
- metadata: FailureMetadata,
- actual: TransitionState.Transition.ChangeScene,
-) : BaseTransitionSubject<TransitionState.Transition.ChangeScene>(metadata, actual) {
+private constructor(metadata: FailureMetadata, actual: TransitionState.Transition.ChangeScene) :
+ BaseTransitionSubject<TransitionState.Transition.ChangeScene>(metadata, actual) {
fun hasFromScene(sceneKey: SceneKey) {
check("fromScene").that(actual.fromScene).isEqualTo(sceneKey)
}
@@ -223,10 +219,8 @@ private constructor(
}
class ReplaceOverlayTransitionSubject
-private constructor(
- metadata: FailureMetadata,
- actual: TransitionState.Transition.ReplaceOverlay,
-) : BaseTransitionSubject<TransitionState.Transition.ReplaceOverlay>(metadata, actual) {
+private constructor(metadata: FailureMetadata, actual: TransitionState.Transition.ReplaceOverlay) :
+ BaseTransitionSubject<TransitionState.Transition.ReplaceOverlay>(metadata, actual) {
fun hasFromOverlay(fromOverlay: OverlayKey) {
check("fromOverlay").that(actual.fromOverlay).isEqualTo(fromOverlay)
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/transformation/AnchoredSizeTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/transformation/AnchoredSizeTest.kt
index c9f71da1691b..de55e2fb7657 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/transformation/AnchoredSizeTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/transformation/AnchoredSizeTest.kt
@@ -57,7 +57,7 @@ class AnchoredSizeTest {
transition = {
spec = tween(16 * 4, easing = LinearEasing)
anchoredSize(TestElements.Bar, TestElements.Foo)
- }
+ },
)
}
@@ -73,7 +73,7 @@ class AnchoredSizeTest {
// Scale during 4 frames.
spec = tween(16 * 4, easing = LinearEasing)
anchoredSize(TestElements.Bar, TestElements.Foo)
- }
+ },
)
}
@@ -103,7 +103,7 @@ class AnchoredSizeTest {
transition = {
spec = tween(16 * 4, easing = LinearEasing)
anchoredSize(TestElements.Bar, TestElements.Foo, anchorWidth = false)
- }
+ },
)
}
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/transformation/SharedElementTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/transformation/SharedElementTest.kt
index 00acb137a833..4877cd610875 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/transformation/SharedElementTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/transformation/SharedElementTest.kt
@@ -56,7 +56,7 @@ class SharedElementTest {
transition = {
spec = tween(16 * 4, easing = LinearEasing)
// Elements should be shared by default.
- }
+ },
) {
before {
onElement(TestElements.Foo).assertPositionInRootIsEqualTo(10.dp, 50.dp)
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnectionTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnectionTest.kt
index ce4c52757e78..a406e13904f5 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnectionTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/LargeTopAppBarNestedScrollConnectionTest.kt
@@ -117,7 +117,7 @@ class LargeTopAppBarNestedScrollConnectionTest(testCase: TestCase) {
scrollConnection.onPostScroll(
consumed = Offset.Zero,
available = Offset(x = 0f, y = -1f),
- source = scrollSource
+ source = scrollSource,
)
// It should ignore all onPostScroll events
@@ -147,7 +147,7 @@ class LargeTopAppBarNestedScrollConnectionTest(testCase: TestCase) {
scrollConnection.onPostScroll(
consumed = Offset.Zero,
available = Offset(x = 0f, y = 1f),
- source = scrollSource
+ source = scrollSource,
)
// It can increase by 1 the height
@@ -162,13 +162,13 @@ class LargeTopAppBarNestedScrollConnectionTest(testCase: TestCase) {
scrollConnection.onPostScroll(
consumed = Offset.Zero,
available = Offset(x = 0f, y = 0.5f),
- source = scrollSource
+ source = scrollSource,
)
val offsetConsumed =
scrollConnection.onPreScroll(
available = Offset(x = 0f, y = 0.5f),
- source = scrollSource
+ source = scrollSource,
)
assertThat(offsetConsumed).isEqualTo(Offset(0f, 0.5f))
@@ -185,7 +185,7 @@ class LargeTopAppBarNestedScrollConnectionTest(testCase: TestCase) {
scrollConnection.onPostScroll(
consumed = Offset.Zero,
available = Offset(x = 0f, y = 1f),
- source = scrollSource
+ source = scrollSource,
)
// It should not change the height (already at max)
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt
index 8a9a92ead89e..7f1af05b7252 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/nestedscroll/PriorityNestedScrollConnectionTest.kt
@@ -70,7 +70,7 @@ class PriorityNestedScrollConnectionTest {
scrollConnection.onPostScroll(
consumed = Offset.Zero,
available = Offset.Zero,
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
assertThat(isStarted).isEqualTo(false)
@@ -89,7 +89,7 @@ class PriorityNestedScrollConnectionTest {
scrollConnection.onPostScroll(
consumed = Offset.Zero,
available = Offset.Zero,
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
}
@@ -115,7 +115,7 @@ class PriorityNestedScrollConnectionTest {
scrollConnection.onPostScroll(
consumed = Offset.Zero,
available = Offset.Zero,
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
assertThat(isStarted).isEqualTo(false)
@@ -130,7 +130,7 @@ class PriorityNestedScrollConnectionTest {
scrollConnection.onPostScroll(
consumed = offset1,
available = offset2,
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
assertThat(lastScroll).isEqualTo(offset2)
@@ -184,10 +184,7 @@ class PriorityNestedScrollConnectionTest {
fun receive_onPostFling() = runTest {
canStartPostFling = true
- scrollConnection.onPostFling(
- consumed = velocity1,
- available = velocity2,
- )
+ scrollConnection.onPostFling(consumed = velocity1, available = velocity2)
assertThat(lastStop).isEqualTo(velocity2)
}
@@ -202,7 +199,7 @@ class PriorityNestedScrollConnectionTest {
scrollConnection.onPostScroll(
consumed = Offset.Zero,
available = Offset.Zero,
- source = NestedScrollSource.Drag
+ source = NestedScrollSource.Drag,
)
assertThat(isStarted).isEqualTo(false)
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/test/SetContentAndCreateScope.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/test/SetContentAndCreateScope.kt
index 28a864f8f905..0819dd9fc869 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/test/SetContentAndCreateScope.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/test/SetContentAndCreateScope.kt
@@ -27,7 +27,7 @@ import kotlinx.coroutines.Dispatchers
* and scoped to this rule.
*/
fun ComposeContentTestRule.setContentAndCreateMainScope(
- content: @Composable () -> Unit,
+ content: @Composable () -> Unit
): CoroutineScope {
lateinit var coroutineScope: CoroutineScope
setContent {
diff --git a/packages/SystemUI/compose/scene/tests/src/com/android/compose/test/subjects/DpOffsetSubject.kt b/packages/SystemUI/compose/scene/tests/src/com/android/compose/test/subjects/DpOffsetSubject.kt
index bf7bf98878e6..ab31038fac8f 100644
--- a/packages/SystemUI/compose/scene/tests/src/com/android/compose/test/subjects/DpOffsetSubject.kt
+++ b/packages/SystemUI/compose/scene/tests/src/com/android/compose/test/subjects/DpOffsetSubject.kt
@@ -30,10 +30,8 @@ fun assertThat(dpOffset: DpOffset): DpOffsetSubject {
}
/** A Truth subject to assert on [DpOffset] with some tolerance. Inspired by FloatSubject. */
-class DpOffsetSubject(
- metadata: FailureMetadata,
- private val actual: DpOffset,
-) : Subject(metadata, actual) {
+class DpOffsetSubject(metadata: FailureMetadata, private val actual: DpOffset) :
+ Subject(metadata, actual) {
fun isWithin(tolerance: Dp): TolerantDpOffsetComparison {
return object : TolerantDpOffsetComparison {
override fun of(expected: DpOffset) {
diff --git a/packages/SystemUI/compose/scene/tests/utils/src/com/android/compose/animation/scene/TestTransition.kt b/packages/SystemUI/compose/scene/tests/utils/src/com/android/compose/animation/scene/TestTransition.kt
index 25f95645e699..0d2fcfc0b790 100644
--- a/packages/SystemUI/compose/scene/tests/utils/src/com/android/compose/animation/scene/TestTransition.kt
+++ b/packages/SystemUI/compose/scene/tests/utils/src/com/android/compose/animation/scene/TestTransition.kt
@@ -101,15 +101,12 @@ fun ComposeContentTestRule.testTransition(
runOnUiThread {
MutableSceneTransitionLayoutState(
fromScene,
- transitions { from(fromScene, to = toScene, builder = transition) }
+ transitions { from(fromScene, to = toScene, builder = transition) },
)
},
to = toScene,
transitionLayout = { state ->
- SceneTransitionLayout(
- state,
- layoutModifier,
- ) {
+ SceneTransitionLayout(state, layoutModifier) {
scene(fromScene, content = fromSceneContent)
scene(toScene, content = toSceneContent)
}
@@ -212,14 +209,14 @@ fun ComposeContentTestRule.testReplaceOverlayTransition(
data class TransitionRecordingSpec(
val recordBefore: Boolean = true,
val recordAfter: Boolean = true,
- val timeSeriesCapture: TimeSeriesCaptureScope<SemanticsNodeInteractionsProvider>.() -> Unit
+ val timeSeriesCapture: TimeSeriesCaptureScope<SemanticsNodeInteractionsProvider>.() -> Unit,
)
/** Captures the feature using [capture] on the [element]. */
fun TimeSeriesCaptureScope<SemanticsNodeInteractionsProvider>.featureOfElement(
element: ElementKey,
capture: FeatureCapture<SemanticsNode, *>,
- name: String = "${element.debugName}_${capture.name}"
+ name: String = "${element.debugName}_${capture.name}",
) {
feature(isElement(element), capture, name)
}
@@ -238,7 +235,7 @@ fun MotionTestRule<ComposeToolkit>.recordTransition(
toolkit.composeContentTestRule.runOnUiThread {
MutableSceneTransitionLayoutState(
fromScene,
- transitions { from(fromScene, to = toScene, builder = transition) }
+ transitions { from(fromScene, to = toScene, builder = transition) },
)
}
@@ -250,10 +247,7 @@ fun MotionTestRule<ComposeToolkit>.recordTransition(
}
}
- SceneTransitionLayout(
- state,
- layoutModifier,
- ) {
+ SceneTransitionLayout(state, layoutModifier) {
scene(fromScene, content = fromSceneContent)
scene(toScene, content = toSceneContent)
}
@@ -264,8 +258,8 @@ fun MotionTestRule<ComposeToolkit>.recordTransition(
},
recordBefore = recordingSpec.recordBefore,
recordAfter = recordingSpec.recordAfter,
- timeSeriesCapture = recordingSpec.timeSeriesCapture
- )
+ timeSeriesCapture = recordingSpec.timeSeriesCapture,
+ ),
)
}
@@ -302,7 +296,7 @@ fun ComposeContentTestRule.testTransition(
object : TransitionTestAssertionScope {
override fun onElement(
element: ElementKey,
- scene: SceneKey?
+ scene: SceneKey?,
): SemanticsNodeInteraction {
return onNode(isElement(element, scene))
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/BiometricTestExtensions.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/BiometricTestExtensions.kt
index 75a77cf781d2..4bc71fd6d363 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/BiometricTestExtensions.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/BiometricTestExtensions.kt
@@ -27,6 +27,17 @@ import android.hardware.face.FaceSensorProperties
import android.hardware.face.FaceSensorPropertiesInternal
import android.hardware.fingerprint.FingerprintSensorProperties
import android.hardware.fingerprint.FingerprintSensorPropertiesInternal
+import com.android.keyguard.keyguardUpdateMonitor
+import com.android.systemui.SysuiTestableContext
+import com.android.systemui.biometrics.data.repository.biometricStatusRepository
+import com.android.systemui.biometrics.shared.model.AuthenticationReason
+import com.android.systemui.bouncer.data.repository.keyguardBouncerRepository
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.res.R
+import com.android.systemui.util.mockito.whenever
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.test.TestScope
+import kotlinx.coroutines.test.runCurrent
/** Create [FingerprintSensorPropertiesInternal] for a test. */
internal fun fingerprintSensorPropertiesInternal(
@@ -145,3 +156,67 @@ internal fun promptInfo(
info.negativeButtonText = negativeButton
return info
}
+
+@OptIn(ExperimentalCoroutinesApi::class)
+internal fun TestScope.updateSfpsIndicatorRequests(
+ kosmos: Kosmos,
+ mContext: SysuiTestableContext,
+ primaryBouncerRequest: Boolean? = null,
+ alternateBouncerRequest: Boolean? = null,
+ biometricPromptRequest: Boolean? = null,
+ // TODO(b/365182034): update when rest to unlock feature is implemented
+ // progressBarShowing: Boolean? = null
+) {
+ biometricPromptRequest?.let { hasBiometricPromptRequest ->
+ if (hasBiometricPromptRequest) {
+ kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
+ AuthenticationReason.BiometricPromptAuthentication
+ )
+ } else {
+ kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
+ AuthenticationReason.NotRunning
+ )
+ }
+ }
+
+ primaryBouncerRequest?.let { hasPrimaryBouncerRequest ->
+ updatePrimaryBouncer(
+ kosmos,
+ mContext,
+ isShowing = hasPrimaryBouncerRequest,
+ isAnimatingAway = false,
+ fpsDetectionRunning = true,
+ isUnlockingWithFpAllowed = true
+ )
+ }
+
+ alternateBouncerRequest?.let { hasAlternateBouncerRequest ->
+ kosmos.keyguardBouncerRepository.setAlternateVisible(hasAlternateBouncerRequest)
+ }
+
+ // TODO(b/365182034): set progress bar visibility when rest to unlock feature is implemented
+
+ runCurrent()
+}
+
+internal fun updatePrimaryBouncer(
+ kosmos: Kosmos,
+ mContext: SysuiTestableContext,
+ isShowing: Boolean,
+ isAnimatingAway: Boolean,
+ fpsDetectionRunning: Boolean,
+ isUnlockingWithFpAllowed: Boolean,
+) {
+ kosmos.keyguardBouncerRepository.setPrimaryShow(isShowing)
+ kosmos.keyguardBouncerRepository.setPrimaryStartingToHide(false)
+ val primaryStartDisappearAnimation = if (isAnimatingAway) Runnable {} else null
+ kosmos.keyguardBouncerRepository.setPrimaryStartDisappearAnimation(
+ primaryStartDisappearAnimation
+ )
+
+ whenever(kosmos.keyguardUpdateMonitor.isFingerprintDetectionRunning)
+ .thenReturn(fpsDetectionRunning)
+ whenever(kosmos.keyguardUpdateMonitor.isUnlockingWithFingerprintAllowed)
+ .thenReturn(isUnlockingWithFpAllowed)
+ mContext.orCreateTestableResources.addOverride(R.bool.config_show_sidefps_hint_on_bouncer, true)
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorTest.kt
new file mode 100644
index 000000000000..298b54a5be5a
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorTest.kt
@@ -0,0 +1,174 @@
+/*
+ * Copyright (C) 2024 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.biometrics.domain.interactor
+
+import android.testing.TestableLooper
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.biometrics.data.repository.biometricStatusRepository
+import com.android.systemui.biometrics.data.repository.fingerprintPropertyRepository
+import com.android.systemui.biometrics.shared.model.AuthenticationReason
+import com.android.systemui.biometrics.shared.model.FingerprintSensorType
+import com.android.systemui.biometrics.shared.model.SensorStrength
+import com.android.systemui.biometrics.updateSfpsIndicatorRequests
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.display.data.repository.displayRepository
+import com.android.systemui.display.data.repository.displayStateRepository
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.testKosmos
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.test.TestScope
+import kotlinx.coroutines.test.runCurrent
+import kotlinx.coroutines.test.runTest
+import org.junit.Ignore
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@OptIn(ExperimentalCoroutinesApi::class)
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+@TestableLooper.RunWithLooper(setAsMainLooper = true)
+class SideFpsOverlayInteractorTest : SysuiTestCase() {
+ private val kosmos = testKosmos()
+ private val underTest = kosmos.sideFpsOverlayInteractor
+
+ @Test
+ fun verifyIsShowingFalse_whenInRearDisplayMode() {
+ kosmos.testScope.runTest {
+ val isShowing by collectLastValue(underTest.isShowing)
+ setupTestConfiguration(isInRearDisplayMode = true)
+
+ updateSfpsIndicatorRequests(kosmos, mContext, primaryBouncerRequest = true)
+ runCurrent()
+
+ assertThat(isShowing).isFalse()
+ }
+ }
+
+ @Test
+ fun verifyIsShowingUpdates_onPrimaryBouncerShowAndHide() {
+ kosmos.testScope.runTest {
+ val isShowing by collectLastValue(underTest.isShowing)
+ setupTestConfiguration(isInRearDisplayMode = false)
+
+ // Show primary bouncer
+ updateSfpsIndicatorRequests(kosmos, mContext, primaryBouncerRequest = true)
+ runCurrent()
+
+ assertThat(isShowing).isTrue()
+
+ // Hide primary bouncer
+ updateSfpsIndicatorRequests(kosmos, mContext, primaryBouncerRequest = false)
+ runCurrent()
+
+ assertThat(isShowing).isFalse()
+ }
+ }
+
+ @Test
+ fun verifyIsShowingUpdates_onAlternateBouncerShowAndHide() {
+ kosmos.testScope.runTest {
+ val isShowing by collectLastValue(underTest.isShowing)
+ setupTestConfiguration(isInRearDisplayMode = false)
+
+ updateSfpsIndicatorRequests(kosmos, mContext, alternateBouncerRequest = true)
+ runCurrent()
+
+ assertThat(isShowing).isTrue()
+
+ // Hide alternate bouncer
+ updateSfpsIndicatorRequests(kosmos, mContext, alternateBouncerRequest = false)
+ runCurrent()
+
+ assertThat(isShowing).isFalse()
+ }
+ }
+
+ @Test
+ fun verifyIsShowingUpdates_onSystemServerAuthenticationStartedAndStopped() {
+ kosmos.testScope.runTest {
+ val isShowing by collectLastValue(underTest.isShowing)
+ setupTestConfiguration(isInRearDisplayMode = false)
+
+ updateSfpsIndicatorRequests(kosmos, mContext, biometricPromptRequest = true)
+ runCurrent()
+
+ assertThat(isShowing).isTrue()
+
+ // System server authentication stopped
+ updateSfpsIndicatorRequests(kosmos, mContext, biometricPromptRequest = false)
+ runCurrent()
+
+ assertThat(isShowing).isFalse()
+ }
+ }
+
+ // On progress bar shown - hide indicator
+ // On progress bar hidden - show indicator
+ // TODO(b/365182034): update + enable when rest to unlock feature is implemented
+ @Ignore("b/365182034")
+ @Test
+ fun verifyIsShowingUpdates_onProgressBarInteraction() {
+ kosmos.testScope.runTest {
+ val isShowing by collectLastValue(underTest.isShowing)
+ setupTestConfiguration(isInRearDisplayMode = false)
+
+ updateSfpsIndicatorRequests(kosmos, mContext, primaryBouncerRequest = true)
+ runCurrent()
+
+ assertThat(isShowing).isTrue()
+
+ // updateSfpsIndicatorRequests(
+ // kosmos, mContext, primaryBouncerRequest = true, progressBarShowing =
+ // true
+ // )
+ runCurrent()
+
+ assertThat(isShowing).isFalse()
+
+ // Set progress bar invisible
+ // updateSfpsIndicatorRequests(
+ // kosmos, mContext, primaryBouncerRequest = true, progressBarShowing =
+ // false
+ // )
+ runCurrent()
+
+ // Verify indicator shown
+ assertThat(isShowing).isTrue()
+ }
+ }
+
+ private suspend fun TestScope.setupTestConfiguration(isInRearDisplayMode: Boolean) {
+ kosmos.fingerprintPropertyRepository.setProperties(
+ sensorId = 1,
+ strength = SensorStrength.STRONG,
+ sensorType = FingerprintSensorType.POWER_BUTTON,
+ sensorLocations = emptyMap()
+ )
+
+ kosmos.displayStateRepository.setIsInRearDisplayMode(isInRearDisplayMode)
+ kosmos.displayRepository.emitDisplayChangeEvent(0)
+ runCurrent()
+
+ kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
+ AuthenticationReason.NotRunning
+ )
+ // TODO(b/365182034): set progress bar visibility once rest to unlock feature is implemented
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinderTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinderTest.kt
index 7fa165c19f60..2eea6681ecca 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinderTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinderTest.kt
@@ -16,64 +16,48 @@
package com.android.systemui.biometrics.ui.binder
-import android.animation.Animator
-import android.graphics.Rect
-import android.hardware.biometrics.SensorLocationInternal
-import android.hardware.display.DisplayManager
-import android.hardware.display.DisplayManagerGlobal
import android.testing.TestableLooper
-import android.view.Display
-import android.view.DisplayInfo
import android.view.LayoutInflater
import android.view.View
-import android.view.ViewPropertyAnimator
-import android.view.WindowInsets
import android.view.WindowManager
-import android.view.WindowMetrics
import android.view.layoutInflater
import android.view.windowManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.airbnb.lottie.LottieAnimationView
-import com.android.keyguard.keyguardUpdateMonitor
import com.android.systemui.SysuiTestCase
-import com.android.systemui.biometrics.FingerprintInteractiveToAuthProvider
-import com.android.systemui.biometrics.data.repository.biometricStatusRepository
import com.android.systemui.biometrics.data.repository.fingerprintPropertyRepository
-import com.android.systemui.biometrics.shared.model.AuthenticationReason
import com.android.systemui.biometrics.shared.model.DisplayRotation
import com.android.systemui.biometrics.shared.model.FingerprintSensorType
import com.android.systemui.biometrics.shared.model.SensorStrength
-import com.android.systemui.bouncer.data.repository.keyguardBouncerRepository
+import com.android.systemui.biometrics.updateSfpsIndicatorRequests
import com.android.systemui.display.data.repository.displayRepository
import com.android.systemui.display.data.repository.displayStateRepository
-import com.android.systemui.keyguard.ui.viewmodel.sideFpsProgressBarViewModel
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.testKosmos
import com.android.systemui.util.mockito.eq
-import com.android.systemui.util.mockito.whenever
import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.test.TestScope
import kotlinx.coroutines.test.runCurrent
import kotlinx.coroutines.test.runTest
import org.junit.Before
+import org.junit.Ignore
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
+import org.mockito.ArgumentCaptor
+import org.mockito.Captor
import org.mockito.Mock
-import org.mockito.Mockito
import org.mockito.Mockito.any
import org.mockito.Mockito.inOrder
import org.mockito.Mockito.mock
import org.mockito.Mockito.never
-import org.mockito.Mockito.spy
import org.mockito.Mockito.verify
import org.mockito.Mockito.`when`
import org.mockito.junit.MockitoJUnit
import org.mockito.junit.MockitoRule
-import org.mockito.kotlin.argumentCaptor
+import org.mockito.kotlin.firstValue
@OptIn(ExperimentalCoroutinesApi::class)
@SmallTest
@@ -83,84 +67,25 @@ class SideFpsOverlayViewBinderTest : SysuiTestCase() {
private val kosmos = testKosmos()
@JvmField @Rule var mockitoRule: MockitoRule = MockitoJUnit.rule()
- @Mock private lateinit var displayManager: DisplayManager
- @Mock
- private lateinit var fingerprintInteractiveToAuthProvider: FingerprintInteractiveToAuthProvider
@Mock private lateinit var layoutInflater: LayoutInflater
@Mock private lateinit var sideFpsView: View
-
- private val contextDisplayInfo = DisplayInfo()
-
- private var displayWidth: Int = 0
- private var displayHeight: Int = 0
- private var boundsWidth: Int = 0
- private var boundsHeight: Int = 0
-
- private lateinit var deviceConfig: DeviceConfig
- private lateinit var sensorLocation: SensorLocationInternal
-
- enum class DeviceConfig {
- X_ALIGNED,
- Y_ALIGNED,
- }
+ @Captor private lateinit var viewCaptor: ArgumentCaptor<View>
@Before
fun setup() {
allowTestableLooperAsMainThread() // repeatWhenAttached requires the main thread
-
- mContext = spy(mContext)
-
- val resources = mContext.resources
- whenever(mContext.display)
- .thenReturn(
- Display(mock(DisplayManagerGlobal::class.java), 1, contextDisplayInfo, resources)
- )
-
kosmos.layoutInflater = layoutInflater
-
- whenever(fingerprintInteractiveToAuthProvider.enabledForCurrentUser)
- .thenReturn(MutableStateFlow(false))
-
- context.addMockSystemService(DisplayManager::class.java, displayManager)
context.addMockSystemService(WindowManager::class.java, kosmos.windowManager)
-
`when`(layoutInflater.inflate(R.layout.sidefps_view, null, false)).thenReturn(sideFpsView)
`when`(sideFpsView.requireViewById<LottieAnimationView>(eq(R.id.sidefps_animation)))
.thenReturn(mock(LottieAnimationView::class.java))
- with(mock(ViewPropertyAnimator::class.java)) {
- `when`(sideFpsView.animate()).thenReturn(this)
- `when`(alpha(Mockito.anyFloat())).thenReturn(this)
- `when`(setStartDelay(Mockito.anyLong())).thenReturn(this)
- `when`(setDuration(Mockito.anyLong())).thenReturn(this)
- `when`(setListener(any())).thenAnswer {
- (it.arguments[0] as Animator.AnimatorListener).onAnimationEnd(
- mock(Animator::class.java)
- )
- this
- }
- }
}
@Test
fun verifyIndicatorNotAdded_whenInRearDisplayMode() {
kosmos.testScope.runTest {
- setupTestConfiguration(
- DeviceConfig.X_ALIGNED,
- rotation = DisplayRotation.ROTATION_0,
- isInRearDisplayMode = true
- )
- kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
- AuthenticationReason.NotRunning
- )
- kosmos.sideFpsProgressBarViewModel.setVisible(false)
- updatePrimaryBouncer(
- isShowing = true,
- isAnimatingAway = false,
- fpsDetectionRunning = true,
- isUnlockingWithFpAllowed = true
- )
- runCurrent()
-
+ setupTestConfiguration(isInRearDisplayMode = true)
+ updateSfpsIndicatorRequests(kosmos, mContext, primaryBouncerRequest = true)
verify(kosmos.windowManager, never()).addView(any(), any())
}
}
@@ -168,33 +93,14 @@ class SideFpsOverlayViewBinderTest : SysuiTestCase() {
@Test
fun verifyIndicatorShowAndHide_onPrimaryBouncerShowAndHide() {
kosmos.testScope.runTest {
- setupTestConfiguration(
- DeviceConfig.X_ALIGNED,
- rotation = DisplayRotation.ROTATION_0,
- isInRearDisplayMode = false
- )
- kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
- AuthenticationReason.NotRunning
- )
- kosmos.sideFpsProgressBarViewModel.setVisible(false)
- // Show primary bouncer
- updatePrimaryBouncer(
- isShowing = true,
- isAnimatingAway = false,
- fpsDetectionRunning = true,
- isUnlockingWithFpAllowed = true
- )
+ setupTestConfiguration(isInRearDisplayMode = false)
+ updateSfpsIndicatorRequests(kosmos, mContext, primaryBouncerRequest = true)
runCurrent()
verify(kosmos.windowManager).addView(any(), any())
// Hide primary bouncer
- updatePrimaryBouncer(
- isShowing = false,
- isAnimatingAway = false,
- fpsDetectionRunning = true,
- isUnlockingWithFpAllowed = true
- )
+ updateSfpsIndicatorRequests(kosmos, mContext, primaryBouncerRequest = false)
runCurrent()
verify(kosmos.windowManager).removeView(any())
@@ -204,30 +110,19 @@ class SideFpsOverlayViewBinderTest : SysuiTestCase() {
@Test
fun verifyIndicatorShowAndHide_onAlternateBouncerShowAndHide() {
kosmos.testScope.runTest {
- setupTestConfiguration(
- DeviceConfig.X_ALIGNED,
- rotation = DisplayRotation.ROTATION_0,
- isInRearDisplayMode = false
- )
- kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
- AuthenticationReason.NotRunning
- )
- kosmos.sideFpsProgressBarViewModel.setVisible(false)
- // Show alternate bouncer
- kosmos.keyguardBouncerRepository.setAlternateVisible(true)
+ setupTestConfiguration(isInRearDisplayMode = false)
+ updateSfpsIndicatorRequests(kosmos, mContext, alternateBouncerRequest = true)
runCurrent()
verify(kosmos.windowManager).addView(any(), any())
- var viewCaptor = argumentCaptor<View>()
verify(kosmos.windowManager).addView(viewCaptor.capture(), any())
verify(viewCaptor.firstValue)
.announceForAccessibility(
mContext.getText(R.string.accessibility_side_fingerprint_indicator_label)
)
- // Hide alternate bouncer
- kosmos.keyguardBouncerRepository.setAlternateVisible(false)
+ updateSfpsIndicatorRequests(kosmos, mContext, alternateBouncerRequest = false)
runCurrent()
verify(kosmos.windowManager).removeView(any())
@@ -237,30 +132,14 @@ class SideFpsOverlayViewBinderTest : SysuiTestCase() {
@Test
fun verifyIndicatorShownAndHidden_onSystemServerAuthenticationStartedAndStopped() {
kosmos.testScope.runTest {
- setupTestConfiguration(
- DeviceConfig.X_ALIGNED,
- rotation = DisplayRotation.ROTATION_0,
- isInRearDisplayMode = false
- )
- kosmos.sideFpsProgressBarViewModel.setVisible(false)
- updatePrimaryBouncer(
- isShowing = false,
- isAnimatingAway = false,
- fpsDetectionRunning = true,
- isUnlockingWithFpAllowed = true
- )
- // System server authentication started
- kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
- AuthenticationReason.BiometricPromptAuthentication
- )
+ setupTestConfiguration(isInRearDisplayMode = false)
+ updateSfpsIndicatorRequests(kosmos, mContext, biometricPromptRequest = true)
runCurrent()
verify(kosmos.windowManager).addView(any(), any())
// System server authentication stopped
- kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
- AuthenticationReason.NotRunning
- )
+ updateSfpsIndicatorRequests(kosmos, mContext, biometricPromptRequest = false)
runCurrent()
verify(kosmos.windowManager).removeView(any())
@@ -269,45 +148,35 @@ class SideFpsOverlayViewBinderTest : SysuiTestCase() {
// On progress bar shown - hide indicator
// On progress bar hidden - show indicator
+ // TODO(b/365182034): update + enable when rest to unlock feature is implemented
+ @Ignore("b/365182034")
@Test
fun verifyIndicatorProgressBarInteraction() {
kosmos.testScope.runTest {
// Pre-auth conditions
- setupTestConfiguration(
- DeviceConfig.X_ALIGNED,
- rotation = DisplayRotation.ROTATION_0,
- isInRearDisplayMode = false
- )
- kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
- AuthenticationReason.NotRunning
- )
- kosmos.sideFpsProgressBarViewModel.setVisible(false)
-
- // Show primary bouncer
- updatePrimaryBouncer(
- isShowing = true,
- isAnimatingAway = false,
- fpsDetectionRunning = true,
- isUnlockingWithFpAllowed = true
- )
+ setupTestConfiguration(isInRearDisplayMode = false)
+ updateSfpsIndicatorRequests(kosmos, mContext, primaryBouncerRequest = true)
runCurrent()
val inOrder = inOrder(kosmos.windowManager)
-
// Verify indicator shown
inOrder.verify(kosmos.windowManager).addView(any(), any())
// Set progress bar visible
- kosmos.sideFpsProgressBarViewModel.setVisible(true)
-
+ // updateSfpsIndicatorRequests(
+ // kosmos, mContext, primaryBouncerRequest = true, progressBarShowing =
+ // true
+ // )
runCurrent()
// Verify indicator hidden
inOrder.verify(kosmos.windowManager).removeView(any())
// Set progress bar invisible
- kosmos.sideFpsProgressBarViewModel.setVisible(false)
-
+ // updateSfpsIndicatorRequests(
+ // kosmos, mContext, primaryBouncerRequest = true, progressBarShowing =
+ // false
+ // )
runCurrent()
// Verify indicator shown
@@ -315,78 +184,18 @@ class SideFpsOverlayViewBinderTest : SysuiTestCase() {
}
}
- private fun updatePrimaryBouncer(
- isShowing: Boolean,
- isAnimatingAway: Boolean,
- fpsDetectionRunning: Boolean,
- isUnlockingWithFpAllowed: Boolean,
- ) {
- kosmos.keyguardBouncerRepository.setPrimaryShow(isShowing)
- kosmos.keyguardBouncerRepository.setPrimaryStartingToHide(false)
- val primaryStartDisappearAnimation = if (isAnimatingAway) Runnable {} else null
- kosmos.keyguardBouncerRepository.setPrimaryStartDisappearAnimation(
- primaryStartDisappearAnimation
- )
-
- whenever(kosmos.keyguardUpdateMonitor.isFingerprintDetectionRunning)
- .thenReturn(fpsDetectionRunning)
- whenever(kosmos.keyguardUpdateMonitor.isUnlockingWithFingerprintAllowed)
- .thenReturn(isUnlockingWithFpAllowed)
- mContext.orCreateTestableResources.addOverride(
- R.bool.config_show_sidefps_hint_on_bouncer,
- true
- )
- }
-
- private suspend fun TestScope.setupTestConfiguration(
- deviceConfig: DeviceConfig,
- rotation: DisplayRotation = DisplayRotation.ROTATION_0,
- isInRearDisplayMode: Boolean,
- ) {
- this@SideFpsOverlayViewBinderTest.deviceConfig = deviceConfig
-
- when (deviceConfig) {
- DeviceConfig.X_ALIGNED -> {
- displayWidth = 3000
- displayHeight = 1500
- boundsWidth = 200
- boundsHeight = 100
- sensorLocation = SensorLocationInternal("", 2500, 0, boundsWidth / 2)
- }
- DeviceConfig.Y_ALIGNED -> {
- displayWidth = 2500
- displayHeight = 2000
- boundsWidth = 100
- boundsHeight = 200
- sensorLocation = SensorLocationInternal("", displayWidth, 300, boundsHeight / 2)
- }
- }
-
- whenever(kosmos.windowManager.maximumWindowMetrics)
- .thenReturn(
- WindowMetrics(
- Rect(0, 0, displayWidth, displayHeight),
- mock(WindowInsets::class.java),
- )
- )
-
- contextDisplayInfo.uniqueId = DISPLAY_ID
-
+ private suspend fun TestScope.setupTestConfiguration(isInRearDisplayMode: Boolean) {
kosmos.fingerprintPropertyRepository.setProperties(
sensorId = 1,
strength = SensorStrength.STRONG,
sensorType = FingerprintSensorType.POWER_BUTTON,
- sensorLocations = mapOf(DISPLAY_ID to sensorLocation)
+ sensorLocations = emptyMap()
)
kosmos.displayStateRepository.setIsInRearDisplayMode(isInRearDisplayMode)
- kosmos.displayStateRepository.setCurrentRotation(rotation)
+ kosmos.displayStateRepository.setCurrentRotation(DisplayRotation.ROTATION_0)
kosmos.displayRepository.emitDisplayChangeEvent(0)
kosmos.sideFpsOverlayViewBinder.start()
runCurrent()
}
-
- companion object {
- private const val DISPLAY_ID = "displayId"
- }
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModelTest.kt
index 0db7b62b8ef1..27b1371deb12 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModelTest.kt
@@ -30,23 +30,19 @@ import android.view.windowManager
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.airbnb.lottie.model.KeyPath
-import com.android.keyguard.keyguardUpdateMonitor
import com.android.settingslib.Utils
import com.android.systemui.SysuiTestCase
import com.android.systemui.biometrics.FingerprintInteractiveToAuthProvider
-import com.android.systemui.biometrics.data.repository.biometricStatusRepository
import com.android.systemui.biometrics.data.repository.fingerprintPropertyRepository
import com.android.systemui.biometrics.domain.interactor.displayStateInteractor
-import com.android.systemui.biometrics.shared.model.AuthenticationReason
import com.android.systemui.biometrics.shared.model.DisplayRotation
import com.android.systemui.biometrics.shared.model.FingerprintSensorType
import com.android.systemui.biometrics.shared.model.LottieCallback
import com.android.systemui.biometrics.shared.model.SensorStrength
-import com.android.systemui.bouncer.data.repository.keyguardBouncerRepository
+import com.android.systemui.biometrics.updateSfpsIndicatorRequests
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.display.data.repository.displayRepository
import com.android.systemui.display.data.repository.displayStateRepository
-import com.android.systemui.keyguard.ui.viewmodel.sideFpsProgressBarViewModel
import com.android.systemui.kosmos.testScope
import com.android.systemui.res.R
import com.android.systemui.testKosmos
@@ -284,17 +280,7 @@ class SideFpsOverlayViewModelTest : SysuiTestCase() {
kosmos.testScope.runTest {
val lottieCallbacks by collectLastValue(kosmos.sideFpsOverlayViewModel.lottieCallbacks)
- kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
- AuthenticationReason.NotRunning
- )
- kosmos.sideFpsProgressBarViewModel.setVisible(false)
-
- updatePrimaryBouncer(
- isShowing = true,
- isAnimatingAway = false,
- fpsDetectionRunning = true,
- isUnlockingWithFpAllowed = true
- )
+ updateSfpsIndicatorRequests(kosmos, mContext, primaryBouncerRequest = true)
runCurrent()
assertThat(lottieCallbacks)
@@ -312,17 +298,7 @@ class SideFpsOverlayViewModelTest : SysuiTestCase() {
val lottieCallbacks by collectLastValue(kosmos.sideFpsOverlayViewModel.lottieCallbacks)
setDarkMode(true)
- kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
- AuthenticationReason.BiometricPromptAuthentication
- )
- kosmos.sideFpsProgressBarViewModel.setVisible(false)
-
- updatePrimaryBouncer(
- isShowing = false,
- isAnimatingAway = false,
- fpsDetectionRunning = true,
- isUnlockingWithFpAllowed = true
- )
+ updateSfpsIndicatorRequests(kosmos, mContext, biometricPromptRequest = true)
runCurrent()
assertThat(lottieCallbacks)
@@ -338,17 +314,7 @@ class SideFpsOverlayViewModelTest : SysuiTestCase() {
val lottieCallbacks by collectLastValue(kosmos.sideFpsOverlayViewModel.lottieCallbacks)
setDarkMode(false)
- kosmos.biometricStatusRepository.setFingerprintAuthenticationReason(
- AuthenticationReason.BiometricPromptAuthentication
- )
- kosmos.sideFpsProgressBarViewModel.setVisible(false)
-
- updatePrimaryBouncer(
- isShowing = false,
- isAnimatingAway = false,
- fpsDetectionRunning = true,
- isUnlockingWithFpAllowed = true
- )
+ updateSfpsIndicatorRequests(kosmos, mContext, biometricPromptRequest = true)
runCurrent()
assertThat(lottieCallbacks)
@@ -371,29 +337,6 @@ class SideFpsOverlayViewModelTest : SysuiTestCase() {
mContext.resources.configuration.uiMode = uiMode
}
- private fun updatePrimaryBouncer(
- isShowing: Boolean,
- isAnimatingAway: Boolean,
- fpsDetectionRunning: Boolean,
- isUnlockingWithFpAllowed: Boolean,
- ) {
- kosmos.keyguardBouncerRepository.setPrimaryShow(isShowing)
- kosmos.keyguardBouncerRepository.setPrimaryStartingToHide(false)
- val primaryStartDisappearAnimation = if (isAnimatingAway) Runnable {} else null
- kosmos.keyguardBouncerRepository.setPrimaryStartDisappearAnimation(
- primaryStartDisappearAnimation
- )
-
- whenever(kosmos.keyguardUpdateMonitor.isFingerprintDetectionRunning)
- .thenReturn(fpsDetectionRunning)
- whenever(kosmos.keyguardUpdateMonitor.isUnlockingWithFingerprintAllowed)
- .thenReturn(isUnlockingWithFpAllowed)
- mContext.orCreateTestableResources.addOverride(
- R.bool.config_show_sidefps_hint_on_bouncer,
- true
- )
- }
-
private suspend fun TestScope.setupTestConfiguration(
deviceConfig: DeviceConfig,
rotation: DisplayRotation = DisplayRotation.ROTATION_0,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt
index 3b0057d87048..e531e654cd34 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/communal/CommunalDreamStartableTest.kt
@@ -22,6 +22,7 @@ import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.Flags
import com.android.systemui.SysuiTestCase
+import com.android.systemui.communal.domain.interactor.communalSceneInteractor
import com.android.systemui.communal.domain.interactor.communalSettingsInteractor
import com.android.systemui.flags.Flags.COMMUNAL_SERVICE_ENABLED
import com.android.systemui.flags.fakeFeatureFlagsClassic
@@ -73,6 +74,7 @@ class CommunalDreamStartableTest : SysuiTestCase() {
keyguardInteractor = kosmos.keyguardInteractor,
keyguardTransitionInteractor = kosmos.keyguardTransitionInteractor,
dreamManager = dreamManager,
+ communalSceneInteractor = kosmos.communalSceneInteractor,
bgScope = kosmos.applicationCoroutineScope,
)
.apply { start() }
@@ -158,6 +160,36 @@ class CommunalDreamStartableTest : SysuiTestCase() {
}
}
+ @Test
+ fun shouldNotStartDreamWhenLaunchingWidget() =
+ testScope.runTest {
+ keyguardRepository.setKeyguardShowing(true)
+ keyguardRepository.setDreaming(false)
+ powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON)
+ kosmos.communalSceneInteractor.setIsLaunchingWidget(true)
+ whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true)
+ runCurrent()
+
+ transition(from = KeyguardState.DREAMING, to = KeyguardState.GLANCEABLE_HUB)
+
+ verify(dreamManager, never()).startDream()
+ }
+
+ @Test
+ fun shouldNotStartDreamWhenOccluded() =
+ testScope.runTest {
+ keyguardRepository.setKeyguardShowing(true)
+ keyguardRepository.setDreaming(false)
+ powerRepository.setScreenPowerState(ScreenPowerState.SCREEN_ON)
+ keyguardRepository.setKeyguardOccluded(true)
+ whenever(dreamManager.canStartDreaming(/* isScreenOn= */ true)).thenReturn(true)
+ runCurrent()
+
+ transition(from = KeyguardState.DREAMING, to = KeyguardState.GLANCEABLE_HUB)
+
+ verify(dreamManager, never()).startDream()
+ }
+
private suspend fun TestScope.transition(from: KeyguardState, to: KeyguardState) {
kosmos.fakeKeyguardTransitionRepository.sendTransitionSteps(
from = from,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadStatsInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadStatsInteractorTest.kt
index cd0c58feebed..98e09474d5f2 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadStatsInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadStatsInteractorTest.kt
@@ -19,14 +19,22 @@ package com.android.systemui.education.domain.interactor
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
-import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.contextualeducation.GestureType.ALL_APPS
import com.android.systemui.contextualeducation.GestureType.BACK
+import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.education.data.repository.contextualEducationRepository
import com.android.systemui.education.data.repository.fakeEduClock
+import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType
+import com.android.systemui.inputdevice.tutorial.tutorialSchedulerRepository
+import com.android.systemui.keyboard.data.repository.keyboardRepository
import com.android.systemui.kosmos.testScope
import com.android.systemui.testKosmos
+import com.android.systemui.touchpad.data.repository.touchpadRepository
import com.google.common.truth.Truth.assertThat
+import kotlin.time.Duration.Companion.seconds
+import kotlinx.coroutines.launch
import kotlinx.coroutines.test.runTest
+import org.junit.After
import org.junit.Test
import org.junit.runner.RunWith
@@ -36,24 +44,129 @@ class KeyboardTouchpadStatsInteractorTest : SysuiTestCase() {
private val kosmos = testKosmos()
private val testScope = kosmos.testScope
private val underTest = kosmos.keyboardTouchpadEduStatsInteractor
+ private val keyboardRepository = kosmos.keyboardRepository
+ private val touchpadRepository = kosmos.touchpadRepository
+ private val repository = kosmos.contextualEducationRepository
+ private val fakeClock = kosmos.fakeEduClock
+ private val tutorialSchedulerRepository = kosmos.tutorialSchedulerRepository
+ private val initialDelayElapsedDuration =
+ KeyboardTouchpadEduStatsInteractorImpl.initialDelayDuration + 1.seconds
+
+ @Test
+ fun dataUpdatedOnIncrementSignalCountWhenTouchpadConnected() =
+ testScope.runTest {
+ setUpForInitialDelayElapse()
+ touchpadRepository.setIsAnyTouchpadConnected(true)
+
+ val model by collectLastValue(repository.readGestureEduModelFlow(BACK))
+ val originalValue = model!!.signalCount
+ underTest.incrementSignalCount(BACK)
+
+ assertThat(model?.signalCount).isEqualTo(originalValue + 1)
+ }
@Test
- fun dataUpdatedOnIncrementSignalCount() =
+ fun dataUnchangedOnIncrementSignalCountWhenTouchpadDisconnected() =
testScope.runTest {
- val model by
- collectLastValue(kosmos.contextualEducationRepository.readGestureEduModelFlow(BACK))
+ setUpForInitialDelayElapse()
+ touchpadRepository.setIsAnyTouchpadConnected(false)
+
+ val model by collectLastValue(repository.readGestureEduModelFlow(BACK))
val originalValue = model!!.signalCount
underTest.incrementSignalCount(BACK)
+
+ assertThat(model?.signalCount).isEqualTo(originalValue)
+ }
+
+ @Test
+ fun dataUpdatedOnIncrementSignalCountWhenKeyboardConnected() =
+ testScope.runTest {
+ setUpForInitialDelayElapse()
+ keyboardRepository.setIsAnyKeyboardConnected(true)
+
+ val model by collectLastValue(repository.readGestureEduModelFlow(ALL_APPS))
+ val originalValue = model!!.signalCount
+ underTest.incrementSignalCount(ALL_APPS)
+
assertThat(model?.signalCount).isEqualTo(originalValue + 1)
}
@Test
+ fun dataUnchangedOnIncrementSignalCountWhenKeyboardDisconnected() =
+ testScope.runTest {
+ setUpForInitialDelayElapse()
+ keyboardRepository.setIsAnyKeyboardConnected(false)
+
+ val model by collectLastValue(repository.readGestureEduModelFlow(ALL_APPS))
+ val originalValue = model!!.signalCount
+ underTest.incrementSignalCount(ALL_APPS)
+
+ assertThat(model?.signalCount).isEqualTo(originalValue)
+ }
+
+ @Test
fun dataAddedOnUpdateShortcutTriggerTime() =
testScope.runTest {
- val model by
- collectLastValue(kosmos.contextualEducationRepository.readGestureEduModelFlow(BACK))
+ val model by collectLastValue(repository.readGestureEduModelFlow(BACK))
assertThat(model?.lastShortcutTriggeredTime).isNull()
underTest.updateShortcutTriggerTime(BACK)
assertThat(model?.lastShortcutTriggeredTime).isEqualTo(kosmos.fakeEduClock.instant())
}
+
+ @Test
+ fun dataUpdatedOnIncrementSignalCountAfterInitialDelay() =
+ testScope.runTest {
+ setUpForDeviceConnection()
+ tutorialSchedulerRepository.updateLaunchTime(DeviceType.TOUCHPAD, fakeClock.instant())
+
+ fakeClock.offset(initialDelayElapsedDuration)
+ val model by collectLastValue(repository.readGestureEduModelFlow(BACK))
+ val originalValue = model!!.signalCount
+ underTest.incrementSignalCount(BACK)
+
+ assertThat(model?.signalCount).isEqualTo(originalValue + 1)
+ }
+
+ @Test
+ fun dataUnchangedOnIncrementSignalCountBeforeInitialDelay() =
+ testScope.runTest {
+ setUpForDeviceConnection()
+ tutorialSchedulerRepository.updateLaunchTime(DeviceType.TOUCHPAD, fakeClock.instant())
+
+ // No offset to the clock to simulate update before initial delay
+ val model by collectLastValue(repository.readGestureEduModelFlow(BACK))
+ val originalValue = model!!.signalCount
+ underTest.incrementSignalCount(BACK)
+
+ assertThat(model?.signalCount).isEqualTo(originalValue)
+ }
+
+ @Test
+ fun dataUnchangedOnIncrementSignalCountWithoutOobeLaunchTime() =
+ testScope.runTest {
+ // No update to OOBE launch time to simulate no OOBE is launched yet
+ setUpForDeviceConnection()
+
+ val model by collectLastValue(repository.readGestureEduModelFlow(BACK))
+ val originalValue = model!!.signalCount
+ underTest.incrementSignalCount(BACK)
+
+ assertThat(model?.signalCount).isEqualTo(originalValue)
+ }
+
+ private suspend fun setUpForInitialDelayElapse() {
+ tutorialSchedulerRepository.updateLaunchTime(DeviceType.TOUCHPAD, fakeClock.instant())
+ tutorialSchedulerRepository.updateLaunchTime(DeviceType.KEYBOARD, fakeClock.instant())
+ fakeClock.offset(initialDelayElapsedDuration)
+ }
+
+ private fun setUpForDeviceConnection() {
+ touchpadRepository.setIsAnyTouchpadConnected(true)
+ keyboardRepository.setIsAnyKeyboardConnected(true)
+ }
+
+ @After
+ fun clear() {
+ testScope.launch { tutorialSchedulerRepository.clearDataStore() }
+ }
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepositoryTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepositoryTest.kt
index 1e5599bfe1d5..93ba26517e37 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepositoryTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepositoryTest.kt
@@ -19,7 +19,6 @@ package com.android.systemui.qs.panels.data.repository
import android.content.ComponentName
import android.content.packageManager
import android.content.pm.PackageManager
-import android.content.pm.ServiceInfo
import android.content.pm.UserInfo
import android.graphics.drawable.TestStubDrawable
import androidx.test.ext.junit.runners.AndroidJUnit4
@@ -35,6 +34,7 @@ import com.android.systemui.qs.pipeline.data.repository.FakeInstalledTilesCompon
import com.android.systemui.qs.pipeline.data.repository.fakeInstalledTilesRepository
import com.android.systemui.qs.pipeline.data.repository.installedTilesRepository
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.settings.FakeUserTracker
import com.android.systemui.settings.fakeUserTracker
import com.android.systemui.testKosmos
@@ -100,6 +100,7 @@ class IconAndNameCustomRepositoryTest : SysuiTestCase() {
Icon.Loaded(drawable1, ContentDescription.Loaded(tileService1)),
Text.Loaded(tileService1),
Text.Loaded(appName1),
+ TileCategory.PROVIDED_BY_APP,
)
val expectedData2 =
EditTileData(
@@ -107,6 +108,7 @@ class IconAndNameCustomRepositoryTest : SysuiTestCase() {
Icon.Loaded(drawable2, ContentDescription.Loaded(tileService2)),
Text.Loaded(tileService2),
Text.Loaded(appName2),
+ TileCategory.PROVIDED_BY_APP,
)
assertThat(editTileDataList).containsExactly(expectedData1, expectedData2)
@@ -144,6 +146,7 @@ class IconAndNameCustomRepositoryTest : SysuiTestCase() {
Icon.Loaded(drawable1, ContentDescription.Loaded(tileService1)),
Text.Loaded(tileService1),
Text.Loaded(appName1),
+ TileCategory.PROVIDED_BY_APP,
)
val editTileDataList = underTest.getCustomTileData()
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractorTest.kt
index deefbf585ba9..053a59aa533a 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractorTest.kt
@@ -31,6 +31,7 @@ import com.android.systemui.qs.panels.shared.model.EditTileData
import com.android.systemui.qs.pipeline.data.repository.FakeInstalledTilesComponentRepository
import com.android.systemui.qs.pipeline.data.repository.fakeInstalledTilesRepository
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tiles.impl.battery.qsBatterySaverTileConfig
import com.android.systemui.qs.tiles.impl.flashlight.qsFlashlightTileConfig
import com.android.systemui.qs.tiles.impl.internet.qsInternetTileConfig
@@ -132,6 +133,7 @@ class EditTilesListInteractorTest : SysuiTestCase() {
icon = Icon.Loaded(icon, ContentDescription.Loaded(tileName)),
label = Text.Loaded(tileName),
appName = Text.Loaded(appName),
+ category = TileCategory.PROVIDED_BY_APP,
)
assertThat(editTiles.customTiles).hasSize(1)
@@ -181,7 +183,8 @@ class EditTilesListInteractorTest : SysuiTestCase() {
tileSpec = this,
icon = Icon.Resource(android.R.drawable.star_on, ContentDescription.Loaded(spec)),
label = Text.Loaded(spec),
- appName = null
+ appName = null,
+ category = TileCategory.UNKNOWN,
)
}
@@ -192,6 +195,7 @@ class EditTilesListInteractorTest : SysuiTestCase() {
Icon.Resource(uiConfig.iconRes, ContentDescription.Resource(uiConfig.labelRes)),
label = Text.Resource(uiConfig.labelRes),
appName = null,
+ category = category,
)
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/EditTileListStateTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/EditTileListStateTest.kt
index 7f01fad1ce55..484a8ff973c1 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/EditTileListStateTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/compose/EditTileListStateTest.kt
@@ -16,11 +16,11 @@
package com.android.systemui.qs.panels.ui.compose
+import androidx.compose.ui.text.AnnotatedString
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.Icon
-import com.android.systemui.common.shared.model.Text
import com.android.systemui.qs.panels.shared.model.SizedTile
import com.android.systemui.qs.panels.shared.model.SizedTileImpl
import com.android.systemui.qs.panels.ui.model.GridCell
@@ -28,6 +28,7 @@ import com.android.systemui.qs.panels.ui.model.SpacerGridCell
import com.android.systemui.qs.panels.ui.model.TileGridCell
import com.android.systemui.qs.panels.ui.viewmodel.EditTileViewModel
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@@ -141,10 +142,11 @@ class EditTileListStateTest : SysuiTestCase() {
EditTileViewModel(
tileSpec = TileSpec.create(tileSpec),
icon = Icon.Resource(0, null),
- label = Text.Loaded("unused"),
+ label = AnnotatedString("unused"),
appName = null,
isCurrent = true,
availableEditActions = emptySet(),
+ category = TileCategory.UNKNOWN,
),
width,
)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelTest.kt
index 601779f8fb02..583db722a759 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelTest.kt
@@ -26,6 +26,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Text
+import com.android.systemui.common.ui.compose.toAnnotatedString
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testScope
@@ -42,6 +43,7 @@ import com.android.systemui.qs.pipeline.data.repository.fakeMinimumTilesReposito
import com.android.systemui.qs.pipeline.domain.interactor.currentTilesInteractor
import com.android.systemui.qs.pipeline.shared.TileSpec
import com.android.systemui.qs.qsTileFactory
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tiles.impl.alarm.qsAlarmTileConfig
import com.android.systemui.qs.tiles.impl.battery.qsBatterySaverTileConfig
import com.android.systemui.qs.tiles.impl.flashlight.qsFlashlightTileConfig
@@ -190,7 +192,7 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
.forEach {
val data = getEditTileData(it.tileSpec)
- assertThat(it.label).isEqualTo(data.label)
+ assertThat(it.label).isEqualTo(data.label.toAnnotatedString(context))
assertThat(it.icon).isEqualTo(data.icon)
assertThat(it.appName).isNull()
}
@@ -224,15 +226,19 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
// service1
val model1 = tiles!!.first { it.tileSpec == TileSpec.create(component1) }
- assertThat(model1.label).isEqualTo(Text.Loaded(tileService1))
- assertThat(model1.appName).isEqualTo(Text.Loaded(appName1))
+ assertThat(model1.label)
+ .isEqualTo(Text.Loaded(tileService1).toAnnotatedString(context))
+ assertThat(model1.appName)
+ .isEqualTo(Text.Loaded(appName1).toAnnotatedString(context))
assertThat(model1.icon)
.isEqualTo(Icon.Loaded(drawable1, ContentDescription.Loaded(tileService1)))
// service2
val model2 = tiles!!.first { it.tileSpec == TileSpec.create(component2) }
- assertThat(model2.label).isEqualTo(Text.Loaded(tileService2))
- assertThat(model2.appName).isEqualTo(Text.Loaded(appName2))
+ assertThat(model2.label)
+ .isEqualTo(Text.Loaded(tileService2).toAnnotatedString(context))
+ assertThat(model2.appName)
+ .isEqualTo(Text.Loaded(appName2).toAnnotatedString(context))
assertThat(model2.icon)
.isEqualTo(Icon.Loaded(drawable2, ContentDescription.Loaded(tileService2)))
}
@@ -559,7 +565,8 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
tileSpec = this,
icon = Icon.Resource(R.drawable.star_on, ContentDescription.Loaded(spec)),
label = Text.Loaded(spec),
- appName = null
+ appName = null,
+ category = TileCategory.UNKNOWN,
)
}
@@ -570,6 +577,7 @@ class EditModeViewModelTest(flags: FlagsParameterization) : SysuiTestCase() {
Icon.Resource(uiConfig.iconRes, ContentDescription.Resource(uiConfig.labelRes)),
label = Text.Resource(uiConfig.labelRes),
appName = null,
+ category = category,
)
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/shared/model/GroupAndSortCategoryAndNameTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/shared/model/GroupAndSortCategoryAndNameTest.kt
new file mode 100644
index 000000000000..7f90e3b6f5e0
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/shared/model/GroupAndSortCategoryAndNameTest.kt
@@ -0,0 +1,87 @@
+/*
+ * Copyright (C) 2024 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.qs.shared.model
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class GroupAndSortCategoryAndNameTest : SysuiTestCase() {
+
+ private val elements =
+ listOf(
+ CategoryAndName(TileCategory.DISPLAY, "B"),
+ CategoryAndName(TileCategory.PRIVACY, "A"),
+ CategoryAndName(TileCategory.DISPLAY, "C"),
+ CategoryAndName(TileCategory.UTILITIES, "B"),
+ CategoryAndName(TileCategory.CONNECTIVITY, "A"),
+ CategoryAndName(TileCategory.PROVIDED_BY_APP, "B"),
+ CategoryAndName(TileCategory.CONNECTIVITY, "C"),
+ CategoryAndName(TileCategory.ACCESSIBILITY, "A")
+ )
+
+ @Test
+ fun allElementsInResult() {
+ val grouped = groupAndSort(elements)
+ val allValues = grouped.values.reduce { acc, el -> acc + el }
+ assertThat(allValues).containsExactlyElementsIn(elements)
+ }
+
+ @Test
+ fun groupedByCategory() {
+ val grouped = groupAndSort(elements)
+ grouped.forEach { tileCategory, categoryAndNames ->
+ categoryAndNames.forEach { element ->
+ assertThat(element.category).isEqualTo(tileCategory)
+ }
+ }
+ }
+
+ @Test
+ fun sortedAlphabeticallyInEachCategory() {
+ val grouped = groupAndSort(elements)
+ grouped.values.forEach { elements ->
+ assertThat(elements.map(CategoryAndName::name)).isInOrder()
+ }
+ }
+
+ @Test
+ fun categoriesSortedInNaturalOrder() {
+ val grouped = groupAndSort(elements)
+ assertThat(grouped.keys).isInOrder()
+ }
+
+ @Test
+ fun missingCategoriesAreNotInResult() {
+ val grouped = groupAndSort(elements.filterNot { it.category == TileCategory.CONNECTIVITY })
+ assertThat(grouped.keys).doesNotContain(TileCategory.CONNECTIVITY)
+ }
+
+ companion object {
+ private fun CategoryAndName(category: TileCategory, name: String): CategoryAndName {
+ return object : CategoryAndName {
+ override val category = category
+ override val name = name
+ }
+ }
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt
index aaad0fc1b644..5a4506086058 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/internet/domain/interactor/InternetTileDataInteractorTest.kt
@@ -184,7 +184,7 @@ class InternetTileDataInteractorTest : SysuiTestCase() {
)
val networkModel =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = 4,
ssid = "test ssid",
)
@@ -219,7 +219,7 @@ class InternetTileDataInteractorTest : SysuiTestCase() {
)
val networkModel =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = 4,
ssid = "test ssid",
hotspotDeviceType = WifiNetworkModel.HotspotDeviceType.NONE,
@@ -398,7 +398,7 @@ class InternetTileDataInteractorTest : SysuiTestCase() {
collectLastValue(
underTest.tileData(testUser, flowOf(DataUpdateTrigger.InitialRequest))
)
- val networkModel = WifiNetworkModel.Inactive
+ val networkModel = WifiNetworkModel.Inactive()
connectivityRepository.setWifiConnected(validated = false)
wifiRepository.setIsWifiDefault(true)
@@ -416,7 +416,7 @@ class InternetTileDataInteractorTest : SysuiTestCase() {
underTest.tileData(testUser, flowOf(DataUpdateTrigger.InitialRequest))
)
- val networkModel = WifiNetworkModel.Inactive
+ val networkModel = WifiNetworkModel.Inactive()
connectivityRepository.setWifiConnected(validated = false)
wifiRepository.setIsWifiDefault(true)
@@ -543,7 +543,7 @@ class InternetTileDataInteractorTest : SysuiTestCase() {
private fun setWifiNetworkWithHotspot(hotspot: WifiNetworkModel.HotspotDeviceType) {
val networkModel =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = 4,
ssid = "test ssid",
hotspotDeviceType = hotspot,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapperTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapperTest.kt
index 244422943309..fa6d8bf4a317 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapperTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/qs/tiles/impl/irecording/IssueRecordingMapperTest.kt
@@ -24,6 +24,7 @@ import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testCase
import com.android.systemui.qs.pipeline.shared.TileSpec
import com.android.systemui.qs.qsEventLogger
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tiles.viewmodel.QSTileConfig
import com.android.systemui.qs.tiles.viewmodel.QSTileState
import com.android.systemui.qs.tiles.viewmodel.QSTileUIConfig
@@ -43,7 +44,8 @@ class IssueRecordingMapperTest : SysuiTestCase() {
QSTileConfig(
TileSpec.create(RecordIssueModule.TILE_SPEC),
uiConfig,
- kosmos.qsEventLogger.getNewInstanceId()
+ kosmos.qsEventLogger.getNewInstanceId(),
+ TileCategory.UTILITIES,
)
private val resources = kosmos.mainResources
private val theme = resources.newTheme()
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImplTest.kt
index 9464c75eeb71..d163abf66b05 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImplTest.kt
@@ -19,8 +19,6 @@ package com.android.systemui.shade.domain.interactor
import android.app.StatusBarManager.DISABLE2_NONE
import android.app.StatusBarManager.DISABLE2_NOTIFICATION_SHADE
import android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS
-import android.platform.test.annotations.DisableFlags
-import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
@@ -38,11 +36,7 @@ import com.android.systemui.kosmos.testScope
import com.android.systemui.power.data.repository.fakePowerRepository
import com.android.systemui.power.shared.model.WakeSleepReason
import com.android.systemui.power.shared.model.WakefulnessState
-import com.android.systemui.shade.data.repository.fakeShadeRepository
-import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.shadeTestUtil
-import com.android.systemui.shade.shared.flag.DualShade
-import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.disableflags.data.model.DisableFlagsModel
import com.android.systemui.statusbar.disableflags.data.repository.fakeDisableFlagsRepository
import com.android.systemui.statusbar.phone.dozeParameters
@@ -73,7 +67,6 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
private val keyguardRepository by lazy { kosmos.fakeKeyguardRepository }
private val keyguardTransitionRepository by lazy { kosmos.fakeKeyguardTransitionRepository }
private val powerRepository by lazy { kosmos.fakePowerRepository }
- private val shadeRepository by lazy { kosmos.fakeShadeRepository }
private val shadeTestUtil by lazy { kosmos.shadeTestUtil }
private val userRepository by lazy { kosmos.fakeUserRepository }
private val userSetupRepository by lazy { kosmos.fakeUserSetupRepository }
@@ -142,9 +135,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
userSetupRepository.setUserSetUp(true)
disableFlagsRepository.disableFlags.value =
- DisableFlagsModel(
- disable2 = DISABLE2_NOTIFICATION_SHADE,
- )
+ DisableFlagsModel(disable2 = DISABLE2_NOTIFICATION_SHADE)
val actual by collectLastValue(underTest.isExpandToQsEnabled)
@@ -158,9 +149,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
userSetupRepository.setUserSetUp(true)
disableFlagsRepository.disableFlags.value =
- DisableFlagsModel(
- disable2 = DISABLE2_QUICK_SETTINGS,
- )
+ DisableFlagsModel(disable2 = DISABLE2_QUICK_SETTINGS)
val actual by collectLastValue(underTest.isExpandToQsEnabled)
assertThat(actual).isFalse()
@@ -171,10 +160,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
testScope.runTest {
deviceProvisioningRepository.setDeviceProvisioned(true)
userSetupRepository.setUserSetUp(true)
- disableFlagsRepository.disableFlags.value =
- DisableFlagsModel(
- disable2 = DISABLE2_NONE,
- )
+ disableFlagsRepository.disableFlags.value = DisableFlagsModel(disable2 = DISABLE2_NONE)
keyguardRepository.setIsDozing(true)
@@ -188,10 +174,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
testScope.runTest {
deviceProvisioningRepository.setDeviceProvisioned(true)
keyguardRepository.setIsDozing(false)
- disableFlagsRepository.disableFlags.value =
- DisableFlagsModel(
- disable2 = DISABLE2_NONE,
- )
+ disableFlagsRepository.disableFlags.value = DisableFlagsModel(disable2 = DISABLE2_NONE)
userSetupRepository.setUserSetUp(true)
@@ -205,10 +188,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
testScope.runTest {
deviceProvisioningRepository.setDeviceProvisioned(true)
keyguardRepository.setIsDozing(false)
- disableFlagsRepository.disableFlags.value =
- DisableFlagsModel(
- disable2 = DISABLE2_NONE,
- )
+ disableFlagsRepository.disableFlags.value = DisableFlagsModel(disable2 = DISABLE2_NONE)
userRepository.setSettings(UserSwitcherSettingsModel(isSimpleUserSwitcher = false))
@@ -222,10 +202,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
testScope.runTest {
deviceProvisioningRepository.setDeviceProvisioned(true)
keyguardRepository.setIsDozing(false)
- disableFlagsRepository.disableFlags.value =
- DisableFlagsModel(
- disable2 = DISABLE2_NONE,
- )
+ disableFlagsRepository.disableFlags.value = DisableFlagsModel(disable2 = DISABLE2_NONE)
userSetupRepository.setUserSetUp(true)
val actual by collectLastValue(underTest.isExpandToQsEnabled)
@@ -250,10 +227,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
testScope.runTest {
deviceProvisioningRepository.setDeviceProvisioned(true)
keyguardRepository.setIsDozing(false)
- disableFlagsRepository.disableFlags.value =
- DisableFlagsModel(
- disable2 = DISABLE2_NONE,
- )
+ disableFlagsRepository.disableFlags.value = DisableFlagsModel(disable2 = DISABLE2_NONE)
userSetupRepository.setUserSetUp(true)
val actual by collectLastValue(underTest.isExpandToQsEnabled)
@@ -262,17 +236,12 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
// WHEN QS is disabled
disableFlagsRepository.disableFlags.value =
- DisableFlagsModel(
- disable2 = DISABLE2_QUICK_SETTINGS,
- )
+ DisableFlagsModel(disable2 = DISABLE2_QUICK_SETTINGS)
// THEN expand is disabled
assertThat(actual).isFalse()
// WHEN QS is enabled
- disableFlagsRepository.disableFlags.value =
- DisableFlagsModel(
- disable2 = DISABLE2_NONE,
- )
+ disableFlagsRepository.disableFlags.value = DisableFlagsModel(disable2 = DISABLE2_NONE)
// THEN expand is enabled
assertThat(actual).isTrue()
}
@@ -282,10 +251,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
testScope.runTest {
deviceProvisioningRepository.setDeviceProvisioned(true)
keyguardRepository.setIsDozing(false)
- disableFlagsRepository.disableFlags.value =
- DisableFlagsModel(
- disable2 = DISABLE2_NONE,
- )
+ disableFlagsRepository.disableFlags.value = DisableFlagsModel(disable2 = DISABLE2_NONE)
userSetupRepository.setUserSetUp(true)
val actual by collectLastValue(underTest.isExpandToQsEnabled)
@@ -359,9 +325,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
)
)
keyguardRepository.setDozeTransitionModel(
- DozeTransitionModel(
- to = DozeStateModel.DOZE_AOD,
- )
+ DozeTransitionModel(to = DozeStateModel.DOZE_AOD)
)
val isShadeTouchable by collectLastValue(underTest.isShadeTouchable)
assertThat(isShadeTouchable).isFalse()
@@ -385,9 +349,7 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
)
)
keyguardRepository.setDozeTransitionModel(
- DozeTransitionModel(
- to = DozeStateModel.DOZE_PULSING,
- )
+ DozeTransitionModel(to = DozeStateModel.DOZE_PULSING)
)
val isShadeTouchable by collectLastValue(underTest.isShadeTouchable)
assertThat(isShadeTouchable).isTrue()
@@ -450,71 +412,9 @@ class ShadeInteractorImplTest(flags: FlagsParameterization) : SysuiTestCase() {
lastSleepReason = WakeSleepReason.OTHER,
)
keyguardTransitionRepository.sendTransitionStep(
- TransitionStep(
- transitionState = TransitionState.STARTED,
- )
+ TransitionStep(transitionState = TransitionState.STARTED)
)
val isShadeTouchable by collectLastValue(underTest.isShadeTouchable)
assertThat(isShadeTouchable).isTrue()
}
-
- @Test
- @DisableFlags(DualShade.FLAG_NAME)
- fun legacyShadeMode_narrowScreen_singleShade() =
- testScope.runTest {
- val shadeMode by collectLastValue(underTest.shadeMode)
- kosmos.shadeRepository.setShadeLayoutWide(false)
-
- assertThat(shadeMode).isEqualTo(ShadeMode.Single)
- }
-
- @Test
- @DisableFlags(DualShade.FLAG_NAME)
- fun legacyShadeMode_wideScreen_splitShade() =
- testScope.runTest {
- val shadeMode by collectLastValue(underTest.shadeMode)
- kosmos.shadeRepository.setShadeLayoutWide(true)
-
- assertThat(shadeMode).isEqualTo(ShadeMode.Split)
- }
-
- @Test
- @EnableFlags(DualShade.FLAG_NAME)
- fun shadeMode_wideScreen_isDual() =
- testScope.runTest {
- val shadeMode by collectLastValue(underTest.shadeMode)
- kosmos.shadeRepository.setShadeLayoutWide(true)
-
- assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
- }
-
- @Test
- @EnableFlags(DualShade.FLAG_NAME)
- fun shadeMode_narrowScreen_isDual() =
- testScope.runTest {
- val shadeMode by collectLastValue(underTest.shadeMode)
- kosmos.shadeRepository.setShadeLayoutWide(false)
-
- assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
- }
-
- @Test
- fun getTopEdgeSplitFraction_narrowScreen_splitInHalf() =
- testScope.runTest {
- // Ensure isShadeLayoutWide is collected.
- val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide)
- shadeRepository.setShadeLayoutWide(false)
-
- assertThat(underTest.getTopEdgeSplitFraction()).isEqualTo(0.5f)
- }
-
- @Test
- fun getTopEdgeSplitFraction_wideScreen_leftSideLarger() =
- testScope.runTest {
- // Ensure isShadeLayoutWide is collected.
- val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide)
- shadeRepository.setShadeLayoutWide(true)
-
- assertThat(underTest.getTopEdgeSplitFraction()).isGreaterThan(0.5f)
- }
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorImplTest.kt
new file mode 100644
index 000000000000..2a2817b9af73
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorImplTest.kt
@@ -0,0 +1,109 @@
+/*
+ * Copyright (C) 2024 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.shade.domain.interactor
+
+import android.platform.test.annotations.DisableFlags
+import android.platform.test.annotations.EnableFlags
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.coroutines.collectLastValue
+import com.android.systemui.kosmos.testScope
+import com.android.systemui.shade.data.repository.shadeRepository
+import com.android.systemui.shade.shared.flag.DualShade
+import com.android.systemui.shade.shared.model.ShadeMode
+import com.android.systemui.testKosmos
+import com.google.common.truth.Truth.assertThat
+import kotlinx.coroutines.test.runTest
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class ShadeModeInteractorImplTest : SysuiTestCase() {
+
+ private val kosmos = testKosmos()
+ private val testScope = kosmos.testScope
+
+ private lateinit var underTest: ShadeModeInteractor
+
+ @Before
+ fun setUp() {
+ underTest = kosmos.shadeModeInteractor
+ }
+
+ @Test
+ @DisableFlags(DualShade.FLAG_NAME)
+ fun legacyShadeMode_narrowScreen_singleShade() =
+ testScope.runTest {
+ val shadeMode by collectLastValue(underTest.shadeMode)
+ kosmos.shadeRepository.setShadeLayoutWide(false)
+
+ assertThat(shadeMode).isEqualTo(ShadeMode.Single)
+ }
+
+ @Test
+ @DisableFlags(DualShade.FLAG_NAME)
+ fun legacyShadeMode_wideScreen_splitShade() =
+ testScope.runTest {
+ val shadeMode by collectLastValue(underTest.shadeMode)
+ kosmos.shadeRepository.setShadeLayoutWide(true)
+
+ assertThat(shadeMode).isEqualTo(ShadeMode.Split)
+ }
+
+ @Test
+ @EnableFlags(DualShade.FLAG_NAME)
+ fun shadeMode_wideScreen_isDual() =
+ testScope.runTest {
+ val shadeMode by collectLastValue(underTest.shadeMode)
+ kosmos.shadeRepository.setShadeLayoutWide(true)
+
+ assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
+ }
+
+ @Test
+ @EnableFlags(DualShade.FLAG_NAME)
+ fun shadeMode_narrowScreen_isDual() =
+ testScope.runTest {
+ val shadeMode by collectLastValue(underTest.shadeMode)
+ kosmos.shadeRepository.setShadeLayoutWide(false)
+
+ assertThat(shadeMode).isEqualTo(ShadeMode.Dual)
+ }
+
+ @Test
+ fun getTopEdgeSplitFraction_narrowScreen_splitInHalf() =
+ testScope.runTest {
+ // Ensure isShadeLayoutWide is collected.
+ val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide)
+ kosmos.shadeRepository.setShadeLayoutWide(false)
+
+ assertThat(underTest.getTopEdgeSplitFraction()).isEqualTo(0.5f)
+ }
+
+ @Test
+ fun getTopEdgeSplitFraction_wideScreen_leftSideLarger() =
+ testScope.runTest {
+ // Ensure isShadeLayoutWide is collected.
+ val isShadeLayoutWide by collectLastValue(underTest.isShadeLayoutWide)
+ kosmos.shadeRepository.setShadeLayoutWide(true)
+
+ assertThat(underTest.getTopEdgeSplitFraction()).isGreaterThan(0.5f)
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/wifi/domain/interactor/WifiInteractorImplTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/wifi/domain/interactor/WifiInteractorImplTest.kt
index b9ca8fc2d181..c0a15922642e 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/wifi/domain/interactor/WifiInteractorImplTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/wifi/domain/interactor/WifiInteractorImplTest.kt
@@ -78,7 +78,7 @@ class WifiInteractorImplTest : SysuiTestCase() {
@Test
fun ssid_inactiveNetwork_outputsNull() =
testScope.runTest {
- wifiRepository.setWifiNetwork(WifiNetworkModel.Inactive)
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Inactive())
var latest: String? = "default"
val job = underTest.ssid.onEach { latest = it }.launchIn(this)
@@ -93,7 +93,7 @@ class WifiInteractorImplTest : SysuiTestCase() {
fun ssid_carrierMergedNetwork_outputsNull() =
testScope.runTest {
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(subscriptionId = 2, level = 1)
+ WifiNetworkModel.CarrierMerged.of(subscriptionId = 2, level = 1)
)
var latest: String? = "default"
@@ -109,7 +109,7 @@ class WifiInteractorImplTest : SysuiTestCase() {
fun ssid_unknownSsid_outputsNull() =
testScope.runTest {
wifiRepository.setWifiNetwork(
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = 1,
ssid = WifiManager.UNKNOWN_SSID,
)
@@ -128,7 +128,7 @@ class WifiInteractorImplTest : SysuiTestCase() {
fun ssid_validSsid_outputsSsid() =
testScope.runTest {
wifiRepository.setWifiNetwork(
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = 1,
ssid = "MyAwesomeWifiNetwork",
)
@@ -189,7 +189,7 @@ class WifiInteractorImplTest : SysuiTestCase() {
fun wifiNetwork_matchesRepoWifiNetwork() =
testScope.runTest {
val wifiNetwork =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
isValidated = true,
level = 3,
ssid = "AB",
@@ -263,7 +263,7 @@ class WifiInteractorImplTest : SysuiTestCase() {
val latest by collectLastValue(underTest.areNetworksAvailable)
wifiRepository.wifiScanResults.value = emptyList()
- wifiRepository.setWifiNetwork(WifiNetworkModel.Inactive)
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Inactive())
assertThat(latest).isFalse()
}
@@ -280,7 +280,7 @@ class WifiInteractorImplTest : SysuiTestCase() {
WifiScanEntry(ssid = "ssid 3"),
)
- wifiRepository.setWifiNetwork(WifiNetworkModel.Inactive)
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Inactive())
assertThat(latest).isTrue()
}
@@ -298,7 +298,7 @@ class WifiInteractorImplTest : SysuiTestCase() {
)
wifiRepository.setWifiNetwork(
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
ssid = "ssid 2",
level = 2,
)
@@ -318,7 +318,7 @@ class WifiInteractorImplTest : SysuiTestCase() {
)
wifiRepository.setWifiNetwork(
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
ssid = "ssid 2",
level = 2,
)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelTest.kt
index 72a45b9b5452..141e304b63a1 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelTest.kt
@@ -115,7 +115,7 @@ class WifiViewModelTest : SysuiTestCase() {
val latestKeyguard by collectLastValue(keyguard.wifiIcon)
val latestQs by collectLastValue(qs.wifiIcon)
- wifiRepository.setWifiNetwork(WifiNetworkModel.Active(isValidated = true, level = 1))
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Active.of(isValidated = true, level = 1))
assertThat(latestHome).isInstanceOf(WifiIcon.Visible::class.java)
assertThat(latestHome).isEqualTo(latestKeyguard)
@@ -129,7 +129,7 @@ class WifiViewModelTest : SysuiTestCase() {
// Even WHEN the network has a valid hotspot type
wifiRepository.setWifiNetwork(
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
isValidated = true,
level = 1,
hotspotDeviceType = WifiNetworkModel.HotspotDeviceType.LAPTOP,
@@ -191,7 +191,7 @@ class WifiViewModelTest : SysuiTestCase() {
whenever(connectivityConstants.shouldShowActivityConfig).thenReturn(true)
createAndSetViewModel()
- wifiRepository.setWifiNetwork(WifiNetworkModel.Active(ssid = null, level = 1))
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Active.of(ssid = null, level = 1))
val activityIn by collectLastValue(underTest.isActivityInViewVisible)
val activityOut by collectLastValue(underTest.isActivityOutViewVisible)
@@ -214,7 +214,7 @@ class WifiViewModelTest : SysuiTestCase() {
whenever(connectivityConstants.shouldShowActivityConfig).thenReturn(true)
createAndSetViewModel()
- wifiRepository.setWifiNetwork(WifiNetworkModel.Active(ssid = null, level = 1))
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Active.of(ssid = null, level = 1))
val activityIn by collectLastValue(underTest.isActivityInViewVisible)
val activityOut by collectLastValue(underTest.isActivityOutViewVisible)
@@ -463,6 +463,6 @@ class WifiViewModelTest : SysuiTestCase() {
}
companion object {
- private val ACTIVE_VALID_WIFI_NETWORK = WifiNetworkModel.Active(ssid = "AB", level = 1)
+ private val ACTIVE_VALID_WIFI_NETWORK = WifiNetworkModel.Active.of(ssid = "AB", level = 1)
}
}
diff --git a/packages/SystemUI/res/layout/biometric_prompt_one_pane_layout.xml b/packages/SystemUI/res/layout/biometric_prompt_one_pane_layout.xml
index 3b3ed39c8993..91cd019c85d1 100644
--- a/packages/SystemUI/res/layout/biometric_prompt_one_pane_layout.xml
+++ b/packages/SystemUI/res/layout/biometric_prompt_one_pane_layout.xml
@@ -215,17 +215,4 @@
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0"
tools:srcCompat="@tools:sample/avatars" />
-
- <com.android.systemui.biometrics.BiometricPromptLottieViewWrapper
- android:id="@+id/biometric_icon_overlay"
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_gravity="center"
- android:contentDescription="@null"
- android:scaleType="fitXY"
- android:importantForAccessibility="no"
- app:layout_constraintBottom_toBottomOf="@+id/biometric_icon"
- app:layout_constraintEnd_toEndOf="@+id/biometric_icon"
- app:layout_constraintStart_toStartOf="@+id/biometric_icon"
- app:layout_constraintTop_toTopOf="@+id/biometric_icon" />
</androidx.constraintlayout.widget.ConstraintLayout>
diff --git a/packages/SystemUI/res/layout/biometric_prompt_two_pane_layout.xml b/packages/SystemUI/res/layout/biometric_prompt_two_pane_layout.xml
index 2a00495e9d01..51117a7845df 100644
--- a/packages/SystemUI/res/layout/biometric_prompt_two_pane_layout.xml
+++ b/packages/SystemUI/res/layout/biometric_prompt_two_pane_layout.xml
@@ -40,19 +40,6 @@ android:layout_height="match_parent">
app:layout_constraintTop_toTopOf="parent"
tools:srcCompat="@tools:sample/avatars" />
- <com.android.systemui.biometrics.BiometricPromptLottieViewWrapper
- android:id="@+id/biometric_icon_overlay"
- android:layout_width="0dp"
- android:layout_height="0dp"
- android:layout_gravity="center"
- android:contentDescription="@null"
- android:scaleType="fitXY"
- android:importantForAccessibility="no"
- app:layout_constraintBottom_toBottomOf="@+id/biometric_icon"
- app:layout_constraintEnd_toEndOf="@+id/biometric_icon"
- app:layout_constraintStart_toStartOf="@+id/biometric_icon"
- app:layout_constraintTop_toTopOf="@+id/biometric_icon" />
-
<ScrollView
android:id="@+id/scrollView"
android:layout_width="0dp"
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 1fb1dad067f9..589d9ddd20b9 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -3812,4 +3812,33 @@ Action + ESC for this.</string>
<!-- Toast message for notifying users to use regular brightness bar to lower the brightness. [CHAR LIMIT=NONE] -->
<string name="accessibility_deprecate_extra_dim_dialog_toast">
Extra dim shortcut removed. To lower your brightness, use the regular brightness bar.</string>
+
+ <!-- Label for category in QS Edit mode list of tiles, for tiles that are related to connectivity, e.g. Internet. [CHAR LIMIT=NONE] -->
+ <string name="qs_edit_mode_category_connectivity">
+ Connectivity
+ </string>
+ <!-- Label for category in QS Edit mode list of tiles, for tiles that are related to accessibility functions, e.g. Hearing devices. [CHAR LIMIT=NONE] -->
+ <string name="qs_edit_mode_category_accessibility">
+ Accessibility
+ </string>
+ <!-- Label for category in QS Edit mode list of tiles, for tiles that are related to general utilities, e.g. Flashlight. [CHAR LIMIT=NONE] -->
+ <string name="qs_edit_mode_category_utilities">
+ Utilities
+ </string>
+ <!-- Label for category in QS Edit mode list of tiles, for tiles that are related to privacy, e.g. Mic access. [CHAR LIMIT=NONE] -->
+ <string name="qs_edit_mode_category_privacy">
+ Privacy
+ </string>
+ <!-- Label for category in QS Edit mode list of tiles, for tiles that are provided by an app, e.g. Calculator. [CHAR LIMIT=NONE] -->
+ <string name="qs_edit_mode_category_providedByApps">
+ Provided by apps
+ </string>
+ <!-- Label for category in QS Edit mode list of tiles, for tiles that are related to the display, e.g. Dark theme. [CHAR LIMIT=NONE] -->
+ <string name="qs_edit_mode_category_display">
+ Display
+ </string>
+ <!-- Label for category in QS Edit mode list of tiles, for tiles with an unknown category. [CHAR LIMIT=NONE] -->
+ <string name="qs_edit_mode_category_unknown">
+ Unknown
+ </string>
</resources>
diff --git a/packages/SystemUI/shared/src/com/android/systemui/dagger/qualifiers/DisplaySpecific.kt b/packages/SystemUI/shared/src/com/android/systemui/dagger/qualifiers/DisplaySpecific.kt
index 57a49c83ae17..3e39ae9a3fe5 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/dagger/qualifiers/DisplaySpecific.kt
+++ b/packages/SystemUI/shared/src/com/android/systemui/dagger/qualifiers/DisplaySpecific.kt
@@ -15,10 +15,7 @@
*/
package com.android.systemui.dagger.qualifiers
-import java.lang.annotation.Documented
-import java.lang.annotation.Retention
-import java.lang.annotation.RetentionPolicy.RUNTIME
import javax.inject.Qualifier
/** Annotates a class that is display specific. */
-@Qualifier @Documented @Retention(RUNTIME) annotation class DisplaySpecific
+@Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class DisplaySpecific
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl
index c00007b55482..283e4556d05c 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/IOverviewProxy.aidl
@@ -132,4 +132,9 @@ oneway interface IOverviewProxy {
* Sent when {@link TaskbarDelegate#transitionTo} is called.
*/
void transitionTo(int barMode, boolean animate) = 33;
+
+ /**
+ * Sent when {@link TaskbarDelegate#appTransitionPending} is called.
+ */
+ void appTransitionPending(boolean pending) = 34;
}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/RecentsTransition.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/RecentsTransition.java
index b8319e51ec3b..c8de9f6660f9 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/RecentsTransition.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/view/RecentsTransition.java
@@ -36,36 +36,6 @@ import java.util.function.Consumer;
public class RecentsTransition {
/**
- * Creates a new transition aspect scaled transition activity options.
- */
- public static ActivityOptions createAspectScaleAnimation(Context context, Handler handler,
- boolean scaleUp, AppTransitionAnimationSpecsFuture animationSpecsFuture,
- final Runnable animationStartCallback) {
- final OnAnimationStartedListener animStartedListener = new OnAnimationStartedListener() {
- private boolean mHandled;
-
- @Override
- public void onAnimationStarted(long elapsedRealTime) {
- // OnAnimationStartedListener can be called numerous times, so debounce here to
- // prevent multiple callbacks
- if (mHandled) {
- return;
- }
- mHandled = true;
-
- if (animationStartCallback != null) {
- animationStartCallback.run();
- }
- }
- };
- final ActivityOptions opts = ActivityOptions.makeMultiThumbFutureAspectScaleAnimation(
- context, handler,
- animationSpecsFuture != null ? animationSpecsFuture.getFuture() : null,
- animStartedListener, scaleUp);
- return opts;
- }
-
- /**
* Wraps a animation-start callback in a binder that can be called from window manager.
*/
public static IRemoteCallback wrapStartedListener(final Handler handler,
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationControllerCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationControllerCompat.java
index bbf46984208f..76af813fe2f8 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationControllerCompat.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationControllerCompat.java
@@ -18,13 +18,13 @@ package com.android.systemui.shared.system;
import android.os.RemoteException;
import android.util.Log;
-import android.view.IRecentsAnimationController;
import android.view.SurfaceControl;
import android.window.PictureInPictureSurfaceTransaction;
import android.window.TaskSnapshot;
import com.android.internal.os.IResultReceiver;
import com.android.systemui.shared.recents.model.ThumbnailData;
+import com.android.wm.shell.recents.IRecentsAnimationController;
public class RecentsAnimationControllerCompat {
@@ -58,14 +58,6 @@ public class RecentsAnimationControllerCompat {
}
}
- public void setAnimationTargetsBehindSystemBars(boolean behindSystemBars) {
- try {
- mAnimationController.setAnimationTargetsBehindSystemBars(behindSystemBars);
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to set whether animation targets are behind system bars", e);
- }
- }
-
/**
* Sets the final surface transaction on a Task. This is used by Launcher to notify the system
* that animating Activity to PiP has completed and the associated task surface should be
@@ -103,22 +95,6 @@ public class RecentsAnimationControllerCompat {
}
}
- public void setDeferCancelUntilNextTransition(boolean defer, boolean screenshot) {
- try {
- mAnimationController.setDeferCancelUntilNextTransition(defer, screenshot);
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to set deferred cancel with screenshot", e);
- }
- }
-
- public void cleanupScreenshot() {
- try {
- mAnimationController.cleanupScreenshot();
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to clean up screenshot of recents animation", e);
- }
- }
-
/**
* @see {{@link IRecentsAnimationController#setWillFinishToHome(boolean)}}.
*/
@@ -131,18 +107,6 @@ public class RecentsAnimationControllerCompat {
}
/**
- * @see IRecentsAnimationController#removeTask
- */
- public boolean removeTask(int taskId) {
- try {
- return mAnimationController.removeTask(taskId);
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to remove remote animation target", e);
- return false;
- }
- }
-
- /**
* @see IRecentsAnimationController#detachNavigationBarFromApp
*/
public void detachNavigationBarFromApp(boolean moveHomeToTop) {
@@ -152,15 +116,4 @@ public class RecentsAnimationControllerCompat {
Log.e(TAG, "Failed to detach the navigation bar from app", e);
}
}
-
- /**
- * @see IRecentsAnimationController#animateNavigationBarToApp(long)
- */
- public void animateNavigationBarToApp(long duration) {
- try {
- mAnimationController.animateNavigationBarToApp(duration);
- } catch (RemoteException e) {
- Log.e(TAG, "Failed to animate the navigation bar to app", e);
- }
- }
}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationListener.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationListener.java
index 24073501c946..51892aac606a 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationListener.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/RecentsAnimationListener.java
@@ -42,14 +42,4 @@ public interface RecentsAnimationListener {
* was running becomes ready for control.
*/
void onTasksAppeared(RemoteAnimationTarget[] app);
-
- /**
- * Called to request that the current task tile be switched out for a screenshot (if not
- * already). Once complete, onFinished should be called.
- * @return true if this impl will call onFinished. No other onSwitchToScreenshot impls will
- * be called afterwards (to avoid multiple calls to onFinished).
- */
- default boolean onSwitchToScreenshot(Runnable onFinished) {
- return false;
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityButtonModeObserver.java b/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityButtonModeObserver.java
index 2c97d62d690e..4d5e717536f6 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityButtonModeObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityButtonModeObserver.java
@@ -28,6 +28,7 @@ import android.util.Log;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.settings.UserTracker;
+import com.android.systemui.util.settings.SecureSettings;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -68,8 +69,9 @@ public class AccessibilityButtonModeObserver extends
}
@Inject
- public AccessibilityButtonModeObserver(Context context, UserTracker userTracker) {
- super(context, userTracker, Settings.Secure.ACCESSIBILITY_BUTTON_MODE);
+ public AccessibilityButtonModeObserver(
+ Context context, UserTracker userTracker, SecureSettings secureSettings) {
+ super(context, userTracker, secureSettings, Settings.Secure.ACCESSIBILITY_BUTTON_MODE);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityButtonTargetsObserver.java b/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityButtonTargetsObserver.java
index 53a21b329594..1363b1c12332 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityButtonTargetsObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityButtonTargetsObserver.java
@@ -24,6 +24,7 @@ import androidx.annotation.Nullable;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.settings.UserTracker;
+import com.android.systemui.util.settings.SecureSettings;
import javax.inject.Inject;
@@ -49,8 +50,9 @@ public class AccessibilityButtonTargetsObserver extends
}
@Inject
- public AccessibilityButtonTargetsObserver(Context context, UserTracker userTracker) {
- super(context, userTracker, Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
+ public AccessibilityButtonTargetsObserver(
+ Context context, UserTracker userTracker, SecureSettings secureSettings) {
+ super(context, userTracker, secureSettings, Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityGestureTargetsObserver.java b/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityGestureTargetsObserver.java
index c94487848b81..736217a699fd 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityGestureTargetsObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/AccessibilityGestureTargetsObserver.java
@@ -24,6 +24,7 @@ import androidx.annotation.Nullable;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.settings.UserTracker;
+import com.android.systemui.util.settings.SecureSettings;
import javax.inject.Inject;
@@ -49,8 +50,9 @@ public class AccessibilityGestureTargetsObserver extends
}
@Inject
- public AccessibilityGestureTargetsObserver(Context context, UserTracker userTracker) {
- super(context, userTracker, Settings.Secure.ACCESSIBILITY_GESTURE_TARGETS);
+ public AccessibilityGestureTargetsObserver(
+ Context context, UserTracker userTracker, SecureSettings secureSettings) {
+ super(context, userTracker, secureSettings, Settings.Secure.ACCESSIBILITY_GESTURE_TARGETS);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/SecureSettingsContentObserver.java b/packages/SystemUI/src/com/android/systemui/accessibility/SecureSettingsContentObserver.java
index 326773fb5bef..c50cf85feccb 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/SecureSettingsContentObserver.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/SecureSettingsContentObserver.java
@@ -28,6 +28,7 @@ import androidx.annotation.NonNull;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.settings.UserTracker;
+import com.android.systemui.util.settings.SecureSettings;
import java.util.ArrayList;
import java.util.List;
@@ -48,6 +49,7 @@ public abstract class SecureSettingsContentObserver<T> {
private final UserTracker mUserTracker;
@VisibleForTesting
final ContentObserver mContentObserver;
+ private final SecureSettings mSecureSettings;
private final String mKey;
@@ -55,7 +57,7 @@ public abstract class SecureSettingsContentObserver<T> {
final List<T> mListeners = new ArrayList<>();
protected SecureSettingsContentObserver(Context context, UserTracker userTracker,
- String secureSettingsKey) {
+ SecureSettings secureSettings, String secureSettingsKey) {
mKey = secureSettingsKey;
mContentResolver = context.getContentResolver();
mUserTracker = userTracker;
@@ -65,6 +67,7 @@ public abstract class SecureSettingsContentObserver<T> {
updateValueChanged();
}
};
+ mSecureSettings = secureSettings;
}
/**
@@ -80,9 +83,8 @@ public abstract class SecureSettingsContentObserver<T> {
}
if (mListeners.size() == 1) {
- mContentResolver.registerContentObserver(
- Settings.Secure.getUriFor(mKey), /* notifyForDescendants= */
- false, mContentObserver, UserHandle.USER_ALL);
+ mSecureSettings.registerContentObserverForUserAsync(Settings.Secure.getUriFor(mKey),
+ /* notifyForDescendants= */ false, mContentObserver, UserHandle.USER_ALL);
}
}
@@ -97,7 +99,7 @@ public abstract class SecureSettingsContentObserver<T> {
mListeners.remove(listener);
if (mListeners.isEmpty()) {
- mContentResolver.unregisterContentObserver(mContentObserver);
+ mSecureSettings.unregisterContentObserverAsync(mContentObserver);
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java b/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java
index 7750f6bf4178..51c5b00daae4 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/SystemActions.java
@@ -18,8 +18,6 @@ package com.android.systemui.accessibility;
import static android.view.WindowManager.ScreenshotSource.SCREENSHOT_ACCESSIBILITY_ACTIONS;
-import static com.android.internal.accessibility.common.ShortcutConstants.CHOOSER_PACKAGE_NAME;
-
import android.accessibilityservice.AccessibilityService;
import android.app.PendingIntent;
import android.app.RemoteAction;
@@ -45,7 +43,6 @@ import android.view.accessibility.AccessibilityManager;
import android.view.accessibility.Flags;
import com.android.internal.R;
-import com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity;
import com.android.internal.accessibility.util.AccessibilityUtils;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ScreenshotHelper;
@@ -561,16 +558,13 @@ public class SystemActions implements CoreStartable, ConfigurationController.Con
}
private void handleAccessibilityButton() {
- AccessibilityManager.getInstance(mContext).notifyAccessibilityButtonClicked(
+ mA11yManager.notifyAccessibilityButtonClicked(
mDisplayTracker.getDefaultDisplayId());
}
private void handleAccessibilityButtonChooser() {
- final Intent intent = new Intent(AccessibilityManager.ACTION_CHOOSE_ACCESSIBILITY_BUTTON);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- final String chooserClassName = AccessibilityButtonChooserActivity.class.getName();
- intent.setClassName(CHOOSER_PACKAGE_NAME, chooserClassName);
- mContext.startActivityAsUser(intent, mUserTracker.getUserHandle());
+ mA11yManager.notifyAccessibilityButtonLongClicked(
+ mDisplayTracker.getDefaultDisplayId());
}
private void handleAccessibilityShortcut() {
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/qs/QSAccessibilityModule.kt b/packages/SystemUI/src/com/android/systemui/accessibility/qs/QSAccessibilityModule.kt
index bb80396c70fb..cd9efaf6e6bb 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/qs/QSAccessibilityModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/qs/QSAccessibilityModule.kt
@@ -19,6 +19,7 @@ package com.android.systemui.accessibility.qs
import com.android.systemui.Flags
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.qs.tiles.ColorCorrectionTile
import com.android.systemui.qs.tiles.ColorInversionTile
@@ -179,6 +180,7 @@ interface QSAccessibilityModule {
labelRes = R.string.quick_settings_color_correction_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.ACCESSIBILITY,
)
/** Inject ColorCorrectionTile into tileViewModelMap in QSModule */
@@ -210,6 +212,7 @@ interface QSAccessibilityModule {
labelRes = R.string.quick_settings_inversion_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.ACCESSIBILITY,
)
/** Inject ColorInversionTile into tileViewModelMap in QSModule */
@@ -241,6 +244,7 @@ interface QSAccessibilityModule {
labelRes = R.string.quick_settings_font_scaling_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.DISPLAY,
)
/** Inject FontScaling Tile into tileViewModelMap in QSModule */
@@ -272,6 +276,7 @@ interface QSAccessibilityModule {
labelRes = com.android.internal.R.string.reduce_bright_colors_feature_name,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.DISPLAY,
)
@Provides
@@ -286,6 +291,7 @@ interface QSAccessibilityModule {
labelRes = R.string.quick_settings_hearing_devices_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.ACCESSIBILITY,
)
/**
@@ -322,6 +328,7 @@ interface QSAccessibilityModule {
labelRes = R.string.quick_settings_onehanded_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.ACCESSIBILITY,
)
/** Inject One Handed Mode Tile into tileViewModelMap in QSModule. */
@@ -355,6 +362,7 @@ interface QSAccessibilityModule {
labelRes = R.string.quick_settings_night_display_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.DISPLAY,
)
/**
diff --git a/packages/SystemUI/src/com/android/systemui/battery/BatterySaverModule.kt b/packages/SystemUI/src/com/android/systemui/battery/BatterySaverModule.kt
index 8a9a322ff100..831bc1da5a79 100644
--- a/packages/SystemUI/src/com/android/systemui/battery/BatterySaverModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/battery/BatterySaverModule.kt
@@ -2,6 +2,7 @@ package com.android.systemui.battery
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.qs.tiles.BatterySaverTile
import com.android.systemui.qs.tiles.base.interactor.QSTileAvailabilityInteractor
@@ -33,7 +34,7 @@ interface BatterySaverModule {
@IntoMap
@StringKey(BATTERY_SAVER_TILE_SPEC)
fun provideBatterySaverAvailabilityInteractor(
- impl: BatterySaverTileDataInteractor
+ impl: BatterySaverTileDataInteractor
): QSTileAvailabilityInteractor
companion object {
@@ -51,6 +52,7 @@ interface BatterySaverModule {
labelRes = R.string.battery_detail_switch_title,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.UTILITIES,
)
/** Inject BatterySaverTile into tileViewModelMap in QSModule */
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/domain/BiometricsDomainLayerModule.kt b/packages/SystemUI/src/com/android/systemui/biometrics/domain/BiometricsDomainLayerModule.kt
index ec3fd9f7da35..7ecbb88099cb 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/domain/BiometricsDomainLayerModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/domain/BiometricsDomainLayerModule.kt
@@ -25,6 +25,8 @@ import com.android.systemui.biometrics.domain.interactor.LogContextInteractor
import com.android.systemui.biometrics.domain.interactor.LogContextInteractorImpl
import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractor
import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractorImpl
+import com.android.systemui.biometrics.domain.interactor.SideFpsOverlayInteractor
+import com.android.systemui.biometrics.domain.interactor.SideFpsOverlayInteractorImpl
import com.android.systemui.dagger.SysUISingleton
import dagger.Binds
import dagger.Module
@@ -46,6 +48,12 @@ interface BiometricsDomainLayerModule {
@Binds
@SysUISingleton
+ fun providesSideFpsOverlayInteractor(
+ impl: SideFpsOverlayInteractorImpl
+ ): SideFpsOverlayInteractor
+
+ @Binds
+ @SysUISingleton
fun providesCredentialInteractor(impl: CredentialInteractorImpl): CredentialInteractor
@Binds
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractor.kt b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractor.kt
new file mode 100644
index 000000000000..10c3483de452
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractor.kt
@@ -0,0 +1,82 @@
+/*
+ * Copyright (C) 2024 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.biometrics.domain.interactor
+
+import android.util.Log
+import com.android.systemui.biometrics.shared.model.AuthenticationReason.NotRunning
+import com.android.systemui.keyguard.domain.interactor.DeviceEntrySideFpsOverlayInteractor
+import com.android.systemui.util.kotlin.sample
+import javax.inject.Inject
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.combine
+import kotlinx.coroutines.flow.flatMapLatest
+import kotlinx.coroutines.flow.flowOf
+import kotlinx.coroutines.flow.onEach
+
+/** Encapsulates business logic for showing and hiding the side fingerprint sensor indicator. */
+interface SideFpsOverlayInteractor {
+ /** Whether the side fingerprint sensor indicator is currently showing. */
+ val isShowing: Flow<Boolean>
+}
+
+@OptIn(ExperimentalCoroutinesApi::class)
+class SideFpsOverlayInteractorImpl
+@Inject
+constructor(
+ biometricStatusInteractor: BiometricStatusInteractor,
+ displayStateInteractor: DisplayStateInteractor,
+ deviceEntrySideFpsOverlayInteractor: DeviceEntrySideFpsOverlayInteractor,
+ sfpsSensorInteractor: SideFpsSensorInteractor,
+ // TODO(b/365182034): add progress bar input when rest to unlock feature is implemented
+) : SideFpsOverlayInteractor {
+ private val sfpsOverlayEnabled: Flow<Boolean> =
+ sfpsSensorInteractor.isAvailable.sample(displayStateInteractor.isInRearDisplayMode) {
+ isAvailable: Boolean,
+ isInRearDisplayMode: Boolean ->
+ isAvailable && !isInRearDisplayMode
+ }
+
+ private val showSideFpsOverlay: Flow<Boolean> =
+ combine(
+ biometricStatusInteractor.sfpsAuthenticationReason,
+ deviceEntrySideFpsOverlayInteractor.showIndicatorForDeviceEntry,
+ // TODO(b/365182034): add progress bar input when rest to unlock feature is implemented
+ ) { systemServerAuthReason, showIndicatorForDeviceEntry ->
+ Log.d(
+ TAG,
+ "systemServerAuthReason = $systemServerAuthReason, " +
+ "showIndicatorForDeviceEntry = $showIndicatorForDeviceEntry, "
+ )
+ systemServerAuthReason != NotRunning || showIndicatorForDeviceEntry
+ }
+
+ override val isShowing: Flow<Boolean> =
+ sfpsOverlayEnabled
+ .flatMapLatest { sfpsOverlayEnabled ->
+ if (!sfpsOverlayEnabled) {
+ flowOf(false)
+ } else {
+ showSideFpsOverlay
+ }
+ }
+ .onEach { Log.d(TAG, "isShowing: $it") }
+
+ companion object {
+ private const val TAG = "SideFpsOverlayInteractor"
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt
index d69e87534cb6..d055731b2698 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/BiometricViewSizeBinder.kt
@@ -158,16 +158,13 @@ object BiometricViewSizeBinder {
fun setVisibilities(hideSensorIcon: Boolean, size: PromptSize) {
viewsToHideWhenSmall.forEach { it.showContentOrHide(forceHide = size.isSmall) }
largeConstraintSet.setVisibility(iconHolderView.id, View.GONE)
- largeConstraintSet.setVisibility(R.id.biometric_icon_overlay, View.GONE)
largeConstraintSet.setVisibility(R.id.indicator, View.GONE)
largeConstraintSet.setVisibility(R.id.scrollView, View.GONE)
if (hideSensorIcon) {
smallConstraintSet.setVisibility(iconHolderView.id, View.GONE)
- smallConstraintSet.setVisibility(R.id.biometric_icon_overlay, View.GONE)
smallConstraintSet.setVisibility(R.id.indicator, View.GONE)
mediumConstraintSet.setVisibility(iconHolderView.id, View.GONE)
- mediumConstraintSet.setVisibility(R.id.biometric_icon_overlay, View.GONE)
mediumConstraintSet.setVisibility(R.id.indicator, View.GONE)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinder.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinder.kt
index 9578da4238ee..9fe1dc51f4c2 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinder.kt
@@ -33,89 +33,44 @@ import com.airbnb.lottie.LottieProperty
import com.android.app.animation.Interpolators
import com.android.keyguard.KeyguardPINView
import com.android.systemui.CoreStartable
-import com.android.systemui.biometrics.domain.interactor.BiometricStatusInteractor
-import com.android.systemui.biometrics.domain.interactor.DisplayStateInteractor
-import com.android.systemui.biometrics.domain.interactor.SideFpsSensorInteractor
-import com.android.systemui.biometrics.shared.model.AuthenticationReason.NotRunning
+import com.android.systemui.biometrics.domain.interactor.SideFpsOverlayInteractor
import com.android.systemui.biometrics.shared.model.LottieCallback
import com.android.systemui.biometrics.ui.viewmodel.SideFpsOverlayViewModel
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
-import com.android.systemui.keyguard.domain.interactor.DeviceEntrySideFpsOverlayInteractor
-import com.android.systemui.keyguard.ui.viewmodel.SideFpsProgressBarViewModel
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.res.R
-import com.android.systemui.util.kotlin.sample
import dagger.Lazy
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.launch
/** Binds the side fingerprint sensor indicator view to [SideFpsOverlayViewModel]. */
-@OptIn(ExperimentalCoroutinesApi::class)
@SysUISingleton
class SideFpsOverlayViewBinder
@Inject
constructor(
@Application private val applicationScope: CoroutineScope,
@Application private val applicationContext: Context,
- private val biometricStatusInteractor: Lazy<BiometricStatusInteractor>,
- private val displayStateInteractor: Lazy<DisplayStateInteractor>,
- private val deviceEntrySideFpsOverlayInteractor: Lazy<DeviceEntrySideFpsOverlayInteractor>,
private val layoutInflater: Lazy<LayoutInflater>,
- private val sideFpsProgressBarViewModel: Lazy<SideFpsProgressBarViewModel>,
- private val sfpsSensorInteractor: Lazy<SideFpsSensorInteractor>,
+ private val sideFpsOverlayInteractor: Lazy<SideFpsOverlayInteractor>,
+ private val sideFpsOverlayViewModel: Lazy<SideFpsOverlayViewModel>,
private val windowManager: Lazy<WindowManager>
) : CoreStartable {
+ private var overlayView: View? = null
override fun start() {
- applicationScope
- .launch {
- sfpsSensorInteractor.get().isAvailable.collect { isSfpsAvailable ->
- if (isSfpsAvailable) {
- combine(
- biometricStatusInteractor.get().sfpsAuthenticationReason,
- deviceEntrySideFpsOverlayInteractor
- .get()
- .showIndicatorForDeviceEntry,
- sideFpsProgressBarViewModel.get().isVisible,
- ::Triple
- )
- .sample(displayStateInteractor.get().isInRearDisplayMode, ::Pair)
- .collect { (combinedFlows, isInRearDisplayMode: Boolean) ->
- val (
- systemServerAuthReason,
- showIndicatorForDeviceEntry,
- progressBarIsVisible) =
- combinedFlows
- Log.d(
- TAG,
- "systemServerAuthReason = $systemServerAuthReason, " +
- "showIndicatorForDeviceEntry = " +
- "$showIndicatorForDeviceEntry, " +
- "progressBarIsVisible = $progressBarIsVisible"
- )
- if (!isInRearDisplayMode) {
- if (progressBarIsVisible) {
- hide()
- } else if (systemServerAuthReason != NotRunning) {
- show()
- } else if (showIndicatorForDeviceEntry) {
- show()
- } else {
- hide()
- }
- }
- }
- }
+ applicationScope.launch {
+ sideFpsOverlayInteractor.get().isShowing.collect { isShowing: Boolean ->
+ if (isShowing) {
+ show()
+ } else {
+ hide()
}
}
+ }
}
- private var overlayView: View? = null
-
/** Show the side fingerprint sensor indicator */
private fun show() {
if (overlayView?.isAttachedToWindow == true) {
@@ -125,17 +80,10 @@ constructor(
)
return
}
-
overlayView = layoutInflater.get().inflate(R.layout.sidefps_view, null, false)
-
- val overlayViewModel =
- SideFpsOverlayViewModel(
- applicationContext,
- deviceEntrySideFpsOverlayInteractor.get(),
- displayStateInteractor.get(),
- sfpsSensorInteractor.get(),
- )
+ val overlayViewModel = sideFpsOverlayViewModel.get()
bind(overlayView!!, overlayViewModel, windowManager.get())
+
overlayView!!.visibility = View.INVISIBLE
Log.d(TAG, "show(): adding overlayView $overlayView")
windowManager.get().addView(overlayView, overlayViewModel.defaultOverlayViewParams)
@@ -161,6 +109,20 @@ constructor(
companion object {
private const val TAG = "SideFpsOverlayViewBinder"
+ private val accessibilityDelegate =
+ object : View.AccessibilityDelegate() {
+ override fun dispatchPopulateAccessibilityEvent(
+ host: View,
+ event: AccessibilityEvent
+ ): Boolean {
+ return if (event.eventType == AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED) {
+ true
+ } else {
+ super.dispatchPopulateAccessibilityEvent(host, event)
+ }
+ }
+ }
+
/** Binds overlayView (side fingerprint sensor indicator view) to SideFpsOverlayViewModel */
fun bind(
overlayView: View,
@@ -184,24 +146,7 @@ constructor(
overlayShowAnimator.start()
- it.setAccessibilityDelegate(
- object : View.AccessibilityDelegate() {
- override fun dispatchPopulateAccessibilityEvent(
- host: View,
- event: AccessibilityEvent
- ): Boolean {
- return if (
- event.getEventType() ===
- android.view.accessibility.AccessibilityEvent
- .TYPE_WINDOW_STATE_CHANGED
- ) {
- true
- } else {
- super.dispatchPopulateAccessibilityEvent(host, event)
- }
- }
- }
- )
+ it.accessibilityDelegate = accessibilityDelegate
repeatOnLifecycle(Lifecycle.State.STARTED) {
launch {
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt
index 168ba11309cc..85f221fa951e 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModel.kt
@@ -78,11 +78,11 @@ import kotlinx.coroutines.launch
class PromptViewModel
@Inject
constructor(
- displayStateInteractor: DisplayStateInteractor,
+ private val displayStateInteractor: DisplayStateInteractor,
private val promptSelectorInteractor: PromptSelectorInteractor,
@Application private val context: Context,
- private val udfpsOverlayInteractor: UdfpsOverlayInteractor,
- private val biometricStatusInteractor: BiometricStatusInteractor,
+ udfpsOverlayInteractor: UdfpsOverlayInteractor,
+ biometricStatusInteractor: BiometricStatusInteractor,
private val udfpsUtils: UdfpsUtils,
private val iconProvider: IconProvider,
private val activityTaskManager: ActivityTaskManager,
@@ -135,11 +135,13 @@ constructor(
R.dimen.biometric_prompt_landscape_medium_horizontal_padding
)
+ val currentRotation: StateFlow<DisplayRotation> = displayStateInteractor.currentRotation
+
val udfpsOverlayParams: StateFlow<UdfpsOverlayParams> =
udfpsOverlayInteractor.udfpsOverlayParams
private val udfpsSensorBounds: Flow<Rect> =
- combine(udfpsOverlayParams, displayStateInteractor.currentRotation) { params, rotation ->
+ combine(udfpsOverlayParams, currentRotation) { params, rotation ->
val rotatedBounds = Rect(params.sensorBounds)
RotationUtils.rotateBounds(
rotatedBounds,
@@ -262,7 +264,7 @@ constructor(
_forceLargeSize,
promptKind,
displayStateInteractor.isLargeScreen,
- displayStateInteractor.currentRotation,
+ currentRotation,
modalities
) { forceLarge, promptKind, isLargeScreen, rotation, modalities ->
when {
@@ -454,7 +456,7 @@ constructor(
/** Padding for prompt UI elements */
val promptPadding: Flow<Rect> =
- combine(size, displayStateInteractor.currentRotation) { size, rotation ->
+ combine(size, currentRotation) { size, rotation ->
if (size != PromptSize.LARGE) {
val navBarInsets = Utils.getNavbarInsets(context)
if (rotation == DisplayRotation.ROTATION_90) {
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModel.kt b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModel.kt
index c2a4ee36dec6..7c1984e506c9 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModel.kt
@@ -147,8 +147,7 @@ constructor(
_lottieBounds,
sensorLocation,
displayRotation,
- ) { bounds: Rect?, sensorLocation: SideFpsSensorLocation, displayRotation: DisplayRotation
- ->
+ ) { _: Rect?, sensorLocation: SideFpsSensorLocation, _: DisplayRotation ->
val topLeft = Point(sensorLocation.left, sensorLocation.top)
defaultOverlayViewParams.apply {
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt b/packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt
index a1111f68f1ee..d7a4863bde02 100644
--- a/packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt
+++ b/packages/SystemUI/src/com/android/systemui/bouncer/shared/flag/ComposeBouncerFlags.kt
@@ -21,6 +21,10 @@ import com.android.systemui.scene.shared.flag.SceneContainerFlag
object ComposeBouncerFlags {
+ /** @see [isComposeBouncerOrSceneContainerEnabled] */
+ val isEnabled: Boolean
+ get() = isComposeBouncerOrSceneContainerEnabled()
+
/**
* Returns `true` if the Compose bouncer is enabled or if the scene container framework is
* enabled; `false` otherwise.
diff --git a/packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt b/packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt
index c69cea4a6a5a..04393feaae37 100644
--- a/packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/communal/CommunalDreamStartable.kt
@@ -21,6 +21,7 @@ import android.app.DreamManager
import com.android.systemui.CoreStartable
import com.android.systemui.Flags.glanceableHubAllowKeyguardWhenDreaming
import com.android.systemui.Flags.restartDreamOnUnocclude
+import com.android.systemui.communal.domain.interactor.CommunalSceneInteractor
import com.android.systemui.communal.domain.interactor.CommunalSettingsInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
@@ -55,6 +56,7 @@ constructor(
private val keyguardInteractor: KeyguardInteractor,
private val keyguardTransitionInteractor: KeyguardTransitionInteractor,
private val dreamManager: DreamManager,
+ private val communalSceneInteractor: CommunalSceneInteractor,
@Background private val bgScope: CoroutineScope,
) : CoreStartable {
/** Flow that emits when the dream should be started underneath the glanceable hub. */
@@ -66,6 +68,8 @@ constructor(
not(keyguardInteractor.isDreaming),
// TODO(b/362830856): Remove this workaround.
keyguardInteractor.isKeyguardShowing,
+ not(communalSceneInteractor.isLaunchingWidget),
+ not(keyguardInteractor.isKeyguardOccluded),
)
.filter { it }
diff --git a/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt b/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt
index db7ffc1bef79..037b6facc50d 100644
--- a/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/controls/dagger/ControlsModule.kt
@@ -48,6 +48,7 @@ import com.android.systemui.controls.ui.ControlsUiControllerImpl
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.qs.tiles.DeviceControlsTile
import com.android.systemui.qs.tiles.viewmodel.QSTileConfig
@@ -86,15 +87,16 @@ abstract class ControlsModule {
@IntoMap
@StringKey(DEVICE_CONTROLS_SPEC)
fun provideDeviceControlsTileConfig(uiEventLogger: QsEventLogger): QSTileConfig =
- QSTileConfig(
- tileSpec = TileSpec.create(DEVICE_CONTROLS_SPEC),
- uiConfig =
- QSTileUIConfig.Resource(
- iconRes = com.android.systemui.res.R.drawable.controls_icon,
- labelRes = com.android.systemui.res.R.string.quick_controls_title
- ),
- instanceId = uiEventLogger.getNewInstanceId(),
- )
+ QSTileConfig(
+ tileSpec = TileSpec.create(DEVICE_CONTROLS_SPEC),
+ uiConfig =
+ QSTileUIConfig.Resource(
+ iconRes = com.android.systemui.res.R.drawable.controls_icon,
+ labelRes = com.android.systemui.res.R.string.quick_controls_title
+ ),
+ instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.UTILITIES,
+ )
}
@Binds
@@ -115,12 +117,12 @@ abstract class ControlsModule {
@Binds
abstract fun provideSettingsManager(
- manager: ControlsSettingsRepositoryImpl
+ manager: ControlsSettingsRepositoryImpl
): ControlsSettingsRepository
@Binds
abstract fun provideDialogManager(
- manager: ControlsSettingsDialogManagerImpl
+ manager: ControlsSettingsDialogManagerImpl
): ControlsSettingsDialogManager
@Binds
@@ -141,8 +143,7 @@ abstract class ControlsModule {
repository: SelectedComponentRepositoryImpl
): SelectedComponentRepository
- @BindsOptionalOf
- abstract fun optionalPersistenceWrapper(): ControlsFavoritePersistenceWrapper
+ @BindsOptionalOf abstract fun optionalPersistenceWrapper(): ControlsFavoritePersistenceWrapper
@BindsOptionalOf
abstract fun provideControlsTileResourceConfiguration(): ControlsTileResourceConfiguration
@@ -157,23 +158,17 @@ abstract class ControlsModule {
@Binds
@IntoMap
@ClassKey(ControlsFavoritingActivity::class)
- abstract fun provideControlsFavoritingActivity(
- activity: ControlsFavoritingActivity
- ): Activity
+ abstract fun provideControlsFavoritingActivity(activity: ControlsFavoritingActivity): Activity
@Binds
@IntoMap
@ClassKey(ControlsEditingActivity::class)
- abstract fun provideControlsEditingActivity(
- activity: ControlsEditingActivity
- ): Activity
+ abstract fun provideControlsEditingActivity(activity: ControlsEditingActivity): Activity
@Binds
@IntoMap
@ClassKey(ControlsRequestDialog::class)
- abstract fun provideControlsRequestDialog(
- activity: ControlsRequestDialog
- ): Activity
+ abstract fun provideControlsRequestDialog(activity: ControlsRequestDialog): Activity
@Binds
@IntoMap
diff --git a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java
index f6ac7a579140..a45ad157837b 100644
--- a/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dreams/dagger/DreamModule.java
@@ -38,6 +38,7 @@ import com.android.systemui.dreams.homecontrols.DreamServiceDelegateImpl;
import com.android.systemui.dreams.homecontrols.HomeControlsDreamService;
import com.android.systemui.qs.QsEventLogger;
import com.android.systemui.qs.pipeline.shared.TileSpec;
+import com.android.systemui.qs.shared.model.TileCategory;
import com.android.systemui.qs.tiles.viewmodel.QSTileConfig;
import com.android.systemui.qs.tiles.viewmodel.QSTilePolicy;
import com.android.systemui.qs.tiles.viewmodel.QSTileUIConfig;
@@ -196,6 +197,7 @@ public interface DreamModule {
R.drawable.ic_qs_screen_saver,
R.string.quick_settings_screensaver_label),
uiEventLogger.getNewInstanceId(),
+ TileCategory.UTILITIES,
tileSpec.getSpec(),
QSTilePolicy.NoRestrictions.INSTANCE
);
diff --git a/packages/SystemUI/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduStatsInteractor.kt b/packages/SystemUI/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduStatsInteractor.kt
index 3223433568b9..0e2d9b6a3ae0 100644
--- a/packages/SystemUI/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduStatsInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduStatsInteractor.kt
@@ -16,11 +16,25 @@
package com.android.systemui.education.domain.interactor
+import android.os.SystemProperties
+import com.android.systemui.contextualeducation.GestureType
+import com.android.systemui.contextualeducation.GestureType.ALL_APPS
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
-import com.android.systemui.contextualeducation.GestureType
+import com.android.systemui.education.dagger.ContextualEducationModule.EduClock
+import com.android.systemui.inputdevice.data.repository.UserInputDeviceRepository
+import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType
+import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType.KEYBOARD
+import com.android.systemui.inputdevice.tutorial.data.repository.DeviceType.TOUCHPAD
+import com.android.systemui.inputdevice.tutorial.data.repository.TutorialSchedulerRepository
+import java.time.Clock
import javax.inject.Inject
+import kotlin.time.Duration
+import kotlin.time.Duration.Companion.hours
+import kotlin.time.DurationUnit
+import kotlin.time.toDuration
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.first
import kotlinx.coroutines.launch
/**
@@ -39,12 +53,29 @@ class KeyboardTouchpadEduStatsInteractorImpl
@Inject
constructor(
@Background private val backgroundScope: CoroutineScope,
- private val contextualEducationInteractor: ContextualEducationInteractor
+ private val contextualEducationInteractor: ContextualEducationInteractor,
+ private val inputDeviceRepository: UserInputDeviceRepository,
+ private val tutorialRepository: TutorialSchedulerRepository,
+ @EduClock private val clock: Clock,
) : KeyboardTouchpadEduStatsInteractor {
+ companion object {
+ val initialDelayDuration: Duration
+ get() =
+ SystemProperties.getLong(
+ "persist.contextual_edu.initial_delay_sec",
+ /* defaultValue= */ 72.hours.inWholeSeconds
+ )
+ .toDuration(DurationUnit.SECONDS)
+ }
+
override fun incrementSignalCount(gestureType: GestureType) {
- // Todo: check if keyboard/touchpad is connected before update
- backgroundScope.launch { contextualEducationInteractor.incrementSignalCount(gestureType) }
+ backgroundScope.launch {
+ val targetDevice = getTargetDevice(gestureType)
+ if (isTargetDeviceConnected(targetDevice) && hasInitialDelayElapsed(targetDevice)) {
+ contextualEducationInteractor.incrementSignalCount(gestureType)
+ }
+ }
}
override fun updateShortcutTriggerTime(gestureType: GestureType) {
@@ -52,4 +83,29 @@ constructor(
contextualEducationInteractor.updateShortcutTriggerTime(gestureType)
}
}
+
+ private suspend fun isTargetDeviceConnected(deviceType: DeviceType): Boolean {
+ return when (deviceType) {
+ KEYBOARD -> inputDeviceRepository.isAnyKeyboardConnectedForUser.first().isConnected
+ TOUCHPAD -> inputDeviceRepository.isAnyTouchpadConnectedForUser.first().isConnected
+ }
+ }
+
+ /**
+ * Keyboard shortcut education would be provided for All Apps. Touchpad gesture education would
+ * be provided for the rest of the gesture types (i.e. Home, Overview, Back). This method maps
+ * gesture to its target education device.
+ */
+ private fun getTargetDevice(gestureType: GestureType) =
+ when (gestureType) {
+ ALL_APPS -> KEYBOARD
+ else -> TOUCHPAD
+ }
+
+ private suspend fun hasInitialDelayElapsed(deviceType: DeviceType): Boolean {
+ val oobeLaunchTime = tutorialRepository.launchTime(deviceType) ?: return false
+ return clock
+ .instant()
+ .isAfter(oobeLaunchTime.plusSeconds(initialDelayDuration.inWholeSeconds))
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/haptics/msdl/dagger/MSDLModule.kt b/packages/SystemUI/src/com/android/systemui/haptics/msdl/dagger/MSDLModule.kt
index 5ea96b8388bb..d2dc8c1e8328 100644
--- a/packages/SystemUI/src/com/android/systemui/haptics/msdl/dagger/MSDLModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/haptics/msdl/dagger/MSDLModule.kt
@@ -16,7 +16,9 @@
package com.android.systemui.haptics.msdl.dagger
+import android.annotation.SuppressLint
import android.content.Context
+import android.os.VibratorManager
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.google.android.msdl.domain.MSDLPlayer
@@ -25,8 +27,12 @@ import dagger.Provides
@Module
object MSDLModule {
+ @SuppressLint("NonInjectedService")
@Provides
@SysUISingleton
- fun provideMSDLPlayer(@Application context: Context): MSDLPlayer =
- MSDLPlayer.createPlayer(context)
+ fun provideMSDLPlayer(@Application context: Context): MSDLPlayer {
+ val vibratorManager =
+ context.getSystemService(Context.VIBRATOR_MANAGER_SERVICE) as VibratorManager
+ return MSDLPlayer.createPlayer(vibratorManager.defaultVibrator)
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialCoreStartable.kt b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialCoreStartable.kt
index 7ecacdc7cf16..092a25aa1cad 100644
--- a/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialCoreStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialCoreStartable.kt
@@ -16,9 +16,17 @@
package com.android.systemui.inputdevice.tutorial
+import android.content.BroadcastReceiver
+import android.content.Context
+import android.content.Intent
+import android.content.IntentFilter
+import android.os.UserHandle
import com.android.systemui.CoreStartable
+import com.android.systemui.broadcast.BroadcastDispatcher
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.inputdevice.tutorial.ui.TutorialNotificationCoordinator
+import com.android.systemui.inputdevice.tutorial.ui.view.KeyboardTouchpadTutorialActivity
import com.android.systemui.shared.Flags.newTouchpadGesturesTutorial
import dagger.Lazy
import javax.inject.Inject
@@ -27,11 +35,35 @@ import javax.inject.Inject
@SysUISingleton
class KeyboardTouchpadTutorialCoreStartable
@Inject
-constructor(private val tutorialNotificationCoordinator: Lazy<TutorialNotificationCoordinator>) :
- CoreStartable {
+constructor(
+ private val tutorialNotificationCoordinator: Lazy<TutorialNotificationCoordinator>,
+ private val broadcastDispatcher: BroadcastDispatcher,
+ @Application private val applicationContext: Context,
+) : CoreStartable {
override fun start() {
if (newTouchpadGesturesTutorial()) {
tutorialNotificationCoordinator.get().start()
+ registerTutorialBroadcastReceiver()
}
}
+
+ private fun registerTutorialBroadcastReceiver() {
+ broadcastDispatcher.registerReceiver(
+ receiver =
+ object : BroadcastReceiver() {
+ override fun onReceive(context: Context, intent: Intent) {
+ applicationContext.startActivityAsUser(
+ Intent(
+ applicationContext,
+ KeyboardTouchpadTutorialActivity::class.java
+ ),
+ UserHandle.SYSTEM
+ )
+ }
+ },
+ filter = IntentFilter("com.android.systemui.action.KEYBOARD_TOUCHPAD_TUTORIAL"),
+ flags = Context.RECEIVER_EXPORTED,
+ user = UserHandle.ALL,
+ )
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt
index 63f3d52b2d2d..dcca12f29287 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/shortcut/ui/composable/ShortcutHelper.kt
@@ -82,6 +82,7 @@ import androidx.compose.runtime.setValue
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
import androidx.compose.ui.draw.drawWithContent
+import androidx.compose.ui.focus.FocusDirection
import androidx.compose.ui.focus.FocusRequester
import androidx.compose.ui.focus.focusRequester
import androidx.compose.ui.geometry.CornerRadius
@@ -92,8 +93,12 @@ import androidx.compose.ui.graphics.RectangleShape
import androidx.compose.ui.graphics.Shape
import androidx.compose.ui.graphics.drawscope.Stroke
import androidx.compose.ui.graphics.graphicsLayer
+import androidx.compose.ui.input.key.Key
+import androidx.compose.ui.input.key.key
+import androidx.compose.ui.input.key.onKeyEvent
import androidx.compose.ui.input.nestedscroll.nestedScroll
import androidx.compose.ui.platform.LocalContext
+import androidx.compose.ui.platform.LocalFocusManager
import androidx.compose.ui.platform.rememberNestedScrollInteropConnection
import androidx.compose.ui.res.painterResource
import androidx.compose.ui.res.stringResource
@@ -824,9 +829,18 @@ private fun ShortcutsSearchBar(onQueryChange: (String) -> Unit) {
// from the ViewModel.
var queryInternal by remember { mutableStateOf("") }
val focusRequester = remember { FocusRequester() }
+ val focusManager = LocalFocusManager.current
LaunchedEffect(Unit) { focusRequester.requestFocus() }
SearchBar(
- modifier = Modifier.fillMaxWidth().focusRequester(focusRequester),
+ modifier =
+ Modifier.fillMaxWidth().focusRequester(focusRequester).onKeyEvent {
+ if (it.key == Key.DirectionDown) {
+ focusManager.moveFocus(FocusDirection.Down)
+ return@onKeyEvent true
+ } else {
+ return@onKeyEvent false
+ }
+ },
colors = SearchBarDefaults.colors(containerColor = MaterialTheme.colorScheme.surfaceBright),
query = queryInternal,
active = false,
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
index 362e016cc97c..df0f10acac1f 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewConfigurator.kt
@@ -71,6 +71,7 @@ import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.KeyguardIndicationController
import com.android.systemui.statusbar.VibratorHelper
import com.android.systemui.statusbar.phone.ScreenOffAnimationController
+import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator
import com.google.android.msdl.domain.MSDLPlayer
import dagger.Lazy
@@ -112,6 +113,7 @@ constructor(
private val clockInteractor: KeyguardClockInteractor,
private val keyguardViewMediator: KeyguardViewMediator,
private val deviceEntryUnlockTrackerViewBinder: Optional<DeviceEntryUnlockTrackerViewBinder>,
+ private val statusBarKeyguardViewManager: StatusBarKeyguardViewManager,
@Main private val mainDispatcher: CoroutineDispatcher,
private val msdlPlayer: MSDLPlayer,
) : CoreStartable {
@@ -220,6 +222,7 @@ constructor(
vibratorHelper,
falsingManager,
keyguardViewMediator,
+ statusBarKeyguardViewManager,
mainDispatcher,
msdlPlayer,
)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractor.kt
index e2bb540f6645..7afc7596a994 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardBlueprintInteractor.kt
@@ -80,10 +80,7 @@ constructor(
}
applicationScope.launch {
val refreshConfig =
- Config(
- Type.NoTransition,
- rebuildSections = listOf(smartspaceSection),
- )
+ Config(Type.NoTransition, rebuildSections = listOf(smartspaceSection))
configurationInteractor.onAnyConfigurationChange.collect {
refreshBlueprint(refreshConfig)
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractor.kt b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractor.kt
index 7801c00d83b8..60c53863535d 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractor.kt
@@ -18,6 +18,7 @@
package com.android.systemui.keyguard.domain.interactor
import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
+import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.deviceentry.domain.interactor.DeviceEntryInteractor
@@ -32,6 +33,7 @@ import com.android.systemui.scene.domain.resolver.NotifShadeSceneFamilyResolver
import com.android.systemui.scene.domain.resolver.QuickSettingsSceneFamilyResolver
import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.scene.shared.model.Scenes
+import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.util.kotlin.Utils.Companion.sampleFilter
import com.android.systemui.util.kotlin.sample
import javax.inject.Inject
@@ -44,6 +46,7 @@ import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.filter
import kotlinx.coroutines.flow.filterNot
+import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.merge
import kotlinx.coroutines.flow.stateIn
@@ -58,12 +61,14 @@ constructor(
transitionInteractor: KeyguardTransitionInteractor,
val dismissInteractor: KeyguardDismissInteractor,
@Application private val applicationScope: CoroutineScope,
- sceneInteractor: SceneInteractor,
- deviceEntryInteractor: DeviceEntryInteractor,
- quickSettingsSceneFamilyResolver: QuickSettingsSceneFamilyResolver,
- notifShadeSceneFamilyResolver: NotifShadeSceneFamilyResolver,
+ sceneInteractor: dagger.Lazy<SceneInteractor>,
+ deviceEntryInteractor: dagger.Lazy<DeviceEntryInteractor>,
+ quickSettingsSceneFamilyResolver: dagger.Lazy<QuickSettingsSceneFamilyResolver>,
+ notifShadeSceneFamilyResolver: dagger.Lazy<NotifShadeSceneFamilyResolver>,
powerInteractor: PowerInteractor,
alternateBouncerInteractor: AlternateBouncerInteractor,
+ keyguardInteractor: dagger.Lazy<KeyguardInteractor>,
+ shadeInteractor: dagger.Lazy<ShadeInteractor>,
) {
val dismissAction: Flow<DismissAction> = repository.dismissAction
@@ -98,15 +103,31 @@ constructor(
* device is unlocked. Else, false.
*/
private val isOnShadeWhileUnlocked: Flow<Boolean> =
- combine(
- sceneInteractor.currentScene,
- deviceEntryInteractor.isUnlocked,
- ) { scene, isUnlocked ->
- isUnlocked &&
- (quickSettingsSceneFamilyResolver.includesScene(scene) ||
- notifShadeSceneFamilyResolver.includesScene(scene))
+ if (SceneContainerFlag.isEnabled) {
+ combine(
+ sceneInteractor.get().currentScene,
+ deviceEntryInteractor.get().isUnlocked,
+ ) { scene, isUnlocked ->
+ isUnlocked &&
+ (quickSettingsSceneFamilyResolver.get().includesScene(scene) ||
+ notifShadeSceneFamilyResolver.get().includesScene(scene))
+ }
+ .distinctUntilChanged()
+ } else if (ComposeBouncerFlags.isOnlyComposeBouncerEnabled()) {
+ shadeInteractor.get().isAnyExpanded.sample(
+ keyguardInteractor.get().isKeyguardDismissible
+ ) { isAnyExpanded, isKeyguardDismissible ->
+ isAnyExpanded && isKeyguardDismissible
+ }
+ } else {
+ flow {
+ error(
+ "This should not be used when both SceneContainerFlag " +
+ "and ComposeBouncerFlag are disabled"
+ )
}
- .distinctUntilChanged()
+ }
+
val executeDismissAction: Flow<() -> KeyguardDone> =
merge(
finishedTransitionToGone,
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardDismissActionBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardDismissActionBinder.kt
index 74a7262d7889..69cb6a92137f 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardDismissActionBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardDismissActionBinder.kt
@@ -17,11 +17,11 @@ package com.android.systemui.keyguard.ui.binder
import com.android.keyguard.logging.KeyguardLogger
import com.android.systemui.CoreStartable
+import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.domain.interactor.KeyguardDismissActionInteractor
import com.android.systemui.log.core.LogLevel
-import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.util.kotlin.sample
import dagger.Lazy
import javax.inject.Inject
@@ -41,7 +41,7 @@ constructor(
) : CoreStartable {
override fun start() {
- if (!SceneContainerFlag.isEnabled) {
+ if (!ComposeBouncerFlags.isEnabled) {
return
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardDismissBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardDismissBinder.kt
index ac24591d69d7..b55f813a1f84 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardDismissBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardDismissBinder.kt
@@ -18,13 +18,12 @@ package com.android.systemui.keyguard.ui.binder
import com.android.keyguard.ViewMediatorCallback
import com.android.keyguard.logging.KeyguardLogger
import com.android.systemui.CoreStartable
+import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
-import com.android.systemui.flags.FeatureFlagsClassic
import com.android.systemui.keyguard.domain.interactor.KeyguardDismissInteractor
import com.android.systemui.keyguard.shared.model.KeyguardDone
import com.android.systemui.log.core.LogLevel
-import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.user.domain.interactor.SelectedUserInteractor
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
@@ -40,11 +39,10 @@ constructor(
private val viewMediatorCallback: ViewMediatorCallback,
@Application private val scope: CoroutineScope,
private val keyguardLogger: KeyguardLogger,
- private val featureFlags: FeatureFlagsClassic,
) : CoreStartable {
override fun start() {
- if (!SceneContainerFlag.isEnabled) {
+ if (!ComposeBouncerFlags.isEnabled) {
return
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt
index f2d39dabb1b5..ecfabc3e18ce 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardQuickAffordanceOnTouchListener.kt
@@ -18,13 +18,12 @@ package com.android.systemui.keyguard.ui.binder
import android.annotation.SuppressLint
import android.graphics.PointF
+import android.view.InputDevice
import android.view.MotionEvent
import android.view.View
import android.view.ViewConfiguration
import android.view.ViewPropertyAnimator
-import androidx.core.animation.CycleInterpolator
-import androidx.core.animation.ObjectAnimator
-import com.android.systemui.res.R
+import com.android.systemui.Flags
import com.android.systemui.animation.Expandable
import com.android.systemui.common.ui.view.rawDistanceFrom
import com.android.systemui.keyguard.ui.viewmodel.KeyguardQuickAffordanceViewModel
@@ -71,11 +70,10 @@ class KeyguardQuickAffordanceOnTouchListener(
// Moving too far while performing a long-press gesture cancels that
// gesture.
if (
- event
- .rawDistanceFrom(
- downDisplayCoords.x,
- downDisplayCoords.y,
- ) > ViewConfiguration.getTouchSlop()
+ event.rawDistanceFrom(
+ downDisplayCoords.x,
+ downDisplayCoords.y,
+ ) > ViewConfiguration.getTouchSlop()
) {
cancel()
}
@@ -151,10 +149,14 @@ class KeyguardQuickAffordanceOnTouchListener(
event: MotionEvent,
pointerIndex: Int = 0,
): Boolean {
- return when (event.getToolType(pointerIndex)) {
- MotionEvent.TOOL_TYPE_STYLUS -> true
- MotionEvent.TOOL_TYPE_MOUSE -> true
- else -> false
+ return if (Flags.nonTouchscreenDevicesBypassFalsing()) {
+ event.device?.supportsSource(InputDevice.SOURCE_TOUCHSCREEN) == false
+ } else {
+ when (event.getToolType(pointerIndex)) {
+ MotionEvent.TOOL_TYPE_STYLUS -> true
+ MotionEvent.TOOL_TYPE_MOUSE -> true
+ else -> false
+ }
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
index 5bb7b6425729..ed82159e6160 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/binder/KeyguardRootViewBinder.kt
@@ -24,6 +24,8 @@ import android.graphics.Point
import android.graphics.Rect
import android.util.Log
import android.view.HapticFeedbackConstants
+import android.view.InputDevice
+import android.view.MotionEvent
import android.view.View
import android.view.View.OnLayoutChangeListener
import android.view.View.VISIBLE
@@ -41,6 +43,7 @@ import com.android.app.tracing.coroutines.launch
import com.android.internal.jank.InteractionJankMonitor
import com.android.internal.jank.InteractionJankMonitor.CUJ_SCREEN_OFF_SHOW_AOD
import com.android.keyguard.AuthInteractionProperties
+import com.android.systemui.Flags
import com.android.systemui.Flags.msdlFeedback
import com.android.systemui.Flags.newAodTransition
import com.android.systemui.common.shared.model.Icon
@@ -73,6 +76,7 @@ import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.CrossFadeHelper
import com.android.systemui.statusbar.VibratorHelper
import com.android.systemui.statusbar.phone.ScreenOffAnimationController
+import com.android.systemui.statusbar.phone.StatusBarKeyguardViewManager
import com.android.systemui.temporarydisplay.ViewPriority
import com.android.systemui.temporarydisplay.chipbar.ChipbarCoordinator
import com.android.systemui.temporarydisplay.chipbar.ChipbarInfo
@@ -115,6 +119,7 @@ object KeyguardRootViewBinder {
vibratorHelper: VibratorHelper?,
falsingManager: FalsingManager?,
keyguardViewMediator: KeyguardViewMediator?,
+ statusBarKeyguardViewManager: StatusBarKeyguardViewManager?,
mainImmediateDispatcher: CoroutineDispatcher,
msdlPlayer: MSDLPlayer?,
): DisposableHandle {
@@ -124,12 +129,30 @@ object KeyguardRootViewBinder {
if (KeyguardBottomAreaRefactor.isEnabled) {
disposables +=
view.onTouchListener { _, event ->
+ var consumed = false
if (falsingManager?.isFalseTap(FalsingManager.LOW_PENALTY) == false) {
+ // signifies a primary button click down has reached keyguardrootview
+ // we need to return true here otherwise an ACTION_UP will never arrive
+ if (Flags.nonTouchscreenDevicesBypassFalsing()) {
+ if (
+ event.action == MotionEvent.ACTION_DOWN &&
+ event.buttonState == MotionEvent.BUTTON_PRIMARY &&
+ !event.isTouchscreenSource()
+ ) {
+ consumed = true
+ } else if (
+ event.action == MotionEvent.ACTION_UP &&
+ !event.isTouchscreenSource()
+ ) {
+ statusBarKeyguardViewManager?.showBouncer(true)
+ consumed = true
+ }
+ }
viewModel.setRootViewLastTapPosition(
Point(event.x.toInt(), event.y.toInt())
)
}
- false
+ consumed
}
}
@@ -637,6 +660,10 @@ object KeyguardRootViewBinder {
}
}
+ private fun MotionEvent.isTouchscreenSource(): Boolean {
+ return device?.supportsSource(InputDevice.SOURCE_TOUCHSCREEN) == true
+ }
+
private fun ViewPropertyAnimator.animateInIconTranslation(): ViewPropertyAnimator =
setInterpolator(Interpolators.DECELERATE_QUINT).translationY(0f)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
index f581a2e24546..0b8f7417a49d 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/preview/KeyguardPreviewRenderer.kt
@@ -417,6 +417,7 @@ constructor(
null, // device entry haptics not required for preview mode
null, // falsing manager not required for preview mode
null, // keyguard view mediator is not required for preview mode
+ null, // primary bouncer interactor is not required for preview mode
mainDispatcher,
null,
)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/BouncerToGoneFlows.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/BouncerToGoneFlows.kt
index 8485a265fc70..1edfec8f9e68 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/BouncerToGoneFlows.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/BouncerToGoneFlows.kt
@@ -18,6 +18,7 @@ package com.android.systemui.keyguard.ui.viewmodel
import com.android.app.animation.Interpolators.EMPHASIZED_ACCELERATE
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
+import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags
import com.android.systemui.keyguard.domain.interactor.KeyguardDismissActionInteractor
import com.android.systemui.keyguard.shared.model.Edge
import com.android.systemui.keyguard.shared.model.KeyguardState
@@ -25,7 +26,6 @@ import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.PRIMARY_BOUNCER
import com.android.systemui.keyguard.shared.model.ScrimAlpha
import com.android.systemui.keyguard.ui.KeyguardTransitionAnimationFlow
-import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.statusbar.SysuiStatusBarStateController
@@ -51,7 +51,7 @@ constructor(
) {
/** Common fade for scrim alpha values during *BOUNCER->GONE */
fun scrimAlpha(duration: Duration, fromState: KeyguardState): Flow<ScrimAlpha> {
- return if (SceneContainerFlag.isEnabled) {
+ return if (ComposeBouncerFlags.isEnabled) {
keyguardDismissActionInteractor
.get()
.willAnimateDismissActionOnLockscreen
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DozingToOccludedTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DozingToOccludedTransitionViewModel.kt
index f33752fc04d4..12bcc7ecbab8 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DozingToOccludedTransitionViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/DozingToOccludedTransitionViewModel.kt
@@ -17,6 +17,7 @@
package com.android.systemui.keyguard.ui.viewmodel
import android.util.MathUtils
+import com.android.systemui.Flags.lightRevealMigration
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.domain.interactor.FromAodTransitionInteractor
import com.android.systemui.keyguard.shared.model.Edge
@@ -55,8 +56,18 @@ constructor(
var currentAlpha = 0f
return transitionAnimation.sharedFlow(
duration = 250.milliseconds,
- startTime = 100.milliseconds, // Wait for the light reveal to "hit" the LS elements.
- onStart = { currentAlpha = viewState.alpha() },
+ startTime = if (lightRevealMigration()) {
+ 100.milliseconds // Wait for the light reveal to "hit" the LS elements.
+ } else {
+ 0.milliseconds
+ },
+ onStart = {
+ if (lightRevealMigration()) {
+ currentAlpha = viewState.alpha()
+ } else {
+ currentAlpha = 0f
+ }
+ },
onStep = { MathUtils.lerp(currentAlpha, 0f, it) },
onCancel = { 0f },
)
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt
index 8811908e1d45..17c678e79d8b 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/PrimaryBouncerToGoneTransitionViewModel.kt
@@ -17,6 +17,7 @@
package com.android.systemui.keyguard.ui.viewmodel
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor
+import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.keyguard.domain.interactor.FromPrimaryBouncerTransitionInteractor.Companion.TO_GONE_DURATION
import com.android.systemui.keyguard.domain.interactor.KeyguardDismissActionInteractor
@@ -25,7 +26,6 @@ import com.android.systemui.keyguard.shared.model.KeyguardState.GONE
import com.android.systemui.keyguard.shared.model.KeyguardState.PRIMARY_BOUNCER
import com.android.systemui.keyguard.shared.model.ScrimAlpha
import com.android.systemui.keyguard.ui.KeyguardTransitionAnimationFlow
-import com.android.systemui.scene.shared.flag.SceneContainerFlag
import com.android.systemui.statusbar.SysuiStatusBarStateController
import dagger.Lazy
import javax.inject.Inject
@@ -85,7 +85,7 @@ constructor(
/** Bouncer container alpha */
val bouncerAlpha: Flow<Float> =
- if (SceneContainerFlag.isEnabled) {
+ if (ComposeBouncerFlags.isEnabled) {
keyguardDismissActionInteractor
.get()
.willAnimateDismissActionOnLockscreen
@@ -110,7 +110,7 @@ constructor(
/** Lockscreen alpha */
val lockscreenAlpha: Flow<Float> =
- if (SceneContainerFlag.isEnabled) {
+ if (ComposeBouncerFlags.isEnabled) {
keyguardDismissActionInteractor
.get()
.willAnimateDismissActionOnLockscreen
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/SideFpsProgressBarViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/SideFpsProgressBarViewModel.kt
index c5909ed24c50..75e38714f1fa 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/SideFpsProgressBarViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/ui/viewmodel/SideFpsProgressBarViewModel.kt
@@ -107,6 +107,8 @@ constructor(
}
}
+ // TODO(b/365182034): move to interactor, add as dependency of SideFpsOverlayInteractor when
+ // rest to unlock feature is implemented
val isVisible: Flow<Boolean> = _visible.asStateFlow()
val progress: Flow<Float> = _progress.asStateFlow()
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/BouncerTableLog.kt b/packages/SystemUI/src/com/android/systemui/log/dagger/BouncerTableLog.kt
index 08df7db65af1..9f893e073cb1 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/BouncerTableLog.kt
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/BouncerTableLog.kt
@@ -16,10 +16,7 @@
package com.android.systemui.log.dagger
-import java.lang.annotation.Documented
-import java.lang.annotation.Retention
-import java.lang.annotation.RetentionPolicy
import javax.inject.Qualifier
/** Logger for the primary and alternative bouncers. */
-@Qualifier @Documented @Retention(RetentionPolicy.RUNTIME) annotation class BouncerTableLog
+@Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class BouncerTableLog
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
index 498c34c03f2d..2053b53dba63 100644
--- a/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/LogModule.java
@@ -382,6 +382,16 @@ public class LogModule {
return factory.create("MediaLog", 20);
}
+ /**
+ * Provides a buffer for media device changes
+ */
+ @Provides
+ @SysUISingleton
+ @MediaDeviceLog
+ public static LogBuffer providesMediaDeviceLogBuffer(LogBufferFactory factory) {
+ return factory.create("MediaDeviceLog", 50);
+ }
+
/** Allows logging buffers to be tweaked via adb on debug builds but not on prod builds. */
@Provides
@SysUISingleton
diff --git a/packages/SystemUI/src/com/android/systemui/log/dagger/MediaDeviceLog.kt b/packages/SystemUI/src/com/android/systemui/log/dagger/MediaDeviceLog.kt
new file mode 100644
index 000000000000..06bd26971232
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/log/dagger/MediaDeviceLog.kt
@@ -0,0 +1,26 @@
+/*
+ * Copyright (C) 2024 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.log.dagger
+
+import com.android.systemui.log.LogBuffer
+import javax.inject.Qualifier
+
+/** A [LogBuffer] for [com.android.systemui.media.controls.domain.pipeline.MediaDeviceLogger] */
+@Qualifier
+@MustBeDocumented
+@Retention(AnnotationRetention.RUNTIME)
+annotation class MediaDeviceLog
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImpl.kt b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImpl.kt
index 4ad437c50d61..84aae652795e 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImpl.kt
@@ -70,6 +70,7 @@ import com.android.systemui.dump.DumpManager
import com.android.systemui.media.controls.domain.pipeline.MediaDataManager.Companion.isMediaNotification
import com.android.systemui.media.controls.domain.resume.MediaResumeListener
import com.android.systemui.media.controls.domain.resume.ResumeMediaBrowser
+import com.android.systemui.media.controls.shared.MediaLogger
import com.android.systemui.media.controls.shared.model.EXTRA_KEY_TRIGGER_SOURCE
import com.android.systemui.media.controls.shared.model.EXTRA_VALUE_TRIGGER_PERIODIC
import com.android.systemui.media.controls.shared.model.MediaAction
@@ -84,7 +85,7 @@ import com.android.systemui.media.controls.util.MediaControllerFactory
import com.android.systemui.media.controls.util.MediaDataUtils
import com.android.systemui.media.controls.util.MediaFlags
import com.android.systemui.media.controls.util.MediaUiEventLogger
-import com.android.systemui.plugins.ActivityStarter
+import com.android.systemui.media.controls.util.SmallHash
import com.android.systemui.plugins.BcSmartspaceDataPlugin
import com.android.systemui.res.R
import com.android.systemui.statusbar.NotificationMediaManager.isPlayingState
@@ -186,7 +187,6 @@ class LegacyMediaDataManagerImpl(
private val mediaDeviceManager: MediaDeviceManager,
mediaDataCombineLatest: MediaDataCombineLatest,
private val mediaDataFilter: LegacyMediaDataFilterImpl,
- private val activityStarter: ActivityStarter,
private val smartspaceMediaDataProvider: SmartspaceMediaDataProvider,
private var useMediaResumption: Boolean,
private val useQsMediaPlayer: Boolean,
@@ -197,6 +197,7 @@ class LegacyMediaDataManagerImpl(
private val smartspaceManager: SmartspaceManager?,
private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
private val mediaDataLoader: dagger.Lazy<MediaDataLoader>,
+ private val mediaLogger: MediaLogger,
) : Dumpable, BcSmartspaceDataPlugin.SmartspaceTargetListener, MediaDataManager {
companion object {
@@ -273,7 +274,6 @@ class LegacyMediaDataManagerImpl(
mediaDeviceManager: MediaDeviceManager,
mediaDataCombineLatest: MediaDataCombineLatest,
mediaDataFilter: LegacyMediaDataFilterImpl,
- activityStarter: ActivityStarter,
smartspaceMediaDataProvider: SmartspaceMediaDataProvider,
clock: SystemClock,
tunerService: TunerService,
@@ -282,6 +282,7 @@ class LegacyMediaDataManagerImpl(
smartspaceManager: SmartspaceManager?,
keyguardUpdateMonitor: KeyguardUpdateMonitor,
mediaDataLoader: dagger.Lazy<MediaDataLoader>,
+ mediaLogger: MediaLogger,
) : this(
context,
// Loading bitmap for UMO background can take longer time, so it cannot run on the default
@@ -301,7 +302,6 @@ class LegacyMediaDataManagerImpl(
mediaDeviceManager,
mediaDataCombineLatest,
mediaDataFilter,
- activityStarter,
smartspaceMediaDataProvider,
Utils.useMediaResumption(context),
Utils.useQsMediaPlayer(context),
@@ -312,6 +312,7 @@ class LegacyMediaDataManagerImpl(
smartspaceManager,
keyguardUpdateMonitor,
mediaDataLoader,
+ mediaLogger,
)
private val appChangeReceiver =
@@ -564,6 +565,42 @@ class LegacyMediaDataManagerImpl(
val resumeAction: Runnable? = currentEntry?.resumeAction
val hasCheckedForResume = currentEntry?.hasCheckedForResume == true
val active = currentEntry?.active ?: true
+ val mediaController = mediaControllerFactory.create(result.token!!)
+
+ val mediaData =
+ MediaData(
+ userId = sbn.normalizedUserId,
+ initialized = true,
+ app = result.appName,
+ appIcon = result.appIcon,
+ artist = result.artist,
+ song = result.song,
+ artwork = result.artworkIcon,
+ actions = result.actionIcons,
+ actionsToShowInCompact = result.actionsToShowInCompact,
+ semanticActions = result.semanticActions,
+ packageName = sbn.packageName,
+ token = result.token,
+ clickIntent = result.clickIntent,
+ device = result.device,
+ active = active,
+ resumeAction = resumeAction,
+ playbackLocation = result.playbackLocation,
+ notificationKey = key,
+ hasCheckedForResume = hasCheckedForResume,
+ isPlaying = result.isPlaying,
+ isClearable = !sbn.isOngoing,
+ lastActive = lastActive,
+ createdTimestampMillis = createdTimestampMillis,
+ instanceId = instanceId,
+ appUid = result.appUid,
+ isExplicit = result.isExplicit,
+ )
+
+ if (isSameMediaData(context, mediaController, mediaData, currentEntry)) {
+ mediaLogger.logDuplicateMediaNotification(key)
+ return@withContext
+ }
// We need to log the correct media added.
if (isNewlyActiveEntry) {
@@ -583,40 +620,7 @@ class LegacyMediaDataManagerImpl(
)
}
- withContext(mainDispatcher) {
- onMediaDataLoaded(
- key,
- oldKey,
- MediaData(
- userId = sbn.normalizedUserId,
- initialized = true,
- app = result.appName,
- appIcon = result.appIcon,
- artist = result.artist,
- song = result.song,
- artwork = result.artworkIcon,
- actions = result.actionIcons,
- actionsToShowInCompact = result.actionsToShowInCompact,
- semanticActions = result.semanticActions,
- packageName = sbn.packageName,
- token = result.token,
- clickIntent = result.clickIntent,
- device = result.device,
- active = active,
- resumeAction = resumeAction,
- playbackLocation = result.playbackLocation,
- notificationKey = key,
- hasCheckedForResume = hasCheckedForResume,
- isPlaying = result.isPlaying,
- isClearable = !sbn.isOngoing,
- lastActive = lastActive,
- createdTimestampMillis = createdTimestampMillis,
- instanceId = instanceId,
- appUid = result.appUid,
- isExplicit = result.isExplicit,
- )
- )
- }
+ withContext(mainDispatcher) { onMediaDataLoaded(key, oldKey, mediaData) }
}
/** Add a listener for changes in this class */
@@ -1100,6 +1104,47 @@ class LegacyMediaDataManagerImpl(
val instanceId = currentEntry?.instanceId ?: logger.getNewInstanceId()
val appUid = appInfo?.uid ?: Process.INVALID_UID
+ val lastActive = systemClock.elapsedRealtime()
+ val createdTimestampMillis = currentEntry?.createdTimestampMillis ?: 0L
+ val resumeAction: Runnable? = mediaEntries[key]?.resumeAction
+ val hasCheckedForResume = mediaEntries[key]?.hasCheckedForResume == true
+ val active = mediaEntries[key]?.active ?: true
+ var mediaData =
+ MediaData(
+ sbn.normalizedUserId,
+ true,
+ appName,
+ smallIcon,
+ artist,
+ song,
+ artWorkIcon,
+ actionIcons,
+ actionsToShowCollapsed,
+ semanticActions,
+ sbn.packageName,
+ token,
+ notif.contentIntent,
+ device,
+ active,
+ resumeAction = resumeAction,
+ playbackLocation = playbackLocation,
+ notificationKey = key,
+ hasCheckedForResume = hasCheckedForResume,
+ isPlaying = isPlaying,
+ isClearable = !sbn.isOngoing,
+ lastActive = lastActive,
+ createdTimestampMillis = createdTimestampMillis,
+ instanceId = instanceId,
+ appUid = appUid,
+ isExplicit = isExplicit,
+ smartspaceId = SmallHash.hash(appUid + systemClock.currentTimeMillis().toInt()),
+ )
+
+ if (isSameMediaData(context, mediaController, mediaData, currentEntry)) {
+ mediaLogger.logDuplicateMediaNotification(key)
+ return
+ }
+
if (isNewlyActiveEntry) {
logSingleVsMultipleMediaAdded(appUid, sbn.packageName, instanceId)
logger.logActiveMediaAdded(appUid, sbn.packageName, instanceId, playbackLocation)
@@ -1107,44 +1152,17 @@ class LegacyMediaDataManagerImpl(
logger.logPlaybackLocationChange(appUid, sbn.packageName, instanceId, playbackLocation)
}
- val lastActive = systemClock.elapsedRealtime()
- val createdTimestampMillis = currentEntry?.createdTimestampMillis ?: 0L
foregroundExecutor.execute {
- val resumeAction: Runnable? = mediaEntries[key]?.resumeAction
- val hasCheckedForResume = mediaEntries[key]?.hasCheckedForResume == true
- val active = mediaEntries[key]?.active ?: true
- onMediaDataLoaded(
- key,
- oldKey,
- MediaData(
- sbn.normalizedUserId,
- true,
- appName,
- smallIcon,
- artist,
- song,
- artWorkIcon,
- actionIcons,
- actionsToShowCollapsed,
- semanticActions,
- sbn.packageName,
- token,
- notif.contentIntent,
- device,
- active,
- resumeAction = resumeAction,
- playbackLocation = playbackLocation,
- notificationKey = key,
- hasCheckedForResume = hasCheckedForResume,
- isPlaying = isPlaying,
- isClearable = !sbn.isOngoing,
- lastActive = lastActive,
- createdTimestampMillis = createdTimestampMillis,
- instanceId = instanceId,
- appUid = appUid,
- isExplicit = isExplicit,
+ val oldResumeAction: Runnable? = mediaEntries[key]?.resumeAction
+ val oldHasCheckedForResume = mediaEntries[key]?.hasCheckedForResume == true
+ val oldActive = mediaEntries[key]?.active ?: true
+ mediaData =
+ mediaData.copy(
+ resumeAction = oldResumeAction,
+ hasCheckedForResume = oldHasCheckedForResume,
+ active = oldActive
)
- )
+ onMediaDataLoaded(key, oldKey, mediaData)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceLogger.kt b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceLogger.kt
new file mode 100644
index 000000000000..f886166b986b
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceLogger.kt
@@ -0,0 +1,116 @@
+/*
+ * Copyright (C) 2024 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.media.controls.domain.pipeline
+
+import android.media.session.MediaController
+import com.android.settingslib.media.MediaDevice
+import com.android.systemui.log.LogBuffer
+import com.android.systemui.log.core.LogLevel
+import com.android.systemui.log.dagger.MediaDeviceLog
+import com.android.systemui.media.controls.shared.model.MediaDeviceData
+import javax.inject.Inject
+
+/** A [LogBuffer] for media device changes */
+class MediaDeviceLogger @Inject constructor(@MediaDeviceLog private val buffer: LogBuffer) {
+
+ fun logBroadcastEvent(event: String, reason: Int, broadcastId: Int) {
+ buffer.log(
+ TAG,
+ LogLevel.DEBUG,
+ {
+ str1 = event
+ int1 = reason
+ int2 = broadcastId
+ },
+ { "$str1, reason = $int1, broadcastId = $int2" }
+ )
+ }
+
+ fun logBroadcastEvent(event: String, reason: Int) {
+ buffer.log(
+ TAG,
+ LogLevel.DEBUG,
+ {
+ str1 = event
+ int1 = reason
+ },
+ { "$str1, reason = $int1" }
+ )
+ }
+
+ fun logBroadcastMetadataChanged(broadcastId: Int, metadata: String) {
+ buffer.log(
+ TAG,
+ LogLevel.DEBUG,
+ {
+ int1 = broadcastId
+ str1 = metadata
+ },
+ { "onBroadcastMetadataChanged, broadcastId = $int1, metadata = $str1" }
+ )
+ }
+
+ fun logNewDeviceName(name: String?) {
+ buffer.log(TAG, LogLevel.DEBUG, { str1 = name }, { "New device name $str1" })
+ }
+
+ fun logLocalDevice(sassDevice: MediaDeviceData?, connectedDevice: MediaDeviceData?) {
+ buffer.log(
+ TAG,
+ LogLevel.DEBUG,
+ {
+ str1 = sassDevice?.name?.toString()
+ str2 = connectedDevice?.name?.toString()
+ },
+ { "Local device: $str1 or $str2" }
+ )
+ }
+
+ fun logRemoteDevice(routingSessionName: CharSequence?, connectedDevice: MediaDeviceData?) {
+ buffer.log(
+ TAG,
+ LogLevel.DEBUG,
+ {
+ str1 = routingSessionName?.toString()
+ str2 = connectedDevice?.name?.toString()
+ },
+ { "Remote device: $str1 or $str2 or unknown" }
+ )
+ }
+
+ fun logDeviceName(
+ device: MediaDevice?,
+ controller: MediaController?,
+ routingSessionName: CharSequence?,
+ selectedRouteName: CharSequence?
+ ) {
+ buffer.log(
+ TAG,
+ LogLevel.DEBUG,
+ {
+ str1 = "device $device, controller: $controller"
+ str2 = routingSessionName?.toString()
+ str3 = selectedRouteName?.toString()
+ },
+ { "$str1, routingSession $str2 or selected route $str3" }
+ )
+ }
+
+ companion object {
+ private const val TAG = "MediaDeviceLog"
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManager.kt b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManager.kt
index a193f7f8f498..49b53c2d78ae 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManager.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManager.kt
@@ -71,6 +71,7 @@ constructor(
private val localBluetoothManager: Lazy<LocalBluetoothManager?>,
@Main private val fgExecutor: Executor,
@Background private val bgExecutor: Executor,
+ private val logger: MediaDeviceLogger,
) : MediaDataManager.Listener {
private val listeners: MutableSet<Listener> = mutableSetOf()
@@ -281,59 +282,38 @@ constructor(
}
override fun onBroadcastStarted(reason: Int, broadcastId: Int) {
- if (DEBUG) {
- Log.d(TAG, "onBroadcastStarted(), reason = $reason , broadcastId = $broadcastId")
- }
+ logger.logBroadcastEvent("onBroadcastStarted", reason, broadcastId)
updateCurrent()
}
override fun onBroadcastStartFailed(reason: Int) {
- if (DEBUG) {
- Log.d(TAG, "onBroadcastStartFailed(), reason = $reason")
- }
+ logger.logBroadcastEvent("onBroadcastStartFailed", reason)
}
override fun onBroadcastMetadataChanged(
broadcastId: Int,
metadata: BluetoothLeBroadcastMetadata
) {
- if (DEBUG) {
- Log.d(
- TAG,
- "onBroadcastMetadataChanged(), broadcastId = $broadcastId , " +
- "metadata = $metadata"
- )
- }
+ logger.logBroadcastMetadataChanged(broadcastId, metadata.toString())
updateCurrent()
}
override fun onBroadcastStopped(reason: Int, broadcastId: Int) {
- if (DEBUG) {
- Log.d(TAG, "onBroadcastStopped(), reason = $reason , broadcastId = $broadcastId")
- }
+ logger.logBroadcastEvent("onBroadcastStopped", reason, broadcastId)
updateCurrent()
}
override fun onBroadcastStopFailed(reason: Int) {
- if (DEBUG) {
- Log.d(TAG, "onBroadcastStopFailed(), reason = $reason")
- }
+ logger.logBroadcastEvent("onBroadcastStopFailed", reason)
}
override fun onBroadcastUpdated(reason: Int, broadcastId: Int) {
- if (DEBUG) {
- Log.d(TAG, "onBroadcastUpdated(), reason = $reason , broadcastId = $broadcastId")
- }
+ logger.logBroadcastEvent("onBroadcastUpdated", reason, broadcastId)
updateCurrent()
}
override fun onBroadcastUpdateFailed(reason: Int, broadcastId: Int) {
- if (DEBUG) {
- Log.d(
- TAG,
- "onBroadcastUpdateFailed(), reason = $reason , " + "broadcastId = $broadcastId"
- )
- }
+ logger.logBroadcastEvent("onBroadcastUpdateFailed", reason, broadcastId)
}
override fun onPlaybackStarted(reason: Int, broadcastId: Int) {}
@@ -381,12 +361,16 @@ constructor(
name = context.getString(R.string.media_seamless_other_device),
showBroadcastButton = false
)
+ logger.logRemoteDevice(routingSession?.name, connectedDevice)
} else {
// Prefer SASS if available when playback is local.
- activeDevice = getSassDevice() ?: connectedDevice
+ val sassDevice = getSassDevice()
+ activeDevice = sassDevice ?: connectedDevice
+ logger.logLocalDevice(sassDevice, connectedDevice)
}
current = activeDevice ?: EMPTY_AND_DISABLED_MEDIA_DEVICE_DATA
+ logger.logNewDeviceName(current?.name?.toString())
} else {
val aboutToConnect = aboutToConnectDeviceOverride
if (
@@ -407,9 +391,7 @@ constructor(
val enabled = device != null && (controller == null || routingSession != null)
val name = getDeviceName(device, routingSession)
- if (DEBUG) {
- Log.d(TAG, "new device name $name")
- }
+ logger.logNewDeviceName(name)
current =
MediaDeviceData(
enabled,
@@ -463,14 +445,12 @@ constructor(
): String? {
val selectedRoutes = routingSession?.let { mr2manager.get().getSelectedRoutes(it) }
- if (DEBUG) {
- Log.d(
- TAG,
- "device is $device, controller $controller," +
- " routingSession ${routingSession?.name}" +
- " or ${selectedRoutes?.firstOrNull()?.name}"
- )
- }
+ logger.logDeviceName(
+ device,
+ controller,
+ routingSession?.name,
+ selectedRoutes?.firstOrNull()?.name
+ )
if (controller == null) {
// In resume state, we don't have a controller - just use the device name
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/domain/resume/MediaResumeListener.kt b/packages/SystemUI/src/com/android/systemui/media/controls/domain/resume/MediaResumeListener.kt
index e4047e5f96c5..9ee59d1875a6 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/domain/resume/MediaResumeListener.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/domain/resume/MediaResumeListener.kt
@@ -80,6 +80,7 @@ constructor(
field?.disconnect()
field = value
}
+
private var currentUserId: Int = context.userId
@VisibleForTesting
@@ -89,7 +90,7 @@ constructor(
if (Intent.ACTION_USER_UNLOCKED == intent.action) {
val userId = intent.getIntExtra(Intent.EXTRA_USER_HANDLE, -1)
if (userId == currentUserId) {
- loadMediaResumptionControls()
+ backgroundExecutor.execute { loadMediaResumptionControls() }
}
}
}
@@ -254,15 +255,15 @@ constructor(
if (data.resumeAction == null && !data.hasCheckedForResume && isEligibleForResume) {
// TODO also check for a media button receiver intended for restarting (b/154127084)
// Set null action to prevent additional attempts to connect
- mediaDataManager.setResumeAction(key, null)
- Log.d(TAG, "Checking for service component for " + data.packageName)
- val pm = context.packageManager
- val serviceIntent = Intent(MediaBrowserService.SERVICE_INTERFACE)
- val resumeInfo = pm.queryIntentServicesAsUser(serviceIntent, 0, currentUserId)
+ backgroundExecutor.execute {
+ mediaDataManager.setResumeAction(key, null)
+ Log.d(TAG, "Checking for service component for " + data.packageName)
+ val pm = context.packageManager
+ val serviceIntent = Intent(MediaBrowserService.SERVICE_INTERFACE)
+ val resumeInfo = pm.queryIntentServicesAsUser(serviceIntent, 0, currentUserId)
- val inf = resumeInfo?.filter { it.serviceInfo.packageName == data.packageName }
- if (inf != null && inf.size > 0) {
- backgroundExecutor.execute {
+ val inf = resumeInfo?.filter { it.serviceInfo.packageName == data.packageName }
+ if (inf != null && inf.size > 0) {
tryUpdateResumptionList(key, inf!!.get(0).componentInfo.componentName)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModel.kt b/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModel.kt
index cef1e69e7b6a..2a9fe8314349 100644
--- a/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModel.kt
@@ -32,6 +32,7 @@ import androidx.annotation.WorkerThread
import androidx.core.view.GestureDetectorCompat
import androidx.lifecycle.LiveData
import androidx.lifecycle.MutableLiveData
+import com.android.systemui.Flags
import com.android.systemui.classifier.Classifier.MEDIA_SEEKBAR
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.plugins.FalsingManager
@@ -102,9 +103,11 @@ constructor(
}
_progress.postValue(value)
}
+
private val _progress = MutableLiveData<Progress>().apply { postValue(_data) }
val progress: LiveData<Progress>
get() = _progress
+
private var controller: MediaController? = null
set(value) {
if (field?.sessionToken != value?.sessionToken) {
@@ -113,6 +116,7 @@ constructor(
field = value
}
}
+
private var playbackState: PlaybackState? = null
private var callback =
object : MediaController.Callback() {
@@ -128,6 +132,15 @@ constructor(
override fun onSessionDestroyed() {
clearController()
}
+
+ override fun onMetadataChanged(metadata: MediaMetadata?) {
+ if (!Flags.mediaControlsPostsOptimization()) return
+
+ val (enabled, duration) = getEnabledStateAndDuration(metadata)
+ if (_data.duration != duration) {
+ _data = _data.copy(enabled = enabled, duration = duration)
+ }
+ }
}
private var cancel: Runnable? = null
@@ -233,22 +246,13 @@ constructor(
fun updateController(mediaController: MediaController?) {
controller = mediaController
playbackState = controller?.playbackState
- val mediaMetadata = controller?.metadata
+ val (enabled, duration) = getEnabledStateAndDuration(controller?.metadata)
val seekAvailable = ((playbackState?.actions ?: 0L) and PlaybackState.ACTION_SEEK_TO) != 0L
val position = playbackState?.position?.toInt()
- val duration = mediaMetadata?.getLong(MediaMetadata.METADATA_KEY_DURATION)?.toInt() ?: 0
val playing =
NotificationMediaManager.isPlayingState(
playbackState?.state ?: PlaybackState.STATE_NONE
)
- val enabled =
- if (
- playbackState == null ||
- playbackState?.getState() == PlaybackState.STATE_NONE ||
- (duration <= 0)
- )
- false
- else true
_data = Progress(enabled, seekAvailable, playing, scrubbing, position, duration, listening)
checkIfPollingNeeded()
}
@@ -368,6 +372,16 @@ constructor(
}
}
+ /** returns a pair of whether seekbar is enabled and the duration of media. */
+ private fun getEnabledStateAndDuration(metadata: MediaMetadata?): Pair<Boolean, Int> {
+ val duration = metadata?.getLong(MediaMetadata.METADATA_KEY_DURATION)?.toInt() ?: 0
+ val enabled =
+ !(playbackState == null ||
+ playbackState?.state == PlaybackState.STATE_NONE ||
+ (duration <= 0))
+ return Pair(enabled, duration)
+ }
+
/**
* This method specifies if user made a bad seekbar grab or not. If the vertical distance from
* first touch on seekbar is more than the horizontal distance, this means that the seekbar grab
diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverLogger.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverLogger.kt
index 1502df725a9c..078d534833d1 100644
--- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverLogger.kt
@@ -19,6 +19,7 @@ package com.android.systemui.media.taptotransfer.receiver
import android.app.StatusBarManager
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.log.LogBuffer
+import com.android.systemui.log.core.LogLevel
import com.android.systemui.media.taptotransfer.common.MediaTttLoggerUtils
import com.android.systemui.temporarydisplay.TemporaryViewLogger
import javax.inject.Inject
@@ -50,6 +51,15 @@ constructor(
MediaTttLoggerUtils.logPackageNotFound(buffer, TAG, packageName)
}
+ fun logRippleAnimationEnd(id: Int) {
+ buffer.log(
+ tag,
+ LogLevel.DEBUG,
+ { int1 = id },
+ { "ripple animation for view with id: $int1 is ended" }
+ )
+ }
+
companion object {
private const val TAG = "MediaTttReceiver"
}
diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverRippleController.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverRippleController.kt
index fbd7fd3fe821..a232971c4e3f 100644
--- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverRippleController.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/MediaTttReceiverRippleController.kt
@@ -32,6 +32,7 @@ class MediaTttReceiverRippleController
constructor(
private val context: Context,
private val windowManager: WindowManager,
+ private val mediaTttReceiverLogger: MediaTttReceiverLogger,
) {
private var maxRippleWidth: Float = 0f
@@ -90,12 +91,12 @@ constructor(
/** Expands the ripple to cover the screen. */
fun expandToSuccessState(rippleView: ReceiverChipRippleView, onAnimationEnd: Runnable?) {
layoutRipple(rippleView, isFullScreen = true)
- rippleView.expandToFull(maxRippleHeight, onAnimationEnd)
+ rippleView.expandToFull(maxRippleHeight, mediaTttReceiverLogger, onAnimationEnd)
}
/** Collapses the ripple. */
fun collapseRipple(rippleView: ReceiverChipRippleView, onAnimationEnd: Runnable? = null) {
- rippleView.collapseRipple(onAnimationEnd)
+ rippleView.collapseRipple(mediaTttReceiverLogger, onAnimationEnd)
}
private fun layoutRipple(rippleView: ReceiverChipRippleView, isFullScreen: Boolean = false) {
diff --git a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt
index 35018f190394..81059e31f3c1 100644
--- a/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt
+++ b/packages/SystemUI/src/com/android/systemui/media/taptotransfer/receiver/ReceiverChipRippleView.kt
@@ -24,9 +24,7 @@ import com.android.systemui.surfaceeffects.ripple.RippleShader
import com.android.systemui.surfaceeffects.ripple.RippleView
import kotlin.math.pow
-/**
- * An expanding ripple effect for the media tap-to-transfer receiver chip.
- */
+/** An expanding ripple effect for the media tap-to-transfer receiver chip. */
class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleView(context, attrs) {
// Indicates whether the ripple started expanding.
@@ -46,24 +44,34 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi
}
/** Used to animate out the ripple. No-op if the ripple was never started via [startRipple]. */
- fun collapseRipple(onAnimationEnd: Runnable? = null) {
+ fun collapseRipple(logger: MediaTttReceiverLogger, onAnimationEnd: Runnable? = null) {
if (!isStarted) {
return // Ignore if ripple is not started yet.
}
duration = DEFAULT_DURATION
// Reset all listeners to animator.
animator.removeAllListeners()
- animator.addListener(object : AnimatorListenerAdapter() {
- override fun onAnimationEnd(animation: Animator) {
- onAnimationEnd?.run()
- isStarted = false
+ animator.addListener(
+ object : AnimatorListenerAdapter() {
+ override fun onAnimationEnd(animation: Animator) {
+ animation?.let {
+ visibility = GONE
+ logger.logRippleAnimationEnd(id)
+ }
+ onAnimationEnd?.run()
+ isStarted = false
+ }
}
- })
+ )
animator.reverse()
}
// Expands the ripple to cover full screen.
- fun expandToFull(newHeight: Float, onAnimationEnd: Runnable? = null) {
+ fun expandToFull(
+ newHeight: Float,
+ logger: MediaTttReceiverLogger,
+ onAnimationEnd: Runnable? = null
+ ) {
if (!isStarted) {
return
}
@@ -85,13 +93,18 @@ class ReceiverChipRippleView(context: Context?, attrs: AttributeSet?) : RippleVi
rippleShader.time = now.toFloat()
invalidate()
}
- animator.addListener(object : AnimatorListenerAdapter() {
- override fun onAnimationEnd(animation: Animator) {
- animation?.let { visibility = GONE }
- onAnimationEnd?.run()
- isStarted = false
+ animator.addListener(
+ object : AnimatorListenerAdapter() {
+ override fun onAnimationEnd(animation: Animator) {
+ animation?.let {
+ visibility = GONE
+ logger.logRippleAnimationEnd(id)
+ }
+ onAnimationEnd?.run()
+ isStarted = false
+ }
}
- })
+ )
animator.start()
}
diff --git a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java
index 18c6f53630a4..4251b81226b3 100644
--- a/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/mediaprojection/permission/MediaProjectionPermissionActivity.java
@@ -307,7 +307,7 @@ public class MediaProjectionPermissionActivity extends Activity {
private void setUpDialog(AlertDialog dialog) {
SystemUIDialog.registerDismissListener(dialog);
- SystemUIDialog.applyFlags(dialog);
+ SystemUIDialog.applyFlags(dialog, /* showWhenLocked= */ false);
SystemUIDialog.setDialogSize(dialog);
dialog.setOnCancelListener(this::onDialogDismissedOrCancelled);
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java b/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java
index e44069f78ee3..b3c697e06a92 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/TaskbarDelegate.java
@@ -425,6 +425,18 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
}
}
+ private void appTransitionPending(boolean pending) {
+ if (mOverviewProxyService.getProxy() == null) {
+ return;
+ }
+
+ try {
+ mOverviewProxyService.getProxy().appTransitionPending(pending);
+ } catch (RemoteException e) {
+ Log.e(TAG, "appTransitionPending() failed, pending: " + pending, e);
+ }
+ }
+
@Override
public void setImeWindowStatus(int displayId, @ImeWindowVisibility int vis,
@BackDispositionMode int backDisposition, boolean showImeSwitcher) {
@@ -533,6 +545,21 @@ public class TaskbarDelegate implements CommandQueue.Callbacks,
}
}
+ @Override
+ public void appTransitionPending(int displayId, boolean forced) {
+ appTransitionPending(true);
+ }
+
+ @Override
+ public void appTransitionCancelled(int displayId) {
+ appTransitionPending(false);
+ }
+
+ @Override
+ public void appTransitionFinished(int displayId) {
+ appTransitionPending(false);
+ }
+
private void clearTransient() {
if (mTaskbarTransientShowing) {
mTaskbarTransientShowing = false;
diff --git a/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java b/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java
index e8c90c1fc9bf..c70a5234dfca 100644
--- a/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java
+++ b/packages/SystemUI/src/com/android/systemui/navigationbar/views/NavigationBar.java
@@ -34,7 +34,6 @@ import static android.view.WindowManager.LayoutParams.TYPE_INPUT_METHOD;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_GESTURAL;
-import static com.android.internal.accessibility.common.ShortcutConstants.CHOOSER_PACKAGE_NAME;
import static com.android.internal.config.sysui.SystemUiDeviceConfigFlags.HOME_BUTTON_LONG_PRESS_DURATION_MS;
import static com.android.systemui.navigationbar.NavBarHelper.transitionMode;
import static com.android.systemui.recents.OverviewProxyService.OverviewProxyListener;
@@ -60,7 +59,6 @@ import android.app.ActivityTaskManager;
import android.app.IActivityTaskManager;
import android.app.StatusBarManager;
import android.content.Context;
-import android.content.Intent;
import android.content.res.Configuration;
import android.graphics.Insets;
import android.graphics.PixelFormat;
@@ -105,7 +103,6 @@ import androidx.annotation.Nullable;
import androidx.annotation.VisibleForTesting;
import com.android.app.viewcapture.ViewCaptureAwareWindowManager;
-import com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.UiEvent;
import com.android.internal.logging.UiEventLogger;
@@ -1625,11 +1622,9 @@ public class NavigationBar extends ViewController<NavigationBarView> implements
}
private boolean onAccessibilityLongClick(View v) {
- final Intent intent = new Intent(AccessibilityManager.ACTION_CHOOSE_ACCESSIBILITY_BUTTON);
- intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- final String chooserClassName = AccessibilityButtonChooserActivity.class.getName();
- intent.setClassName(CHOOSER_PACKAGE_NAME, chooserClassName);
- mContext.startActivityAsUser(intent, mUserTracker.getUserHandle());
+ final Display display = v.getDisplay();
+ mAccessibilityManager.notifyAccessibilityButtonLongClicked(
+ display != null ? display.getDisplayId() : mDisplayTracker.getDefaultDisplayId());
return true;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qrcodescanner/dagger/QRCodeScannerModule.kt b/packages/SystemUI/src/com/android/systemui/qrcodescanner/dagger/QRCodeScannerModule.kt
index 3a8fe7198ebd..ef1f8341cb15 100644
--- a/packages/SystemUI/src/com/android/systemui/qrcodescanner/dagger/QRCodeScannerModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/qrcodescanner/dagger/QRCodeScannerModule.kt
@@ -19,6 +19,7 @@ package com.android.systemui.qrcodescanner.dagger
import com.android.systemui.Flags
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.qs.tiles.QRCodeScannerTile
import com.android.systemui.qs.tiles.base.interactor.QSTileAvailabilityInteractor
@@ -51,7 +52,7 @@ interface QRCodeScannerModule {
@IntoMap
@StringKey(QR_CODE_SCANNER_TILE_SPEC)
fun provideQrCodeScannerAvailabilityInteractor(
- impl: QRCodeScannerTileDataInteractor
+ impl: QRCodeScannerTileDataInteractor
): QSTileAvailabilityInteractor
companion object {
@@ -69,6 +70,7 @@ interface QRCodeScannerModule {
labelRes = R.string.qr_code_scanner_title,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.UTILITIES,
)
/** Inject QR Code Scanner Tile into tileViewModelMap in QSModule. */
diff --git a/packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt b/packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt
index c39ff557e54f..c2f1c3dcd426 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt
@@ -19,6 +19,7 @@ package com.android.systemui.qs.composefragment
import android.annotation.SuppressLint
import android.graphics.Rect
import android.os.Bundle
+import android.util.IndentingPrintWriter
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
@@ -41,8 +42,8 @@ import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import androidx.compose.ui.Modifier
-import androidx.compose.ui.layout.layout
-import androidx.compose.ui.layout.onGloballyPositioned
+import androidx.compose.ui.layout.onPlaced
+import androidx.compose.ui.layout.onSizeChanged
import androidx.compose.ui.layout.positionInRoot
import androidx.compose.ui.platform.ComposeView
import androidx.compose.ui.res.dimensionResource
@@ -59,7 +60,9 @@ import com.android.compose.modifiers.height
import com.android.compose.modifiers.padding
import com.android.compose.modifiers.thenIf
import com.android.compose.theme.PlatformTheme
+import com.android.systemui.Dumpable
import com.android.systemui.compose.modifiers.sysuiResTag
+import com.android.systemui.dump.DumpManager
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.media.controls.ui.controller.MediaHierarchyManager
import com.android.systemui.media.controls.ui.view.MediaHost
@@ -76,6 +79,10 @@ import com.android.systemui.qs.ui.composable.QuickSettingsTheme
import com.android.systemui.qs.ui.composable.ShadeBody
import com.android.systemui.res.R
import com.android.systemui.util.LifecycleFragment
+import com.android.systemui.util.asIndenting
+import com.android.systemui.util.printSection
+import com.android.systemui.util.println
+import java.io.PrintWriter
import java.util.function.Consumer
import javax.inject.Inject
import javax.inject.Named
@@ -91,9 +98,10 @@ class QSFragmentCompose
@Inject
constructor(
private val qsFragmentComposeViewModelFactory: QSFragmentComposeViewModel.Factory,
+ private val dumpManager: DumpManager,
@Named(QUICK_QS_PANEL) private val qqsMediaHost: MediaHost,
@Named(QS_PANEL) private val qsMediaHost: MediaHost,
-) : LifecycleFragment(), QS {
+) : LifecycleFragment(), QS, Dumpable {
private val scrollListener = MutableStateFlow<QS.ScrollListener?>(null)
private val heightListener = MutableStateFlow<QS.HeightListener?>(null)
@@ -118,8 +126,24 @@ constructor(
var top by mutableStateOf(0)
var bottom by mutableStateOf(0)
var radius by mutableStateOf(0)
+
+ fun dump(pw: IndentingPrintWriter) {
+ pw.printSection("NotificationScrimClippingParams") {
+ pw.println("isEnabled", isEnabled)
+ pw.println("leftInset", "${leftInset}px")
+ pw.println("rightInset", "${rightInset}px")
+ pw.println("top", "${top}px")
+ pw.println("bottom", "${bottom}px")
+ pw.println("radius", "${radius}px")
+ }
+ }
}
+ override fun onStart() {
+ super.onStart()
+ registerDumpable()
+ }
+
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
@@ -343,11 +367,11 @@ constructor(
}
override fun getHeaderTop(): Int {
- return viewModel.qqsHeaderHeight.value
+ return qqsPositionOnRoot.top
}
override fun getHeaderBottom(): Int {
- return headerTop + qqsHeight.value
+ return qqsPositionOnRoot.bottom
}
override fun getHeaderLeft(): Int {
@@ -358,7 +382,7 @@ constructor(
outBounds.set(qqsPositionOnRoot)
view?.getBoundsOnScreen(composeViewPositionOnScreen)
?: run { composeViewPositionOnScreen.setEmpty() }
- qqsPositionOnRoot.offset(composeViewPositionOnScreen.left, composeViewPositionOnScreen.top)
+ outBounds.offset(composeViewPositionOnScreen.left, composeViewPositionOnScreen.top)
}
override fun isHeaderShown(): Boolean {
@@ -404,37 +428,29 @@ constructor(
onDispose { qqsVisible.value = false }
}
Column(modifier = Modifier.sysuiResTag("quick_qs_panel")) {
- Box(modifier = Modifier.fillMaxWidth()) {
+ Box(
+ modifier =
+ Modifier.fillMaxWidth()
+ .onPlaced { coordinates ->
+ val (leftFromRoot, topFromRoot) = coordinates.positionInRoot().round()
+ qqsPositionOnRoot.set(
+ leftFromRoot,
+ topFromRoot,
+ leftFromRoot + coordinates.size.width,
+ topFromRoot + coordinates.size.height,
+ )
+ }
+ .onSizeChanged { size -> qqsHeight.value = size.height }
+ .padding(top = { qqsPadding })
+ ) {
val qsEnabled by viewModel.qsEnabled.collectAsStateWithLifecycle()
if (qsEnabled) {
QuickQuickSettings(
viewModel = viewModel.containerViewModel.quickQuickSettingsViewModel,
modifier =
- Modifier.onGloballyPositioned { coordinates ->
- val (leftFromRoot, topFromRoot) =
- coordinates.positionInRoot().round()
- val (width, height) = coordinates.size
- qqsPositionOnRoot.set(
- leftFromRoot,
- topFromRoot,
- leftFromRoot + width,
- topFromRoot + height
- )
- }
- .layout { measurable, constraints ->
- val placeable = measurable.measure(constraints)
- qqsHeight.value = placeable.height
-
- layout(placeable.width, placeable.height) {
- placeable.place(0, 0)
- }
- }
- .padding(top = { qqsPadding })
- .collapseExpandSemanticAction(
- stringResource(
- id = R.string.accessibility_quick_settings_expand
- )
- )
+ Modifier.collapseExpandSemanticAction(
+ stringResource(id = R.string.accessibility_quick_settings_expand)
+ )
)
}
}
@@ -486,6 +502,44 @@ constructor(
}
} ?: this
}
+
+ private fun registerDumpable() {
+ val instanceId = instanceProvider.getNextId()
+ // Add an instanceId because the system may have more than 1 of these when re-inflating and
+ // DumpManager doesn't like repeated identifiers. Also, put it first because DumpHandler
+ // matches by end.
+ val stringId = "$instanceId-QSFragmentCompose"
+ lifecycleScope.launch {
+ lifecycle.repeatOnLifecycle(Lifecycle.State.CREATED) {
+ try {
+ dumpManager.registerNormalDumpable(stringId, this@QSFragmentCompose)
+ awaitCancellation()
+ } finally {
+ dumpManager.unregisterDumpable(stringId)
+ }
+ }
+ }
+ }
+
+ override fun dump(pw: PrintWriter, args: Array<out String>) {
+ pw.asIndenting().run {
+ notificationScrimClippingParams.dump(this)
+ printSection("QQS positioning") {
+ println("qqsHeight", "${headerHeight}px")
+ println("qqsTop", "${headerTop}px")
+ println("qqsBottom", "${headerBottom}px")
+ println("qqsLeft", "${headerLeft}px")
+ println("qqsPositionOnRoot", qqsPositionOnRoot)
+ val rect = Rect()
+ getHeaderBoundsOnScreen(rect)
+ println("qqsPositionOnScreen", rect)
+ }
+ println("QQS visible", qqsVisible.value)
+ if (::viewModel.isInitialized) {
+ printSection("View Model") { viewModel.dump(this@run, args) }
+ }
+ }
+ }
}
private fun View.setBackPressedDispatcher() {
@@ -526,3 +580,12 @@ private suspend inline fun <Listener : Any, Data> setListenerJob(
}
}
}
+
+private val instanceProvider =
+ object {
+ private var currentId = 0
+
+ fun getNextId(): Int {
+ return currentId++
+ }
+ }
diff --git a/packages/SystemUI/src/com/android/systemui/qs/composefragment/viewmodel/QSFragmentComposeViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/composefragment/viewmodel/QSFragmentComposeViewModel.kt
index 16133f482f7b..7ab11d22ee49 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/composefragment/viewmodel/QSFragmentComposeViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/composefragment/viewmodel/QSFragmentComposeViewModel.kt
@@ -21,6 +21,7 @@ import android.graphics.Rect
import androidx.annotation.FloatRange
import androidx.annotation.VisibleForTesting
import androidx.lifecycle.LifecycleCoroutineScope
+import com.android.systemui.Dumpable
import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.plugins.statusbar.StatusBarStateController
@@ -34,10 +35,14 @@ import com.android.systemui.statusbar.SysuiStatusBarStateController
import com.android.systemui.statusbar.disableflags.data.repository.DisableFlagsRepository
import com.android.systemui.statusbar.phone.KeyguardBypassController
import com.android.systemui.util.LargeScreenUtils
+import com.android.systemui.util.asIndenting
+import com.android.systemui.util.printSection
+import com.android.systemui.util.println
import com.android.systemui.utils.coroutines.flow.conflatedCallbackFlow
import dagger.assisted.Assisted
import dagger.assisted.AssistedFactory
import dagger.assisted.AssistedInject
+import java.io.PrintWriter
import kotlinx.coroutines.channels.awaitClose
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
@@ -62,7 +67,7 @@ constructor(
private val configurationInteractor: ConfigurationInteractor,
private val largeScreenHeaderHelper: LargeScreenHeaderHelper,
@Assisted private val lifecycleScope: LifecycleCoroutineScope,
-) {
+) : Dumpable {
val footerActionsViewModel =
footerActionsViewModelFactory.create(lifecycleScope).also {
lifecycleScope.launch { footerActionsController.init() }
@@ -228,6 +233,30 @@ constructor(
*/
var collapseExpandAccessibilityAction: Runnable? = null
+ override fun dump(pw: PrintWriter, args: Array<out String>) {
+ pw.asIndenting().run {
+ printSection("Quick Settings state") {
+ println("isQSExpanded", isQSExpanded)
+ println("isQSVisible", isQSVisible)
+ println("isQSEnabled", qsEnabled.value)
+ println("isCustomizing", containerViewModel.editModeViewModel.isEditing.value)
+ }
+ printSection("Expansion state") {
+ println("qsExpansion", qsExpansionValue)
+ println("panelExpansionFraction", panelExpansionFractionValue)
+ println("squishinessFraction", squishinessFractionValue)
+ println("expansionState", expansionState.value)
+ }
+ printSection("Shade state") {
+ println("stackOverscrolling", stackScrollerOverscrollingValue)
+ println("statusBarState", StatusBarState.toString(statusBarState.value))
+ println("isSmallScreen", isSmallScreenValue)
+ println("heightOverride", "${heightOverrideValue}px")
+ println("qqsHeaderHeight", "${qqsHeaderHeight.value}px")
+ }
+ }
+ }
+
@AssistedFactory
interface Factory {
fun create(lifecycleScope: LifecycleCoroutineScope): QSFragmentComposeViewModel
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
index cbcf68c27bf8..2f843ac610a3 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileLifecycleManager.java
@@ -50,10 +50,12 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.annotation.WorkerThread;
+import com.android.systemui.Flags;
import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.util.concurrency.DelayableExecutor;
+import com.android.systemui.util.time.SystemClock;
import dagger.assisted.Assisted;
import dagger.assisted.AssistedFactory;
@@ -95,6 +97,7 @@ public class TileLifecycleManager extends BroadcastReceiver implements
// Bind retry control.
private static final int MAX_BIND_RETRIES = 5;
private static final long DEFAULT_BIND_RETRY_DELAY = 5 * DateUtils.SECOND_IN_MILLIS;
+ private static final long ACTIVE_TILE_BIND_RETRY_DELAY = 1 * DateUtils.SECOND_IN_MILLIS;
private static final long LOW_MEMORY_BIND_RETRY_DELAY = 20 * DateUtils.SECOND_IN_MILLIS;
private static final long TILE_SERVICE_ONCLICK_ALLOW_LIST_DEFAULT_DURATION_MS = 15_000;
private static final String PROPERTY_TILE_SERVICE_ONCLICK_ALLOW_LIST_DURATION =
@@ -107,6 +110,7 @@ public class TileLifecycleManager extends BroadcastReceiver implements
private final Intent mIntent;
private final UserHandle mUser;
private final DelayableExecutor mExecutor;
+ private final SystemClock mSystemClock;
private final IBinder mToken = new Binder();
private final PackageManagerAdapter mPackageManagerAdapter;
private final BroadcastDispatcher mBroadcastDispatcher;
@@ -120,7 +124,6 @@ public class TileLifecycleManager extends BroadcastReceiver implements
private IBinder mClickBinder;
private int mBindTryCount;
- private long mBindRetryDelay = DEFAULT_BIND_RETRY_DELAY;
private AtomicBoolean isDeathRebindScheduled = new AtomicBoolean(false);
private AtomicBoolean mBound = new AtomicBoolean(false);
private AtomicBoolean mPackageReceiverRegistered = new AtomicBoolean(false);
@@ -138,7 +141,8 @@ public class TileLifecycleManager extends BroadcastReceiver implements
TileLifecycleManager(@Main Handler handler, Context context, IQSService service,
PackageManagerAdapter packageManagerAdapter, BroadcastDispatcher broadcastDispatcher,
@Assisted Intent intent, @Assisted UserHandle user, ActivityManager activityManager,
- IDeviceIdleController deviceIdleController, @Background DelayableExecutor executor) {
+ IDeviceIdleController deviceIdleController, @Background DelayableExecutor executor,
+ SystemClock systemClock) {
mContext = context;
mHandler = handler;
mIntent = intent;
@@ -146,6 +150,7 @@ public class TileLifecycleManager extends BroadcastReceiver implements
mIntent.putExtra(TileService.EXTRA_TOKEN, mToken);
mUser = user;
mExecutor = executor;
+ mSystemClock = systemClock;
mPackageManagerAdapter = packageManagerAdapter;
mBroadcastDispatcher = broadcastDispatcher;
mActivityManager = activityManager;
@@ -436,25 +441,31 @@ public class TileLifecycleManager extends BroadcastReceiver implements
// If mBound is true (meaning that we should be bound), then reschedule binding for
// later.
if (mBound.get() && checkComponentState()) {
- if (isDeathRebindScheduled.compareAndSet(false, true)) {
+ if (isDeathRebindScheduled.compareAndSet(false, true)) { // if already not scheduled
+
+
mExecutor.executeDelayed(() -> {
// Only rebind if we are supposed to, but remove the scheduling anyway.
if (mBound.get()) {
setBindService(true);
}
- isDeathRebindScheduled.set(false);
+ isDeathRebindScheduled.set(false); // allow scheduling again
}, getRebindDelay());
}
}
});
}
+ private long mLastRebind = 0;
/**
* @return the delay to automatically rebind after a service died. It provides a longer delay if
* the device is a low memory state because the service is likely to get killed again by the
* system. In this case we want to rebind later and not to cause a loop of a frequent rebinds.
+ * It also provides a longer delay if called quickly (a few seconds) after a first call.
*/
private long getRebindDelay() {
+ final long now = mSystemClock.currentTimeMillis();
+
final ActivityManager.MemoryInfo info = new ActivityManager.MemoryInfo();
mActivityManager.getMemoryInfo(info);
@@ -462,7 +473,20 @@ public class TileLifecycleManager extends BroadcastReceiver implements
if (info.lowMemory) {
delay = LOW_MEMORY_BIND_RETRY_DELAY;
} else {
- delay = mBindRetryDelay;
+ if (Flags.qsQuickRebindActiveTiles()) {
+ final long elapsedTimeSinceLastRebind = now - mLastRebind;
+ final boolean justAttemptedRebind =
+ elapsedTimeSinceLastRebind < DEFAULT_BIND_RETRY_DELAY;
+ if (isActiveTile() && !justAttemptedRebind) {
+ delay = ACTIVE_TILE_BIND_RETRY_DELAY;
+ } else {
+ delay = DEFAULT_BIND_RETRY_DELAY;
+ }
+ } else {
+ delay = DEFAULT_BIND_RETRY_DELAY;
+ }
+
+ mLastRebind = now;
}
if (mDebug) Log.i(TAG, "Rebinding with a delay=" + delay + " - " + getComponent());
return delay;
diff --git a/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java b/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java
index d10471d86d0b..c5fa8cf05fd0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/external/TileServiceManager.java
@@ -44,7 +44,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
/**
* Manages the priority which lets {@link TileServices} make decisions about which tiles
* to bind. Also holds on to and manages the {@link TileLifecycleManager}, informing it
- * of when it is allowed to bind based on decisions frome the {@link TileServices}.
+ * of when it is allowed to bind based on decisions from the {@link TileServices}.
*/
public class TileServiceManager {
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepository.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepository.kt
index 28c1fbf2007d..2f054b0a82c0 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/data/repository/IconAndNameCustomRepository.kt
@@ -24,10 +24,10 @@ import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.qs.panels.shared.model.EditTileData
import com.android.systemui.qs.pipeline.data.repository.InstalledTilesComponentRepository
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.settings.UserTracker
import javax.inject.Inject
import kotlin.coroutines.CoroutineContext
-import kotlinx.coroutines.flow.map
import kotlinx.coroutines.withContext
@SysUISingleton
@@ -60,6 +60,7 @@ constructor(
Icon.Loaded(icon, ContentDescription.Loaded(label.toString())),
Text.Loaded(label.toString()),
Text.Loaded(appName.toString()),
+ TileCategory.PROVIDED_BY_APP,
)
} else {
null
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractor.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractor.kt
index 3b29422ccfc3..a2cee3b68d49 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/domain/interactor/EditTilesListInteractor.kt
@@ -24,6 +24,7 @@ import com.android.systemui.qs.panels.data.repository.IconAndNameCustomRepositor
import com.android.systemui.qs.panels.data.repository.StockTilesRepository
import com.android.systemui.qs.panels.domain.model.EditTilesModel
import com.android.systemui.qs.panels.shared.model.EditTileData
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tiles.viewmodel.QSTileConfigProvider
import javax.inject.Inject
@@ -53,6 +54,7 @@ constructor(
),
Text.Resource(config.uiConfig.labelRes),
null,
+ category = config.category,
)
} else {
EditTileData(
@@ -62,7 +64,8 @@ constructor(
ContentDescription.Loaded(it.spec)
),
Text.Loaded(it.spec),
- null
+ null,
+ category = TileCategory.UNKNOWN,
)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/shared/model/EditTileData.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/shared/model/EditTileData.kt
index 8b70bb9f9e23..b153ef7e8a62 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/shared/model/EditTileData.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/shared/model/EditTileData.kt
@@ -19,12 +19,14 @@ package com.android.systemui.qs.panels.shared.model
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Text
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
data class EditTileData(
val tileSpec: TileSpec,
val icon: Icon,
val label: Text,
val appName: Text?,
+ val category: TileCategory,
) {
init {
check(
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/Tile.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/Tile.kt
index 24af09d62313..93037d1d2572 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/Tile.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/Tile.kt
@@ -34,6 +34,7 @@ import androidx.compose.animation.graphics.vector.AnimatedImageVector
import androidx.compose.foundation.ExperimentalFoundationApi
import androidx.compose.foundation.Image
import androidx.compose.foundation.LocalOverscrollConfiguration
+import androidx.compose.foundation.background
import androidx.compose.foundation.basicMarquee
import androidx.compose.foundation.border
import androidx.compose.foundation.combinedClickable
@@ -95,6 +96,8 @@ import androidx.compose.ui.text.style.TextAlign
import androidx.compose.ui.text.style.TextOverflow
import androidx.compose.ui.unit.Dp
import androidx.compose.ui.unit.dp
+import androidx.compose.ui.unit.sp
+import androidx.compose.ui.util.fastMap
import androidx.lifecycle.compose.collectAsStateWithLifecycle
import com.android.compose.animation.Expandable
import com.android.compose.modifiers.background
@@ -115,6 +118,7 @@ import com.android.systemui.qs.panels.ui.viewmodel.TileViewModel
import com.android.systemui.qs.panels.ui.viewmodel.toUiState
import com.android.systemui.qs.pipeline.domain.interactor.CurrentTilesInteractor
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.groupAndSort
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.res.R
import java.util.function.Supplier
@@ -472,31 +476,39 @@ private fun AvailableTileGrid(
onClick: (TileSpec) -> Unit,
dragAndDropState: DragAndDropState,
) {
- // Available tiles aren't visible during drag and drop, so the row isn't needed
- val (otherTilesStock, otherTilesCustom) =
- tiles.map { TileGridCell(it, 0) }.partition { it.tile.appName == null }
val availableTileHeight = tileHeight(true)
val availableGridHeight = gridHeight(tiles.size, availableTileHeight, columns, tilePadding)
+ // Available tiles aren't visible during drag and drop, so the row isn't needed
+ val groupedTiles =
+ remember(tiles.fastMap { it.tile.category }, tiles.fastMap { it.tile.label }) {
+ groupAndSort(tiles.fastMap { TileGridCell(it, 0) })
+ }
+ val labelColors = TileDefaults.inactiveTileColors()
// Available tiles
TileLazyGrid(
modifier = Modifier.height(availableGridHeight).testTag(AVAILABLE_TILES_GRID_TEST_TAG),
columns = GridCells.Fixed(columns)
) {
- editTiles(
- otherTilesStock,
- ClickAction.ADD,
- onClick,
- dragAndDropState = dragAndDropState,
- showLabels = true,
- )
- editTiles(
- otherTilesCustom,
- ClickAction.ADD,
- onClick,
- dragAndDropState = dragAndDropState,
- showLabels = true,
- )
+ groupedTiles.forEach { category, tiles ->
+ stickyHeader {
+ Text(
+ text = category.label.load() ?: "",
+ fontSize = 20.sp,
+ color = labelColors.label,
+ modifier =
+ Modifier.background(Color.Black)
+ .padding(start = 16.dp, bottom = 8.dp, top = 8.dp)
+ )
+ }
+ editTiles(
+ tiles,
+ ClickAction.ADD,
+ onClick,
+ dragAndDropState = dragAndDropState,
+ showLabels = true,
+ )
+ }
}
}
@@ -618,7 +630,7 @@ fun EditTile(
showLabels: Boolean,
modifier: Modifier = Modifier,
) {
- val label = tileViewModel.label.load() ?: tileViewModel.tileSpec.spec
+ val label = tileViewModel.label.text
val colors = TileDefaults.inactiveTileColors()
TileContainer(
@@ -638,7 +650,7 @@ fun EditTile(
} else {
LargeTileContent(
label = label,
- secondaryLabel = tileViewModel.appName?.load(),
+ secondaryLabel = tileViewModel.appName?.text,
icon = tileViewModel.icon,
colors = colors,
iconShape = RoundedCornerShape(TileDefaults.InactiveCornerRadius),
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/model/TileGridCell.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/model/TileGridCell.kt
index 8ca8de762772..08ee856a0ec6 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/model/TileGridCell.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/model/TileGridCell.kt
@@ -21,6 +21,7 @@ import androidx.compose.runtime.Immutable
import com.android.systemui.qs.panels.shared.model.SizedTile
import com.android.systemui.qs.panels.shared.model.splitInRowsSequence
import com.android.systemui.qs.panels.ui.viewmodel.EditTileViewModel
+import com.android.systemui.qs.shared.model.CategoryAndName
/** Represents an item from a grid associated with a row and a span */
interface GridCell {
@@ -38,7 +39,7 @@ data class TileGridCell(
override val row: Int,
override val width: Int,
override val span: GridItemSpan = GridItemSpan(width)
-) : GridCell, SizedTile<EditTileViewModel> {
+) : GridCell, SizedTile<EditTileViewModel>, CategoryAndName by tile {
val key: String = "${tile.tileSpec.spec}-$row"
constructor(
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModel.kt
index 42715be6f6c0..4a8aa83e7d4e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModel.kt
@@ -16,6 +16,9 @@
package com.android.systemui.qs.panels.ui.viewmodel
+import android.content.Context
+import androidx.compose.ui.util.fastMap
+import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.qs.panels.domain.interactor.EditTilesListInteractor
@@ -27,6 +30,7 @@ import com.android.systemui.qs.pipeline.domain.interactor.CurrentTilesInteractor
import com.android.systemui.qs.pipeline.domain.interactor.CurrentTilesInteractor.Companion.POSITION_AT_END
import com.android.systemui.qs.pipeline.domain.interactor.MinimumTilesInteractor
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.util.kotlin.emitOnStart
import javax.inject.Inject
import javax.inject.Named
import kotlinx.coroutines.CoroutineScope
@@ -35,6 +39,7 @@ import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.asStateFlow
+import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.emptyFlow
import kotlinx.coroutines.flow.flatMapLatest
import kotlinx.coroutines.flow.map
@@ -49,6 +54,8 @@ constructor(
private val currentTilesInteractor: CurrentTilesInteractor,
private val tilesAvailabilityInteractor: TilesAvailabilityInteractor,
private val minTilesInteractor: MinimumTilesInteractor,
+ private val configurationInteractor: ConfigurationInteractor,
+ @Application private val applicationContext: Context,
@Named("Default") private val defaultGridLayout: GridLayout,
@Application private val applicationScope: CoroutineScope,
gridLayoutTypeInteractor: GridLayoutTypeInteractor,
@@ -99,38 +106,45 @@ constructor(
.map { it.tileSpec }
.minus(currentTilesInteractor.currentTilesSpecs.toSet())
)
- currentTilesInteractor.currentTiles.map { tiles ->
- val currentSpecs = tiles.map { it.spec }
- val canRemoveTiles = currentSpecs.size > minimumTiles
- val allTiles = editTilesData.stockTiles + editTilesData.customTiles
- val allTilesMap = allTiles.associate { it.tileSpec to it }
- val currentTiles = currentSpecs.map { allTilesMap.get(it) }.filterNotNull()
- val nonCurrentTiles = allTiles.filter { it.tileSpec !in currentSpecs }
-
- (currentTiles + nonCurrentTiles)
- .filterNot { it.tileSpec in unavailable }
- .map {
- val current = it.tileSpec in currentSpecs
- val availableActions = buildSet {
- if (current) {
- add(AvailableEditActions.MOVE)
- if (canRemoveTiles) {
- add(AvailableEditActions.REMOVE)
+ currentTilesInteractor.currentTiles
+ .map { tiles ->
+ val currentSpecs = tiles.map { it.spec }
+ val canRemoveTiles = currentSpecs.size > minimumTiles
+ val allTiles = editTilesData.stockTiles + editTilesData.customTiles
+ val allTilesMap = allTiles.associate { it.tileSpec to it }
+ val currentTiles = currentSpecs.map { allTilesMap.get(it) }.filterNotNull()
+ val nonCurrentTiles = allTiles.filter { it.tileSpec !in currentSpecs }
+
+ (currentTiles + nonCurrentTiles)
+ .filterNot { it.tileSpec in unavailable }
+ .map {
+ val current = it.tileSpec in currentSpecs
+ val availableActions = buildSet {
+ if (current) {
+ add(AvailableEditActions.MOVE)
+ if (canRemoveTiles) {
+ add(AvailableEditActions.REMOVE)
+ }
+ } else {
+ add(AvailableEditActions.ADD)
}
- } else {
- add(AvailableEditActions.ADD)
}
+ UnloadedEditTileViewModel(
+ it.tileSpec,
+ it.icon,
+ it.label,
+ it.appName,
+ current,
+ availableActions,
+ it.category,
+ )
}
- EditTileViewModel(
- it.tileSpec,
- it.icon,
- it.label,
- it.appName,
- current,
- availableActions
- )
- }
- }
+ }
+ .combine(configurationInteractor.onAnyConfigurationChange.emitOnStart()) {
+ tiles,
+ _ ->
+ tiles.fastMap { it.load(applicationContext) }
+ }
} else {
emptyFlow()
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/EditTileViewModel.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/EditTileViewModel.kt
index a4c86381b785..ee12736f6db4 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/EditTileViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/viewmodel/EditTileViewModel.kt
@@ -16,9 +16,15 @@
package com.android.systemui.qs.panels.ui.viewmodel
+import android.content.Context
+import androidx.compose.runtime.Immutable
+import androidx.compose.ui.text.AnnotatedString
import com.android.systemui.common.shared.model.Icon
import com.android.systemui.common.shared.model.Text
+import com.android.systemui.common.ui.compose.toAnnotatedString
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.CategoryAndName
+import com.android.systemui.qs.shared.model.TileCategory
/**
* View model for each tile that is available to be added/removed/moved in Edit mode.
@@ -26,14 +32,41 @@ import com.android.systemui.qs.pipeline.shared.TileSpec
* [isCurrent] indicates whether this tile is part of the current set of tiles that the user sees in
* Quick Settings.
*/
-data class EditTileViewModel(
+data class UnloadedEditTileViewModel(
val tileSpec: TileSpec,
val icon: Icon,
val label: Text,
val appName: Text?,
val isCurrent: Boolean,
val availableEditActions: Set<AvailableEditActions>,
-)
+ val category: TileCategory,
+) {
+ fun load(context: Context): EditTileViewModel {
+ return EditTileViewModel(
+ tileSpec,
+ icon,
+ label.toAnnotatedString(context) ?: AnnotatedString(tileSpec.spec),
+ appName?.toAnnotatedString(context),
+ isCurrent,
+ availableEditActions,
+ category,
+ )
+ }
+}
+
+@Immutable
+data class EditTileViewModel(
+ val tileSpec: TileSpec,
+ val icon: Icon,
+ val label: AnnotatedString,
+ val appName: AnnotatedString?,
+ val isCurrent: Boolean,
+ val availableEditActions: Set<AvailableEditActions>,
+ override val category: TileCategory,
+) : CategoryAndName {
+ override val name
+ get() = label.text
+}
enum class AvailableEditActions {
ADD,
diff --git a/packages/SystemUI/src/com/android/systemui/qs/pipeline/dagger/QSTileListLog.kt b/packages/SystemUI/src/com/android/systemui/qs/pipeline/dagger/QSTileListLog.kt
index c56ca8c27a1f..d50374b3c24c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/pipeline/dagger/QSTileListLog.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/pipeline/dagger/QSTileListLog.kt
@@ -15,9 +15,7 @@
*/
package com.android.systemui.qs.pipeline.dagger
-import java.lang.annotation.Retention
-import java.lang.annotation.RetentionPolicy
import javax.inject.Qualifier
/** A [LogBuffer] for the new QS Pipeline for logging changes to the set of current tiles. */
-@Qualifier @MustBeDocumented @Retention(RetentionPolicy.RUNTIME) annotation class QSTileListLog
+@Qualifier @MustBeDocumented @Retention(AnnotationRetention.RUNTIME) annotation class QSTileListLog
diff --git a/packages/SystemUI/src/com/android/systemui/qs/shared/model/TileCategory.kt b/packages/SystemUI/src/com/android/systemui/qs/shared/model/TileCategory.kt
new file mode 100644
index 000000000000..59cb7d3d5345
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/qs/shared/model/TileCategory.kt
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2024 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.qs.shared.model
+
+import com.android.systemui.common.shared.model.Text
+import com.android.systemui.res.R
+
+/** Categories for tiles. This can be used to sort tiles in edit mode. */
+enum class TileCategory(val label: Text) {
+ CONNECTIVITY(Text.Resource(R.string.qs_edit_mode_category_connectivity)),
+ UTILITIES(Text.Resource(R.string.qs_edit_mode_category_utilities)),
+ DISPLAY(Text.Resource(R.string.qs_edit_mode_category_display)),
+ PRIVACY(Text.Resource(R.string.qs_edit_mode_category_privacy)),
+ ACCESSIBILITY(Text.Resource(R.string.qs_edit_mode_category_accessibility)),
+ PROVIDED_BY_APP(Text.Resource(R.string.qs_edit_mode_category_providedByApps)),
+ UNKNOWN(Text.Resource(R.string.qs_edit_mode_category_unknown)),
+}
+
+interface CategoryAndName {
+ val category: TileCategory
+ val name: String
+}
+
+/**
+ * Groups the elements of the list by [CategoryAndName.category] (with the keys sorted in the
+ * natural order of [TileCategory]), and sorts the elements of each group based on the
+ * [CategoryAndName.name].
+ */
+fun <T : CategoryAndName> groupAndSort(list: List<T>): Map<TileCategory, List<T>> {
+ val groupedByCategory = list.groupBy { it.category }.toSortedMap()
+ return groupedByCategory.mapValues { it.value.sortedBy { it.name } }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfig.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfig.kt
index cdcefdb50b0f..3a9cb170040c 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfig.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfig.kt
@@ -21,6 +21,7 @@ import androidx.annotation.DrawableRes
import androidx.annotation.StringRes
import com.android.internal.logging.InstanceId
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
data class QSTileConfig
@JvmOverloads
@@ -28,6 +29,7 @@ constructor(
val tileSpec: TileSpec,
val uiConfig: QSTileUIConfig,
val instanceId: InstanceId,
+ val category: TileCategory,
val metricsSpec: String = tileSpec.spec,
val policy: QSTilePolicy = QSTilePolicy.NoRestrictions,
val autoRemoveOnUnavailable: Boolean = true,
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProvider.kt b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProvider.kt
index 0609e797d53b..4dbddd91092a 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProvider.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigProvider.kt
@@ -20,6 +20,7 @@ import com.android.internal.util.Preconditions
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import javax.inject.Inject
interface QSTileConfigProvider {
@@ -73,6 +74,7 @@ constructor(
spec,
QSTileUIConfig.Empty,
qsEventLogger.getNewInstanceId(),
+ category = TileCategory.PROVIDED_BY_APP,
)
is TileSpec.Invalid ->
throw IllegalArgumentException("TileSpec.Invalid doesn't support configs")
diff --git a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
index 000781acec58..a402a9d5ae7c 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/OverviewProxyService.java
@@ -25,7 +25,6 @@ import static android.view.MotionEvent.ACTION_DOWN;
import static android.view.MotionEvent.ACTION_UP;
import static android.view.WindowManagerPolicyConstants.NAV_BAR_MODE_3BUTTON;
-import static com.android.internal.accessibility.common.ShortcutConstants.CHOOSER_PACKAGE_NAME;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_SYSUI_PROXY;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_UNFOLD_ANIMATION_FORWARDER;
import static com.android.systemui.shared.system.QuickStepContract.KEY_EXTRA_UNLOCK_ANIMATION_CONTROLLER;
@@ -76,7 +75,6 @@ import android.view.inputmethod.InputMethodManager;
import androidx.annotation.NonNull;
-import com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.AssistUtils;
import com.android.internal.app.IVoiceInteractionSessionListener;
@@ -404,23 +402,16 @@ public class OverviewProxyService implements CallbackController<OverviewProxyLis
@Override
public void notifyAccessibilityButtonClicked(int displayId) {
verifyCallerAndClearCallingIdentity("notifyAccessibilityButtonClicked", () ->
- AccessibilityManager.getInstance(mContext)
- .notifyAccessibilityButtonClicked(displayId));
+ AccessibilityManager.getInstance(mContext).notifyAccessibilityButtonClicked(
+ displayId));
}
@Override
public void notifyAccessibilityButtonLongClicked() {
- verifyCallerAndClearCallingIdentity("notifyAccessibilityButtonLongClicked",
- () -> {
- final Intent intent =
- new Intent(AccessibilityManager.ACTION_CHOOSE_ACCESSIBILITY_BUTTON);
- final String chooserClassName = AccessibilityButtonChooserActivity
- .class.getName();
- intent.setClassName(CHOOSER_PACKAGE_NAME, chooserClassName);
- intent.addFlags(
- Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
- mContext.startActivityAsUser(intent, mUserTracker.getUserHandle());
- });
+ verifyCallerAndClearCallingIdentity("notifyAccessibilityButtonLongClicked", () ->
+ AccessibilityManager.getInstance(mContext)
+ .notifyAccessibilityButtonLongClicked(
+ mDisplayTracker.getDefaultDisplayId()));
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueModule.kt b/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueModule.kt
index 907b92ce4c9b..c092c2f86799 100644
--- a/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/recordissue/RecordIssueModule.kt
@@ -19,6 +19,7 @@ package com.android.systemui.recordissue
import com.android.systemui.Flags
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.qs.tiles.RecordIssueTile
import com.android.systemui.qs.tiles.base.viewmodel.QSTileViewModelFactory
@@ -61,6 +62,7 @@ interface RecordIssueModule {
labelRes = R.string.qs_record_issue_label
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.UTILITIES,
)
/** Inject FlashlightTile into tileViewModelMap in QSModule */
diff --git a/packages/SystemUI/src/com/android/systemui/rotationlock/RotationLockNewModule.kt b/packages/SystemUI/src/com/android/systemui/rotationlock/RotationLockNewModule.kt
index 0589e6c63931..c9712fcdaa27 100644
--- a/packages/SystemUI/src/com/android/systemui/rotationlock/RotationLockNewModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/rotationlock/RotationLockNewModule.kt
@@ -19,6 +19,7 @@ package com.android.systemui.rotationlock
import com.android.systemui.camera.CameraRotationModule
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tiles.base.interactor.QSTileAvailabilityInteractor
import com.android.systemui.qs.tiles.base.viewmodel.QSTileViewModelFactory
import com.android.systemui.qs.tiles.impl.rotation.domain.interactor.RotationLockTileDataInteractor
@@ -42,8 +43,9 @@ interface RotationLockNewModule {
@IntoMap
@StringKey(ROTATION_TILE_SPEC)
fun provideRotationAvailabilityInteractor(
- impl: RotationLockTileDataInteractor
+ impl: RotationLockTileDataInteractor
): QSTileAvailabilityInteractor
+
companion object {
private const val ROTATION_TILE_SPEC = "rotation"
@@ -60,6 +62,7 @@ interface RotationLockNewModule {
labelRes = R.string.quick_settings_rotation_unlocked_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.DISPLAY,
)
/** Inject Rotation tile into tileViewModelMap in QSModule */
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt
index 738b18495f3f..e477efe0808e 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/domain/interactor/WindowRootViewVisibilityInteractor.kt
@@ -25,6 +25,7 @@ import com.android.systemui.keyguard.shared.model.StatusBarState
import com.android.systemui.power.domain.interactor.PowerInteractor
import com.android.systemui.scene.data.repository.WindowRootViewVisibilityRepository
import com.android.systemui.scene.shared.flag.SceneContainerFlag
+import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.statusbar.NotificationPresenter
import com.android.systemui.statusbar.notification.domain.interactor.ActiveNotificationsInteractor
@@ -34,6 +35,7 @@ import com.android.systemui.statusbar.policy.HeadsUpManager
import javax.inject.Inject
import javax.inject.Provider
import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.combine
@@ -45,6 +47,7 @@ import kotlinx.coroutines.flow.stateIn
import kotlinx.coroutines.launch
/** Business logic about the visibility of various parts of the window root view. */
+@OptIn(ExperimentalCoroutinesApi::class)
@SysUISingleton
class WindowRootViewVisibilityInteractor
@Inject
@@ -80,9 +83,9 @@ constructor(
is ObservableTransitionState.Idle ->
flowOf(
state.currentScene == Scenes.Shade ||
- state.currentScene == Scenes.NotificationsShade ||
- state.currentScene == Scenes.QuickSettingsShade ||
- state.currentScene == Scenes.Lockscreen
+ state.currentScene == Scenes.Lockscreen ||
+ Overlays.NotificationsShade in state.currentOverlays ||
+ Overlays.QuickSettingsShade in state.currentOverlays
)
is ObservableTransitionState.Transition ->
if (
@@ -94,12 +97,12 @@ constructor(
} else {
flowOf(
state.toContent == Scenes.Shade ||
- state.toContent == Scenes.NotificationsShade ||
- state.toContent == Scenes.QuickSettingsShade ||
+ state.toContent == Overlays.NotificationsShade ||
+ state.toContent == Overlays.QuickSettingsShade ||
state.toContent == Scenes.Lockscreen ||
state.fromContent == Scenes.Shade ||
- state.fromContent == Scenes.NotificationsShade ||
- state.fromContent == Scenes.QuickSettingsShade ||
+ state.fromContent == Overlays.NotificationsShade ||
+ state.fromContent == Overlays.QuickSettingsShade ||
state.fromContent == Scenes.Lockscreen
)
}
@@ -115,10 +118,9 @@ constructor(
* false if the device is asleep.
*/
val isLockscreenOrShadeVisibleAndInteractive: StateFlow<Boolean> =
- combine(
- isLockscreenOrShadeVisible,
- powerInteractor.isAwake,
- ) { isKeyguardAodOrShadeVisible, isAwake ->
+ combine(isLockscreenOrShadeVisible, powerInteractor.isAwake) {
+ isKeyguardAodOrShadeVisible,
+ isAwake ->
isKeyguardAodOrShadeVisible && isAwake
}
.stateIn(scope, SharingStarted.Eagerly, initialValue = false)
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/resolver/NotifShadeSceneFamilyResolver.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/resolver/NotifShadeSceneFamilyResolver.kt
index 99e554ea5595..a3132736fe33 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/domain/resolver/NotifShadeSceneFamilyResolver.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/domain/resolver/NotifShadeSceneFamilyResolver.kt
@@ -21,7 +21,7 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.scene.shared.model.SceneFamilies
import com.android.systemui.scene.shared.model.Scenes
-import com.android.systemui.shade.domain.interactor.ShadeInteractor
+import com.android.systemui.shade.domain.interactor.ShadeModeInteractor
import com.android.systemui.shade.shared.model.ShadeMode
import dagger.Binds
import dagger.Module
@@ -38,17 +38,17 @@ class NotifShadeSceneFamilyResolver
@Inject
constructor(
@Application applicationScope: CoroutineScope,
- shadeInteractor: ShadeInteractor,
+ shadeModeInteractor: ShadeModeInteractor,
) : SceneResolver {
override val targetFamily: SceneKey = SceneFamilies.NotifShade
override val resolvedScene: StateFlow<SceneKey> =
- shadeInteractor.shadeMode
+ shadeModeInteractor.shadeMode
.map(::notifShadeScene)
.stateIn(
applicationScope,
started = SharingStarted.Eagerly,
- initialValue = notifShadeScene(shadeInteractor.shadeMode.value),
+ initialValue = notifShadeScene(shadeModeInteractor.shadeMode.value),
)
override fun includesScene(scene: SceneKey): Boolean = scene in notifShadeScenes
@@ -61,11 +61,7 @@ constructor(
}
companion object {
- val notifShadeScenes =
- setOf(
- Scenes.NotificationsShade,
- Scenes.Shade,
- )
+ val notifShadeScenes = setOf(Scenes.NotificationsShade, Scenes.Shade)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/resolver/QuickSettingsSceneFamilyResolver.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/resolver/QuickSettingsSceneFamilyResolver.kt
index 2962a3ec903d..923e712af15d 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/domain/resolver/QuickSettingsSceneFamilyResolver.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/domain/resolver/QuickSettingsSceneFamilyResolver.kt
@@ -21,7 +21,7 @@ import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.scene.shared.model.SceneFamilies
import com.android.systemui.scene.shared.model.Scenes
-import com.android.systemui.shade.domain.interactor.ShadeInteractor
+import com.android.systemui.shade.domain.interactor.ShadeModeInteractor
import com.android.systemui.shade.shared.model.ShadeMode
import dagger.Binds
import dagger.Module
@@ -38,17 +38,17 @@ class QuickSettingsSceneFamilyResolver
@Inject
constructor(
@Application applicationScope: CoroutineScope,
- shadeInteractor: ShadeInteractor,
+ shadeModeInteractor: ShadeModeInteractor,
) : SceneResolver {
override val targetFamily: SceneKey = SceneFamilies.QuickSettings
override val resolvedScene: StateFlow<SceneKey> =
- shadeInteractor.shadeMode
+ shadeModeInteractor.shadeMode
.map(::quickSettingsScene)
.stateIn(
applicationScope,
started = SharingStarted.Eagerly,
- initialValue = quickSettingsScene(shadeInteractor.shadeMode.value),
+ initialValue = quickSettingsScene(shadeModeInteractor.shadeMode.value),
)
override fun includesScene(scene: SceneKey): Boolean = scene in quickSettingsScenes
@@ -62,11 +62,7 @@ constructor(
companion object {
val quickSettingsScenes =
- setOf(
- Scenes.QuickSettings,
- Scenes.QuickSettingsShade,
- Scenes.Shade,
- )
+ setOf(Scenes.QuickSettings, Scenes.QuickSettingsShade, Scenes.Shade)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt
index d1629c799732..e352bfe938f6 100644
--- a/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/scene/domain/startable/ScrimStartable.kt
@@ -19,7 +19,9 @@
package com.android.systemui.scene.domain.startable
import androidx.annotation.VisibleForTesting
+import com.android.compose.animation.scene.ContentKey
import com.android.compose.animation.scene.ObservableTransitionState
+import com.android.compose.animation.scene.OverlayKey
import com.android.compose.animation.scene.SceneKey
import com.android.systemui.CoreStartable
import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
@@ -33,6 +35,7 @@ import com.android.systemui.keyguard.shared.model.BiometricUnlockModel
import com.android.systemui.scene.domain.interactor.SceneContainerOcclusionInteractor
import com.android.systemui.scene.domain.interactor.SceneInteractor
import com.android.systemui.scene.shared.flag.SceneContainerFlag
+import com.android.systemui.scene.shared.model.Overlays
import com.android.systemui.scene.shared.model.Scenes
import com.android.systemui.settings.brightness.domain.interactor.BrightnessMirrorShowingInteractor
import com.android.systemui.statusbar.phone.DozeServiceHost
@@ -74,6 +77,7 @@ constructor(
deviceEntryInteractor.isDeviceEntered,
occlusionInteractor.invisibleDueToOcclusion,
sceneInteractor.currentScene,
+ sceneInteractor.currentOverlays,
sceneInteractor.transitionState,
keyguardInteractor.isDozing,
keyguardInteractor.isDreaming,
@@ -95,34 +99,29 @@ constructor(
val isDeviceEntered = flowValues[0] as Boolean
val isOccluded = flowValues[1] as Boolean
val currentScene = flowValues[2] as SceneKey
- val transitionState = flowValues[3] as ObservableTransitionState
- val isDozing = flowValues[4] as Boolean
- val isDreaming = flowValues[5] as Boolean
- val biometricUnlockState = flowValues[6] as BiometricUnlockModel
- val isBrightnessMirrorVisible = flowValues[7] as Boolean
- val isPulsing = flowValues[8] as Boolean
- val hasPendingScreenOffCallback = flowValues[9] as Boolean
+ val currentOverlays = flowValues[3] as Set<OverlayKey>
+ val transitionState = flowValues[4] as ObservableTransitionState
+ val isDozing = flowValues[5] as Boolean
+ val isDreaming = flowValues[6] as Boolean
+ val biometricUnlockState = flowValues[7] as BiometricUnlockModel
+ val isBrightnessMirrorVisible = flowValues[8] as Boolean
+ val isPulsing = flowValues[9] as Boolean
+ val hasPendingScreenOffCallback = flowValues[10] as Boolean
// This is true when the lockscreen scene is either the current scene or somewhere
- // in the
- // navigation back stack of scenes.
+ // in the navigation back stack of scenes.
val isOnKeyguard = !isDeviceEntered
val isCurrentSceneBouncer = currentScene == Scenes.Bouncer
// This is true when moving away from one of the keyguard scenes to the gone scene.
- // It
- // happens only when unlocking or when dismissing a dismissible lockscreen.
+ // It happens only when unlocking or when dismissing a dismissible lockscreen.
val isTransitioningAwayFromKeyguard =
transitionState is ObservableTransitionState.Transition.ChangeScene &&
transitionState.fromScene.isKeyguard() &&
transitionState.toScene == Scenes.Gone
- // This is true when any of the shade scenes is the current scene.
- val isCurrentSceneShade = currentScene.isShade()
- // This is true when moving into one of the shade scenes when a non-shade scene.
- val isTransitioningToShade =
- transitionState is ObservableTransitionState.Transition.ChangeScene &&
- !transitionState.fromScene.isShade() &&
- transitionState.toScene.isShade()
+ // This is true when any of the shade scenes or overlays is the current content.
+ val isCurrentContentShade =
+ currentScene.isShade() || currentOverlays.any { it.isShade() }
// This is true after completing a transition to communal.
val isIdleOnCommunal = transitionState.isIdle(Scenes.Communal)
@@ -137,10 +136,10 @@ constructor(
if (alternateBouncerInteractor.isVisibleState()) {
// This will cancel the keyguardFadingAway animation if it is running. We need
- // to do
- // this as otherwise it can remain pending and leave keyguard in a weird state.
+ // to do this as otherwise it can remain pending and leave keyguard in a weird
+ // state.
onKeyguardFadedAway(isTransitioningAwayFromKeyguard)
- if (!isTransitioningToShade) {
+ if (!transitionState.isTransitioningToShade()) {
// Safeguard which prevents the scrim from being stuck in the wrong
// state
Model(scrimState = ScrimState.KEYGUARD, unlocking = unlocking)
@@ -163,7 +162,7 @@ constructor(
)
} else if (isBrightnessMirrorVisible) {
Model(scrimState = ScrimState.BRIGHTNESS_MIRROR, unlocking = unlocking)
- } else if (isCurrentSceneShade && !isDeviceEntered) {
+ } else if (isCurrentContentShade && !isDeviceEntered) {
Model(scrimState = ScrimState.SHADE_LOCKED, unlocking = unlocking)
} else if (isPulsing) {
Model(scrimState = ScrimState.PULSING, unlocking = unlocking)
@@ -171,8 +170,8 @@ constructor(
Model(scrimState = ScrimState.OFF, unlocking = unlocking)
} else if (isDozing && !unlocking) {
// This will cancel the keyguardFadingAway animation if it is running. We need
- // to do
- // this as otherwise it can remain pending and leave keyguard in a weird state.
+ // to do this as otherwise it can remain pending and leave keyguard in a weird
+ // state.
onKeyguardFadedAway(isTransitioningAwayFromKeyguard)
Model(scrimState = ScrimState.AOD, unlocking = false)
} else if (isIdleOnCommunal) {
@@ -222,15 +221,24 @@ constructor(
return this == Scenes.Lockscreen || this == Scenes.Bouncer
}
- private fun SceneKey.isShade(): Boolean {
+ private fun ContentKey.isShade(): Boolean {
return this == Scenes.Shade ||
this == Scenes.QuickSettings ||
- this == Scenes.NotificationsShade ||
- this == Scenes.QuickSettingsShade
+ this == Overlays.NotificationsShade ||
+ this == Overlays.QuickSettingsShade
+ }
+
+ private fun ObservableTransitionState.isTransitioningToShade(): Boolean {
+ return when (this) {
+ is ObservableTransitionState.Idle -> false
+ is ObservableTransitionState.Transition.ChangeScene ->
+ !fromScene.isShade() && toScene.isShade()
+ is ObservableTransitionState.Transition.ReplaceOverlay ->
+ !fromOverlay.isShade() && toOverlay.isShade()
+ is ObservableTransitionState.Transition.ShowOrHideOverlay ->
+ !fromContent.isShade() && toContent.isShade()
+ }
}
- private data class Model(
- val scrimState: ScrimState,
- val unlocking: Boolean,
- )
+ private data class Model(val scrimState: ScrimState, val unlocking: Boolean)
}
diff --git a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordModule.kt b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordModule.kt
index a830e1bbfe72..9a9c576c5af6 100644
--- a/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/screenrecord/ScreenRecordModule.kt
@@ -21,6 +21,7 @@ import com.android.systemui.log.LogBuffer
import com.android.systemui.log.LogBufferFactory
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.qs.tiles.ScreenRecordTile
import com.android.systemui.qs.tiles.base.interactor.QSTileAvailabilityInteractor
@@ -74,6 +75,7 @@ interface ScreenRecordModule {
labelRes = R.string.quick_settings_screen_record_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.DISPLAY,
)
/** Inject ScreenRecord Tile into tileViewModelMap in QSModule */
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/LegacyScreenshotController.java b/packages/SystemUI/src/com/android/systemui/screenshot/LegacyScreenshotController.java
index a77375c14f26..f69b0cb630d3 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/LegacyScreenshotController.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/LegacyScreenshotController.java
@@ -19,7 +19,6 @@ package com.android.systemui.screenshot;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
import static android.view.WindowManager.LayoutParams.TYPE_SCREENSHOT;
-import static com.android.systemui.Flags.screenshotSaveImageExporter;
import static com.android.systemui.screenshot.LogConfig.DEBUG_ANIM;
import static com.android.systemui.screenshot.LogConfig.DEBUG_CALLBACK;
import static com.android.systemui.screenshot.LogConfig.DEBUG_INPUT;
@@ -133,7 +132,6 @@ public class LegacyScreenshotController implements InteractiveScreenshotHandler
private final MessageContainerController mMessageContainerController;
private final AnnouncementResolver mAnnouncementResolver;
private Bitmap mScreenBitmap;
- private SaveImageInBackgroundTask mSaveInBgTask;
private boolean mScreenshotTakenInPortrait;
private boolean mAttachRequested;
private boolean mDetachRequested;
@@ -393,10 +391,6 @@ public class LegacyScreenshotController implements InteractiveScreenshotHandler
// Any cleanup needed when the service is being destroyed.
@Override
public void onDestroy() {
- if (mSaveInBgTask != null) {
- // just log success/failure for the pre-existing screenshot
- mSaveInBgTask.setActionsReadyListener(this::logSuccessOnActionsReady);
- }
removeWindow();
releaseMediaPlayer();
releaseContext();
@@ -598,36 +592,12 @@ public class LegacyScreenshotController implements InteractiveScreenshotHandler
// Play the shutter sound to notify that we've taken a screenshot
playCameraSoundIfNeeded();
- if (screenshotSaveImageExporter()) {
- saveScreenshotInBackground(screenshot, UUID.randomUUID(), finisher, result -> {
- if (result.uri != null) {
- mScreenshotHandler.post(() -> Toast.makeText(mContext,
- R.string.screenshot_saved_title, Toast.LENGTH_SHORT).show());
- }
- });
- } else {
- saveScreenshotInWorkerThread(
- screenshot.getUserHandle(),
- /* onComplete */ finisher,
- /* actionsReadyListener */ imageData -> {
- if (DEBUG_CALLBACK) {
- Log.d(TAG,
- "returning URI to finisher (Consumer<URI>): " + imageData.uri);
- }
- finisher.accept(imageData.uri);
- if (imageData.uri == null) {
- mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_NOT_SAVED, 0,
- mPackageName);
- mNotificationsController.notifyScreenshotError(
- R.string.screenshot_failed_to_save_text);
- } else {
- mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_SAVED, 0, mPackageName);
- mScreenshotHandler.post(() -> Toast.makeText(mContext,
- R.string.screenshot_saved_title, Toast.LENGTH_SHORT).show());
- }
- },
- null);
- }
+ saveScreenshotInBackground(screenshot, UUID.randomUUID(), finisher, result -> {
+ if (result.uri != null) {
+ mScreenshotHandler.post(() -> Toast.makeText(mContext,
+ R.string.screenshot_saved_title, Toast.LENGTH_SHORT).show());
+ }
+ });
}
/**
@@ -700,35 +670,6 @@ public class LegacyScreenshotController implements InteractiveScreenshotHandler
}
/**
- * Creates a new worker thread and saves the screenshot to the media store.
- */
- private void saveScreenshotInWorkerThread(
- UserHandle owner,
- @NonNull Consumer<Uri> finisher,
- @Nullable SaveImageInBackgroundTask.ActionsReadyListener actionsReadyListener,
- @Nullable SaveImageInBackgroundTask.QuickShareActionReadyListener
- quickShareActionsReadyListener) {
- SaveImageInBackgroundTask.SaveImageInBackgroundData
- data = new SaveImageInBackgroundTask.SaveImageInBackgroundData();
- data.image = mScreenBitmap;
- data.finisher = finisher;
- data.mActionsReadyListener = actionsReadyListener;
- data.mQuickShareActionsReadyListener = quickShareActionsReadyListener;
- data.owner = owner;
- data.displayId = mDisplay.getDisplayId();
-
- if (mSaveInBgTask != null) {
- // just log success/failure for the pre-existing screenshot
- mSaveInBgTask.setActionsReadyListener(this::logSuccessOnActionsReady);
- }
-
- mSaveInBgTask = new SaveImageInBackgroundTask(mContext, mFlags, mImageExporter,
- mScreenshotSmartActions, data,
- mScreenshotNotificationSmartActionsProvider);
- mSaveInBgTask.execute();
- }
-
- /**
* Logs success/failure of the screenshot saving task, and shows an error if it failed.
*/
private void logScreenshotResultStatus(Uri uri, UserHandle owner) {
@@ -745,13 +686,6 @@ public class LegacyScreenshotController implements InteractiveScreenshotHandler
}
}
- /**
- * Logs success/failure of the screenshot saving task, and shows an error if it failed.
- */
- private void logSuccessOnActionsReady(SaveImageInBackgroundTask.SavedImageData imageData) {
- logScreenshotResultStatus(imageData.uri, imageData.owner);
- }
-
private boolean isUserSetupComplete(UserHandle owner) {
return Settings.Secure.getInt(mContext.createContextAsUser(owner, 0)
.getContentResolver(), SETTINGS_SECURE_USER_SETUP_COMPLETE, 0) == 1;
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/SaveImageInBackgroundTask.java b/packages/SystemUI/src/com/android/systemui/screenshot/SaveImageInBackgroundTask.java
deleted file mode 100644
index 9bc3bd842664..000000000000
--- a/packages/SystemUI/src/com/android/systemui/screenshot/SaveImageInBackgroundTask.java
+++ /dev/null
@@ -1,399 +0,0 @@
-/*
- * Copyright (C) 2019 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.screenshot;
-
-import static com.android.systemui.screenshot.LogConfig.DEBUG_CALLBACK;
-import static com.android.systemui.screenshot.LogConfig.DEBUG_STORAGE;
-import static com.android.systemui.screenshot.LogConfig.logTag;
-import static com.android.systemui.screenshot.ScreenshotNotificationSmartActionsProvider.ScreenshotSmartActionType;
-
-import android.app.Notification;
-import android.app.PendingIntent;
-import android.content.ClipData;
-import android.content.ClipDescription;
-import android.content.Context;
-import android.content.Intent;
-import android.graphics.Bitmap;
-import android.net.Uri;
-import android.os.AsyncTask;
-import android.os.Bundle;
-import android.os.Process;
-import android.os.UserHandle;
-import android.provider.DeviceConfig;
-import android.util.Log;
-
-import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.config.sysui.SystemUiDeviceConfigFlags;
-import com.android.systemui.flags.FeatureFlags;
-
-import com.google.common.util.concurrent.ListenableFuture;
-
-import java.text.DateFormat;
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Random;
-import java.util.UUID;
-import java.util.concurrent.CompletableFuture;
-import java.util.function.Consumer;
-
-/**
- * An AsyncTask that saves an image to the media store in the background.
- */
-class SaveImageInBackgroundTask extends AsyncTask<Void, Void, Void> {
- private static final String TAG = logTag(SaveImageInBackgroundTask.class);
-
- private static final String SCREENSHOT_ID_TEMPLATE = "Screenshot_%s";
- private static final String SCREENSHOT_SHARE_SUBJECT_TEMPLATE = "Screenshot (%s)";
-
- /**
- * POD used in the AsyncTask which saves an image in the background.
- */
- static class SaveImageInBackgroundData {
- public Bitmap image;
- public Consumer<Uri> finisher;
- public ActionsReadyListener mActionsReadyListener;
- public QuickShareActionReadyListener mQuickShareActionsReadyListener;
- public UserHandle owner;
- public int displayId;
-
- void clearImage() {
- image = null;
- }
- }
-
- /**
- * Structure returned by the SaveImageInBackgroundTask
- */
- public static class SavedImageData {
- public Uri uri;
- public List<Notification.Action> smartActions;
- public Notification.Action quickShareAction;
- public UserHandle owner;
- public String subject; // Title for sharing
- public Long imageTime; // Time at which screenshot was saved
-
- /**
- * Used to reset the return data on error
- */
- public void reset() {
- uri = null;
- smartActions = null;
- quickShareAction = null;
- subject = null;
- imageTime = null;
- }
- }
-
- /**
- * Structure returned by the QueryQuickShareInBackgroundTask
- */
- static class QuickShareData {
- public Notification.Action quickShareAction;
-
- /**
- * Used to reset the return data on error
- */
- public void reset() {
- quickShareAction = null;
- }
- }
-
- interface ActionsReadyListener {
- void onActionsReady(SavedImageData imageData);
- }
-
- interface QuickShareActionReadyListener {
- void onActionsReady(QuickShareData quickShareData);
- }
-
- private final Context mContext;
- private FeatureFlags mFlags;
- private final ScreenshotSmartActions mScreenshotSmartActions;
- private final SaveImageInBackgroundData mParams;
- private final SavedImageData mImageData;
- private final QuickShareData mQuickShareData;
-
- private final ScreenshotNotificationSmartActionsProvider mSmartActionsProvider;
- private String mScreenshotId;
- private final Random mRandom = new Random();
- private final ImageExporter mImageExporter;
- private long mImageTime;
-
- SaveImageInBackgroundTask(
- Context context,
- FeatureFlags flags,
- ImageExporter exporter,
- ScreenshotSmartActions screenshotSmartActions,
- SaveImageInBackgroundData data,
- ScreenshotNotificationSmartActionsProvider
- screenshotNotificationSmartActionsProvider
- ) {
- mContext = context;
- mFlags = flags;
- mScreenshotSmartActions = screenshotSmartActions;
- mImageData = new SavedImageData();
- mQuickShareData = new QuickShareData();
- mImageExporter = exporter;
-
- // Prepare all the output metadata
- mParams = data;
-
- // Initialize screenshot notification smart actions provider.
- mSmartActionsProvider = screenshotNotificationSmartActionsProvider;
- }
-
- @Override
- protected Void doInBackground(Void... paramsUnused) {
- if (isCancelled()) {
- if (DEBUG_STORAGE) {
- Log.d(TAG, "cancelled! returning null");
- }
- return null;
- }
- // TODO: move to constructor / from ScreenshotRequest
- final UUID requestId = UUID.randomUUID();
-
- Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
-
- Bitmap image = mParams.image;
- mScreenshotId = String.format(SCREENSHOT_ID_TEMPLATE, requestId);
-
- boolean savingToOtherUser = mParams.owner != Process.myUserHandle();
- // Smart actions don't yet work for cross-user saves.
- boolean smartActionsEnabled = !savingToOtherUser
- && DeviceConfig.getBoolean(DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.ENABLE_SCREENSHOT_NOTIFICATION_SMART_ACTIONS,
- true);
- try {
- if (smartActionsEnabled && mParams.mQuickShareActionsReadyListener != null) {
- // Since Quick Share target recommendation does not rely on image URL, it is
- // queried and surfaced before image compress/export. Action intent would not be
- // used, because it does not contain image URL.
- Notification.Action quickShare =
- queryQuickShareAction(mScreenshotId, image, mParams.owner, null);
- if (quickShare != null) {
- mQuickShareData.quickShareAction = quickShare;
- mParams.mQuickShareActionsReadyListener.onActionsReady(mQuickShareData);
- }
- }
-
- // Call synchronously here since already on a background thread.
- ListenableFuture<ImageExporter.Result> future =
- mImageExporter.export(Runnable::run, requestId, image, mParams.owner,
- mParams.displayId);
- ImageExporter.Result result = future.get();
- Log.d(TAG, "Saved screenshot: " + result);
- final Uri uri = result.uri;
- mImageTime = result.timestamp;
-
- CompletableFuture<List<Notification.Action>> smartActionsFuture =
- mScreenshotSmartActions.getSmartActionsFuture(
- mScreenshotId, uri, image, mSmartActionsProvider,
- ScreenshotSmartActionType.REGULAR_SMART_ACTIONS,
- smartActionsEnabled, mParams.owner);
- List<Notification.Action> smartActions = new ArrayList<>();
- if (smartActionsEnabled) {
- int timeoutMs = DeviceConfig.getInt(
- DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.SCREENSHOT_NOTIFICATION_SMART_ACTIONS_TIMEOUT_MS,
- 1000);
- smartActions.addAll(buildSmartActions(
- mScreenshotSmartActions.getSmartActions(
- mScreenshotId, smartActionsFuture, timeoutMs,
- mSmartActionsProvider,
- ScreenshotSmartActionType.REGULAR_SMART_ACTIONS),
- mContext));
- }
-
- mImageData.uri = uri;
- mImageData.owner = mParams.owner;
- mImageData.smartActions = smartActions;
- mImageData.quickShareAction = createQuickShareAction(
- mQuickShareData.quickShareAction, mScreenshotId, uri, mImageTime, image,
- mParams.owner);
- mImageData.subject = getSubjectString(mImageTime);
- mImageData.imageTime = mImageTime;
-
- mParams.mActionsReadyListener.onActionsReady(mImageData);
- if (DEBUG_CALLBACK) {
- Log.d(TAG, "finished background processing, Calling (Consumer<Uri>) "
- + "finisher.accept(\"" + mImageData.uri + "\"");
- }
- mParams.finisher.accept(mImageData.uri);
- mParams.image = null;
- } catch (Exception e) {
- // IOException/UnsupportedOperationException may be thrown if external storage is
- // not mounted
- Log.d(TAG, "Failed to store screenshot", e);
- mParams.clearImage();
- mImageData.reset();
- mQuickShareData.reset();
- mParams.mActionsReadyListener.onActionsReady(mImageData);
- if (DEBUG_CALLBACK) {
- Log.d(TAG, "Calling (Consumer<Uri>) finisher.accept(null)");
- }
- mParams.finisher.accept(null);
- }
-
- return null;
- }
-
- /**
- * Update the listener run when the saving task completes. Used to avoid showing UI for the
- * first screenshot when a second one is taken.
- */
- void setActionsReadyListener(ActionsReadyListener listener) {
- mParams.mActionsReadyListener = listener;
- }
-
- @Override
- protected void onCancelled(Void params) {
- // If we are cancelled while the task is running in the background, we may get null
- // params. The finisher is expected to always be called back, so just use the baked-in
- // params from the ctor in any case.
- mImageData.reset();
- mQuickShareData.reset();
- mParams.mActionsReadyListener.onActionsReady(mImageData);
- if (DEBUG_CALLBACK) {
- Log.d(TAG, "onCancelled, calling (Consumer<Uri>) finisher.accept(null)");
- }
- mParams.finisher.accept(null);
- mParams.clearImage();
- }
-
- private List<Notification.Action> buildSmartActions(
- List<Notification.Action> actions, Context context) {
- List<Notification.Action> broadcastActions = new ArrayList<>();
- for (Notification.Action action : actions) {
- // Proxy smart actions through {@link SmartActionsReceiver} for logging smart actions.
- Bundle extras = action.getExtras();
- String actionType = extras.getString(
- ScreenshotNotificationSmartActionsProvider.ACTION_TYPE,
- ScreenshotNotificationSmartActionsProvider.DEFAULT_ACTION_TYPE);
- Intent intent = new Intent(context, SmartActionsReceiver.class)
- .putExtra(SmartActionsReceiver.EXTRA_ACTION_INTENT, action.actionIntent)
- .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- addIntentExtras(mScreenshotId, intent, actionType, true /* smartActionsEnabled */);
- PendingIntent broadcastIntent = PendingIntent.getBroadcast(context,
- mRandom.nextInt(),
- intent,
- PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
- broadcastActions.add(new Notification.Action.Builder(action.getIcon(), action.title,
- broadcastIntent).setContextual(true).addExtras(extras).build());
- }
- return broadcastActions;
- }
-
- private static void addIntentExtras(String screenshotId, Intent intent, String actionType,
- boolean smartActionsEnabled) {
- intent
- .putExtra(SmartActionsReceiver.EXTRA_ACTION_TYPE, actionType)
- .putExtra(SmartActionsReceiver.EXTRA_ID, screenshotId)
- .putExtra(SmartActionsReceiver.EXTRA_SMART_ACTIONS_ENABLED, smartActionsEnabled);
- }
-
- /**
- * Wrap the quickshare intent and populate the fillin intent with the URI
- */
- @VisibleForTesting
- Notification.Action createQuickShareAction(
- Notification.Action quickShare, String screenshotId, Uri uri, long imageTime,
- Bitmap image, UserHandle user) {
- if (quickShare == null) {
- return null;
- } else if (quickShare.actionIntent.isImmutable()) {
- Notification.Action quickShareWithUri =
- queryQuickShareAction(screenshotId, image, user, uri);
- if (quickShareWithUri == null
- || !quickShareWithUri.title.toString().contentEquals(quickShare.title)) {
- return null;
- }
- quickShare = quickShareWithUri;
- }
-
- Intent wrappedIntent = new Intent(mContext, SmartActionsReceiver.class)
- .putExtra(SmartActionsReceiver.EXTRA_ACTION_INTENT, quickShare.actionIntent)
- .putExtra(SmartActionsReceiver.EXTRA_ACTION_INTENT_FILLIN,
- createFillInIntent(uri, imageTime))
- .addFlags(Intent.FLAG_RECEIVER_FOREGROUND);
- Bundle extras = quickShare.getExtras();
- String actionType = extras.getString(
- ScreenshotNotificationSmartActionsProvider.ACTION_TYPE,
- ScreenshotNotificationSmartActionsProvider.DEFAULT_ACTION_TYPE);
- // We only query for quick share actions when smart actions are enabled, so we can assert
- // that it's true here.
- addIntentExtras(screenshotId, wrappedIntent, actionType, true /* smartActionsEnabled */);
- PendingIntent broadcastIntent =
- PendingIntent.getBroadcast(mContext, mRandom.nextInt(), wrappedIntent,
- PendingIntent.FLAG_CANCEL_CURRENT | PendingIntent.FLAG_IMMUTABLE);
- return new Notification.Action.Builder(quickShare.getIcon(), quickShare.title,
- broadcastIntent)
- .setContextual(true)
- .addExtras(extras)
- .build();
- }
-
- private Intent createFillInIntent(Uri uri, long imageTime) {
- Intent fillIn = new Intent();
- fillIn.setType("image/png");
- fillIn.putExtra(Intent.EXTRA_STREAM, uri);
- fillIn.putExtra(Intent.EXTRA_SUBJECT, getSubjectString(imageTime));
- // Include URI in ClipData also, so that grantPermission picks it up.
- // We don't use setData here because some apps interpret this as "to:".
- ClipData clipData = new ClipData(
- new ClipDescription("content", new String[]{"image/png"}),
- new ClipData.Item(uri));
- fillIn.setClipData(clipData);
- fillIn.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION);
- return fillIn;
- }
-
- /**
- * Query and surface Quick Share chip if it is available. Action intent would not be used,
- * because it does not contain image URL which would be populated in {@link
- * #createQuickShareAction(Notification.Action, String, Uri, long, Bitmap, UserHandle)}
- */
-
- @VisibleForTesting
- Notification.Action queryQuickShareAction(
- String screenshotId, Bitmap image, UserHandle user, Uri uri) {
- CompletableFuture<List<Notification.Action>> quickShareActionsFuture =
- mScreenshotSmartActions.getSmartActionsFuture(
- screenshotId, uri, image, mSmartActionsProvider,
- ScreenshotSmartActionType.QUICK_SHARE_ACTION,
- true /* smartActionsEnabled */, user);
- int timeoutMs = DeviceConfig.getInt(
- DeviceConfig.NAMESPACE_SYSTEMUI,
- SystemUiDeviceConfigFlags.SCREENSHOT_NOTIFICATION_QUICK_SHARE_ACTIONS_TIMEOUT_MS,
- 500);
- List<Notification.Action> quickShareActions =
- mScreenshotSmartActions.getSmartActions(
- screenshotId, quickShareActionsFuture, timeoutMs,
- mSmartActionsProvider,
- ScreenshotSmartActionType.QUICK_SHARE_ACTION);
- if (!quickShareActions.isEmpty()) {
- return quickShareActions.get(0);
- }
- return null;
- }
-
- private static String getSubjectString(long imageTime) {
- String subjectDate = DateFormat.getDateTimeInstance().format(new Date(imageTime));
- return String.format(SCREENSHOT_SHARE_SUBJECT_TEMPLATE, subjectDate);
- }
-}
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java
index 7b802a2a40aa..fe58bc9f34a9 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/ScreenshotController.java
@@ -18,7 +18,6 @@ package com.android.systemui.screenshot;
import static android.content.res.Configuration.ORIENTATION_PORTRAIT;
-import static com.android.systemui.Flags.screenshotSaveImageExporter;
import static com.android.systemui.screenshot.LogConfig.DEBUG_ANIM;
import static com.android.systemui.screenshot.LogConfig.DEBUG_CALLBACK;
import static com.android.systemui.screenshot.LogConfig.DEBUG_INPUT;
@@ -124,7 +123,6 @@ public class ScreenshotController implements InteractiveScreenshotHandler {
private final MessageContainerController mMessageContainerController;
private final AnnouncementResolver mAnnouncementResolver;
private Bitmap mScreenBitmap;
- private SaveImageInBackgroundTask mSaveInBgTask;
private boolean mScreenshotTakenInPortrait;
private Animator mScreenshotAnimation;
private RequestCallback mCurrentRequestCallback;
@@ -373,10 +371,6 @@ public class ScreenshotController implements InteractiveScreenshotHandler {
// Any cleanup needed when the service is being destroyed.
@Override
public void onDestroy() {
- if (mSaveInBgTask != null) {
- // just log success/failure for the pre-existing screenshot
- mSaveInBgTask.setActionsReadyListener(this::logSuccessOnActionsReady);
- }
removeWindow();
releaseMediaPlayer();
releaseContext();
@@ -525,36 +519,12 @@ public class ScreenshotController implements InteractiveScreenshotHandler {
// Play the shutter sound to notify that we've taken a screenshot
playCameraSoundIfNeeded();
- if (screenshotSaveImageExporter()) {
- saveScreenshotInBackground(screenshot, UUID.randomUUID(), finisher, result -> {
- if (result.uri != null) {
- mScreenshotHandler.post(() -> Toast.makeText(mContext,
- R.string.screenshot_saved_title, Toast.LENGTH_SHORT).show());
- }
- });
- } else {
- saveScreenshotInWorkerThread(
- screenshot.getUserHandle(),
- /* onComplete */ finisher,
- /* actionsReadyListener */ imageData -> {
- if (DEBUG_CALLBACK) {
- Log.d(TAG,
- "returning URI to finisher (Consumer<URI>): " + imageData.uri);
- }
- finisher.accept(imageData.uri);
- if (imageData.uri == null) {
- mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_NOT_SAVED, 0,
- mPackageName);
- mNotificationsController.notifyScreenshotError(
- R.string.screenshot_failed_to_save_text);
- } else {
- mUiEventLogger.log(ScreenshotEvent.SCREENSHOT_SAVED, 0, mPackageName);
- mScreenshotHandler.post(() -> Toast.makeText(mContext,
- R.string.screenshot_saved_title, Toast.LENGTH_SHORT).show());
- }
- },
- null);
- }
+ saveScreenshotInBackground(screenshot, UUID.randomUUID(), finisher, result -> {
+ if (result.uri != null) {
+ mScreenshotHandler.post(() -> Toast.makeText(mContext,
+ R.string.screenshot_saved_title, Toast.LENGTH_SHORT).show());
+ }
+ });
}
/**
@@ -627,35 +597,6 @@ public class ScreenshotController implements InteractiveScreenshotHandler {
}
/**
- * Creates a new worker thread and saves the screenshot to the media store.
- */
- private void saveScreenshotInWorkerThread(
- UserHandle owner,
- @NonNull Consumer<Uri> finisher,
- @Nullable SaveImageInBackgroundTask.ActionsReadyListener actionsReadyListener,
- @Nullable SaveImageInBackgroundTask.QuickShareActionReadyListener
- quickShareActionsReadyListener) {
- SaveImageInBackgroundTask.SaveImageInBackgroundData
- data = new SaveImageInBackgroundTask.SaveImageInBackgroundData();
- data.image = mScreenBitmap;
- data.finisher = finisher;
- data.mActionsReadyListener = actionsReadyListener;
- data.mQuickShareActionsReadyListener = quickShareActionsReadyListener;
- data.owner = owner;
- data.displayId = mDisplay.getDisplayId();
-
- if (mSaveInBgTask != null) {
- // just log success/failure for the pre-existing screenshot
- mSaveInBgTask.setActionsReadyListener(this::logSuccessOnActionsReady);
- }
-
- mSaveInBgTask = new SaveImageInBackgroundTask(mContext, mFlags, mImageExporter,
- mScreenshotSmartActions, data,
- mScreenshotNotificationSmartActionsProvider);
- mSaveInBgTask.execute();
- }
-
- /**
* Logs success/failure of the screenshot saving task, and shows an error if it failed.
*/
private void logScreenshotResultStatus(Uri uri, UserHandle owner) {
@@ -672,13 +613,6 @@ public class ScreenshotController implements InteractiveScreenshotHandler {
}
}
- /**
- * Logs success/failure of the screenshot saving task, and shows an error if it failed.
- */
- private void logSuccessOnActionsReady(SaveImageInBackgroundTask.SavedImageData imageData) {
- logScreenshotResultStatus(imageData.uri, imageData.owner);
- }
-
private boolean isUserSetupComplete(UserHandle owner) {
return Settings.Secure.getInt(mContext.createContextAsUser(owner, 0)
.getContentResolver(), SETTINGS_SECURE_USER_SETUP_COMPLETE, 0) == 1;
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/appclips/AppClipsViewModel.java b/packages/SystemUI/src/com/android/systemui/screenshot/appclips/AppClipsViewModel.java
index 9a38358a2768..4b1504f1cc2f 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/appclips/AppClipsViewModel.java
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/appclips/AppClipsViewModel.java
@@ -28,9 +28,9 @@ import android.app.TaskInfo;
import android.app.WindowConfiguration;
import android.app.assist.AssistContent;
import android.content.ClipData;
-import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
+import android.content.pm.ActivityInfo;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.graphics.Bitmap;
@@ -249,7 +249,6 @@ final class AppClipsViewModel extends ViewModel {
.map(taskInfo -> new InternalTaskInfo(taskInfo.topActivityInfo,
taskInfo.taskId, taskInfo.userId,
getPackageManagerForUser(taskInfo.userId)))
- .filter(this::canAppStartThroughLauncher)
.map(this::getBacklinksDataForTaskInfo)
.toList(),
mBgExecutor);
@@ -257,6 +256,17 @@ final class AppClipsViewModel extends ViewModel {
return Futures.transformAsync(backlinksNestedListFuture, Futures::allAsList, mBgExecutor);
}
+ private PackageManager getPackageManagerForUser(int userId) {
+ // If app clips was launched as the same user, then reuse the available PM from mContext.
+ if (mContext.getUserId() == userId) {
+ return mContext.getPackageManager();
+ }
+
+ // PackageManager required for a different user, create its context and return its PM.
+ UserHandle userHandle = UserHandle.of(userId);
+ return mContext.createContextAsUser(userHandle, /* flags= */ 0).getPackageManager();
+ }
+
/**
* Returns all tasks on a given display after querying {@link IActivityTaskManager} from the
* {@link #mBgExecutor}.
@@ -311,17 +321,6 @@ final class AppClipsViewModel extends ViewModel {
}
/**
- * Returns whether the app represented by the {@link InternalTaskInfo} can be launched through
- * the all apps tray by a user.
- */
- private boolean canAppStartThroughLauncher(InternalTaskInfo internalTaskInfo) {
- // Use Intent.resolveActivity API to check if the intent resolves as that is what Android
- // uses internally when apps use Context.startActivity.
- return getMainLauncherIntentForTask(internalTaskInfo)
- .resolveActivity(internalTaskInfo.getPackageManager()) != null;
- }
-
- /**
* Returns an {@link InternalBacklinksData} that represents the Backlink data internally, which
* is captured by querying the system using {@link TaskInfo#taskId}.
*/
@@ -390,11 +389,14 @@ final class AppClipsViewModel extends ViewModel {
internalTaskInfo.getTaskId(),
internalTaskInfo.getTopActivityNameForDebugLogging()));
- String appName = internalTaskInfo.getTopActivityAppName();
- Drawable appIcon = internalTaskInfo.getTopActivityAppIcon();
- ClipData mainLauncherIntent = ClipData.newIntent(appName,
- getMainLauncherIntentForTask(internalTaskInfo));
- InternalBacklinksData fallback = new BacklinksData(mainLauncherIntent, appIcon);
+ String screenshottedAppName = internalTaskInfo.getTopActivityAppName();
+ Drawable screenshottedAppIcon = internalTaskInfo.getTopActivityAppIcon();
+ Intent screenshottedAppMainLauncherIntent = getMainLauncherIntentForTask(
+ internalTaskInfo.getTopActivityPackageName(), internalTaskInfo.getPackageManager());
+ ClipData screenshottedAppMainLauncherClipData =
+ ClipData.newIntent(screenshottedAppName, screenshottedAppMainLauncherIntent);
+ InternalBacklinksData fallback =
+ new BacklinksData(screenshottedAppMainLauncherClipData, screenshottedAppIcon);
if (content == null) {
return fallback;
}
@@ -406,10 +408,14 @@ final class AppClipsViewModel extends ViewModel {
Uri uri = content.getWebUri();
Intent backlinksIntent = new Intent(ACTION_VIEW).setData(uri);
- if (doesIntentResolveToSameTask(backlinksIntent, internalTaskInfo)) {
+ BacklinkDisplayInfo backlinkDisplayInfo = getInfoThatResolvesIntent(backlinksIntent,
+ internalTaskInfo);
+ if (backlinkDisplayInfo != null) {
DebugLogger.INSTANCE.logcatMessage(this,
() -> "getBacklinksDataFromAssistContent: using app provided uri");
- return new BacklinksData(ClipData.newRawUri(appName, uri), appIcon);
+ return new BacklinksData(
+ ClipData.newRawUri(backlinkDisplayInfo.getDisplayLabel(), uri),
+ backlinkDisplayInfo.getAppIcon());
}
}
@@ -419,10 +425,14 @@ final class AppClipsViewModel extends ViewModel {
() -> "getBacklinksDataFromAssistContent: app has provided an intent");
Intent backlinksIntent = content.getIntent();
- if (doesIntentResolveToSameTask(backlinksIntent, internalTaskInfo)) {
+ BacklinkDisplayInfo backlinkDisplayInfo = getInfoThatResolvesIntent(backlinksIntent,
+ internalTaskInfo);
+ if (backlinkDisplayInfo != null) {
DebugLogger.INSTANCE.logcatMessage(this,
() -> "getBacklinksDataFromAssistContent: using app provided intent");
- return new BacklinksData(ClipData.newIntent(appName, backlinksIntent), appIcon);
+ return new BacklinksData(
+ ClipData.newIntent(backlinkDisplayInfo.getDisplayLabel(), backlinksIntent),
+ backlinkDisplayInfo.getAppIcon());
}
}
@@ -431,27 +441,76 @@ final class AppClipsViewModel extends ViewModel {
return fallback;
}
- private boolean doesIntentResolveToSameTask(Intent intentToResolve,
- InternalTaskInfo requiredTaskInfo) {
- PackageManager packageManager = requiredTaskInfo.getPackageManager();
- ComponentName resolvedComponent = intentToResolve.resolveActivity(packageManager);
- if (resolvedComponent == null) {
- return false;
+ /**
+ * Returns {@link BacklinkDisplayInfo} for the app that would resolve the provided backlink
+ * {@link Intent}.
+ *
+ * <p>The method uses the {@link PackageManager} available in the provided
+ * {@link InternalTaskInfo}.
+ *
+ * <p>This method returns {@code null} if Android is not able to resolve the backlink intent or
+ * if the resolved app does not have an icon in the launcher.
+ */
+ @Nullable
+ private BacklinkDisplayInfo getInfoThatResolvesIntent(Intent backlinkIntent,
+ InternalTaskInfo internalTaskInfo) {
+ PackageManager packageManager = internalTaskInfo.getPackageManager();
+
+ // Query for all available activities as there is a chance that multiple apps could resolve
+ // the intent. In such cases the normal `intent.resolveActivity` API returns the activity
+ // resolver info which isn't helpful for further checks. Also, using MATCH_DEFAULT_ONLY flag
+ // is required as that flag will be used when the notes app builds the intent and calls
+ // startActivity with the intent.
+ List<ResolveInfo> resolveInfos = packageManager.queryIntentActivities(backlinkIntent,
+ PackageManager.MATCH_DEFAULT_ONLY);
+ if (resolveInfos.isEmpty()) {
+ DebugLogger.INSTANCE.logcatMessage(this,
+ () -> "getInfoThatResolvesIntent: could not resolve backlink intent");
+ return null;
+ }
+
+ // Only use the first result as the list is ordered from best match to worst and Android
+ // will also use the best match with `intent.startActivity` API which notes app will use.
+ ActivityInfo activityInfo = resolveInfos.get(0).activityInfo;
+ if (activityInfo == null) {
+ DebugLogger.INSTANCE.logcatMessage(this,
+ () -> "getInfoThatResolvesIntent: could not find activity info for backlink "
+ + "intent");
+ return null;
+ }
+
+ // Ignore resolved backlink app if users cannot start it through all apps tray.
+ if (!canAppStartThroughLauncher(activityInfo.packageName, packageManager)) {
+ DebugLogger.INSTANCE.logcatMessage(this,
+ () -> "getInfoThatResolvesIntent: ignoring resolved backlink app as it cannot"
+ + " start through launcher");
+ return null;
}
- String requiredPackageName = requiredTaskInfo.getTopActivityPackageName();
- return resolvedComponent.getPackageName().equals(requiredPackageName);
+ Drawable appIcon = InternalBacklinksDataKt.getAppIcon(activityInfo, packageManager);
+ String appName = InternalBacklinksDataKt.getAppName(activityInfo, packageManager);
+ return new BacklinkDisplayInfo(appIcon, appName);
+ }
+
+ /**
+ * Returns whether the app represented by the provided {@code pkgName} can be launched through
+ * the all apps tray by the user.
+ */
+ private static boolean canAppStartThroughLauncher(String pkgName, PackageManager pkgManager) {
+ // Use Intent.resolveActivity API to check if the intent resolves as that is what Android
+ // uses internally when apps use Context.startActivity.
+ return getMainLauncherIntentForTask(pkgName, pkgManager)
+ .resolveActivity(pkgManager) != null;
}
- private Intent getMainLauncherIntentForTask(InternalTaskInfo internalTaskInfo) {
- String pkgName = internalTaskInfo.getTopActivityPackageName();
+ private static Intent getMainLauncherIntentForTask(String pkgName,
+ PackageManager packageManager) {
Intent intent = new Intent(ACTION_MAIN).addCategory(CATEGORY_LAUNCHER).setPackage(pkgName);
// Not all apps use DEFAULT_CATEGORY for their main launcher activity so the exact component
// needs to be queried and set on the Intent in order for note-taking apps to be able to
// start this intent. When starting an activity with an implicit intent, Android adds the
// DEFAULT_CATEGORY flag otherwise it fails to resolve the intent.
- PackageManager packageManager = internalTaskInfo.getPackageManager();
ResolveInfo resolvedActivity = packageManager.resolveActivity(intent, /* flags= */ 0);
if (resolvedActivity != null) {
intent.setComponent(resolvedActivity.getComponentInfo().getComponentName());
@@ -460,17 +519,6 @@ final class AppClipsViewModel extends ViewModel {
return intent;
}
- private PackageManager getPackageManagerForUser(int userId) {
- // If app clips was launched as the same user, then reuse the available PM from mContext.
- if (mContext.getUserId() == userId) {
- return mContext.getPackageManager();
- }
-
- // PackageManager required for a different user, create its context and return its PM.
- UserHandle userHandle = UserHandle.of(userId);
- return mContext.createContextAsUser(userHandle, /* flags= */ 0).getPackageManager();
- }
-
/** Helper factory to help with injecting {@link AppClipsViewModel}. */
static final class Factory implements ViewModelProvider.Factory {
diff --git a/packages/SystemUI/src/com/android/systemui/screenshot/appclips/InternalBacklinksData.kt b/packages/SystemUI/src/com/android/systemui/screenshot/appclips/InternalBacklinksData.kt
index 234692ea2fc6..f4faa36ef718 100644
--- a/packages/SystemUI/src/com/android/systemui/screenshot/appclips/InternalBacklinksData.kt
+++ b/packages/SystemUI/src/com/android/systemui/screenshot/appclips/InternalBacklinksData.kt
@@ -27,16 +27,27 @@ import android.graphics.drawable.Drawable
* represent error when necessary.
*/
internal sealed class InternalBacklinksData(
- open val appIcon: Drawable,
- open var displayLabel: String
+ // Fields from this object are made accessible through accessors to keep call sites simpler.
+ private val backlinkDisplayInfo: BacklinkDisplayInfo,
) {
- data class BacklinksData(val clipData: ClipData, override val appIcon: Drawable) :
- InternalBacklinksData(appIcon, clipData.description.label.toString())
+ // Use separate field to access display label so that callers don't have to access through
+ // internal object.
+ var displayLabel: String
+ get() = backlinkDisplayInfo.displayLabel
+ set(value) {
+ backlinkDisplayInfo.displayLabel = value
+ }
- data class CrossProfileError(
- override val appIcon: Drawable,
- override var displayLabel: String
- ) : InternalBacklinksData(appIcon, displayLabel)
+ // Use separate field to access app icon so that callers don't have to access through internal
+ // object.
+ val appIcon: Drawable
+ get() = backlinkDisplayInfo.appIcon
+
+ data class BacklinksData(val clipData: ClipData, private val icon: Drawable) :
+ InternalBacklinksData(BacklinkDisplayInfo(icon, clipData.description.label.toString()))
+
+ data class CrossProfileError(private val icon: Drawable, private var label: String) :
+ InternalBacklinksData(BacklinkDisplayInfo(icon, label))
}
/**
@@ -54,11 +65,16 @@ internal data class InternalTaskInfo(
val userId: Int,
val packageManager: PackageManager
) {
- fun getTopActivityNameForDebugLogging(): String = topActivityInfo.name
+ val topActivityNameForDebugLogging: String = topActivityInfo.name
+ val topActivityPackageName: String = topActivityInfo.packageName
+ val topActivityAppName: String by lazy { topActivityInfo.getAppName(packageManager) }
+ val topActivityAppIcon: Drawable by lazy { topActivityInfo.loadIcon(packageManager) }
+}
- fun getTopActivityPackageName(): String = topActivityInfo.packageName
+internal fun ActivityInfo.getAppName(packageManager: PackageManager) =
+ loadLabel(packageManager).toString()
- fun getTopActivityAppName(): String = topActivityInfo.loadLabel(packageManager).toString()
+internal fun ActivityInfo.getAppIcon(packageManager: PackageManager) = loadIcon(packageManager)
- fun getTopActivityAppIcon(): Drawable = topActivityInfo.loadIcon(packageManager)
-}
+/** A class to hold data that is used for displaying backlink to user in SysUI activity. */
+internal data class BacklinkDisplayInfo(val appIcon: Drawable, var displayLabel: String)
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeEmptyImplModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeEmptyImplModule.kt
index 7425807b716d..99ff94605c39 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ShadeEmptyImplModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeEmptyImplModule.kt
@@ -28,6 +28,8 @@ import com.android.systemui.shade.domain.interactor.ShadeBackActionInteractor
import com.android.systemui.shade.domain.interactor.ShadeInteractor
import com.android.systemui.shade.domain.interactor.ShadeInteractorEmptyImpl
import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor
+import com.android.systemui.shade.domain.interactor.ShadeModeInteractor
+import com.android.systemui.shade.domain.interactor.ShadeModeInteractorEmptyImpl
import dagger.Binds
import dagger.Module
@@ -75,4 +77,8 @@ abstract class ShadeEmptyImplModule {
@Binds
@SysUISingleton
abstract fun bindsPrivacyChipRepository(impl: PrivacyChipRepositoryImpl): PrivacyChipRepository
+
+ @Binds
+ @SysUISingleton
+ abstract fun bindShadeModeInteractor(impl: ShadeModeInteractorEmptyImpl): ShadeModeInteractor
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt
index da2024b4ef18..2348a110eb3a 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeModule.kt
@@ -41,6 +41,8 @@ import com.android.systemui.shade.domain.interactor.ShadeInteractorLegacyImpl
import com.android.systemui.shade.domain.interactor.ShadeInteractorSceneContainerImpl
import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractor
import com.android.systemui.shade.domain.interactor.ShadeLockscreenInteractorImpl
+import com.android.systemui.shade.domain.interactor.ShadeModeInteractor
+import com.android.systemui.shade.domain.interactor.ShadeModeInteractorImpl
import dagger.Binds
import dagger.Module
import dagger.Provides
@@ -54,7 +56,7 @@ abstract class ShadeModule {
@SysUISingleton
fun provideBaseShadeInteractor(
sceneContainerOn: Provider<ShadeInteractorSceneContainerImpl>,
- sceneContainerOff: Provider<ShadeInteractorLegacyImpl>
+ sceneContainerOff: Provider<ShadeInteractorLegacyImpl>,
): BaseShadeInteractor {
return if (SceneContainerFlag.isEnabled) {
sceneContainerOn.get()
@@ -67,7 +69,7 @@ abstract class ShadeModule {
@SysUISingleton
fun provideShadeController(
sceneContainerOn: Provider<ShadeControllerSceneImpl>,
- sceneContainerOff: Provider<ShadeControllerImpl>
+ sceneContainerOff: Provider<ShadeControllerImpl>,
): ShadeController {
return if (SceneContainerFlag.isEnabled) {
sceneContainerOn.get()
@@ -80,7 +82,7 @@ abstract class ShadeModule {
@SysUISingleton
fun provideShadeAnimationInteractor(
sceneContainerOn: Provider<ShadeAnimationInteractorSceneContainerImpl>,
- sceneContainerOff: Provider<ShadeAnimationInteractorLegacyImpl>
+ sceneContainerOff: Provider<ShadeAnimationInteractorLegacyImpl>,
): ShadeAnimationInteractor {
return if (SceneContainerFlag.isEnabled) {
sceneContainerOn.get()
@@ -93,7 +95,7 @@ abstract class ShadeModule {
@SysUISingleton
fun provideShadeBackActionInteractor(
sceneContainerOn: Provider<ShadeBackActionInteractorImpl>,
- sceneContainerOff: Provider<NotificationPanelViewController>
+ sceneContainerOff: Provider<NotificationPanelViewController>,
): ShadeBackActionInteractor {
return if (SceneContainerFlag.isEnabled) {
sceneContainerOn.get()
@@ -106,7 +108,7 @@ abstract class ShadeModule {
@SysUISingleton
fun provideShadeLockscreenInteractor(
sceneContainerOn: Provider<ShadeLockscreenInteractorImpl>,
- sceneContainerOff: Provider<NotificationPanelViewController>
+ sceneContainerOff: Provider<NotificationPanelViewController>,
): ShadeLockscreenInteractor {
return if (SceneContainerFlag.isEnabled) {
sceneContainerOn.get()
@@ -119,7 +121,7 @@ abstract class ShadeModule {
@SysUISingleton
fun providePanelExpansionInteractor(
sceneContainerOn: Provider<PanelExpansionInteractorImpl>,
- sceneContainerOff: Provider<NotificationPanelViewController>
+ sceneContainerOff: Provider<NotificationPanelViewController>,
): PanelExpansionInteractor {
return if (SceneContainerFlag.isEnabled) {
sceneContainerOn.get()
@@ -170,4 +172,8 @@ abstract class ShadeModule {
@Binds
@SysUISingleton
abstract fun bindsPrivacyChipRepository(impl: PrivacyChipRepositoryImpl): PrivacyChipRepository
+
+ @Binds
+ @SysUISingleton
+ abstract fun bindShadeModeInteractor(impl: ShadeModeInteractorImpl): ShadeModeInteractor
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractor.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractor.kt
index 3cd91be469c1..6fb96da2c186 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractor.kt
@@ -145,7 +145,7 @@ interface BaseShadeInteractor {
fun createAnyExpansionFlow(
scope: CoroutineScope,
shadeExpansion: Flow<Float>,
- qsExpansion: Flow<Float>
+ qsExpansion: Flow<Float>,
): StateFlow<Float> {
return combine(shadeExpansion, qsExpansion) { shadeExp, qsExp -> maxOf(shadeExp, qsExp) }
.stateIn(scope, SharingStarted.Eagerly, 0f)
diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImpl.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImpl.kt
index b8d2dd2a764f..3eab02ad30d5 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeInteractorImpl.kt
@@ -16,7 +16,6 @@
package com.android.systemui.shade.domain.interactor
-import androidx.annotation.FloatRange
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
import com.android.systemui.keyguard.data.repository.KeyguardRepository
@@ -25,9 +24,6 @@ import com.android.systemui.keyguard.shared.model.DozeStateModel
import com.android.systemui.keyguard.shared.model.Edge
import com.android.systemui.keyguard.shared.model.KeyguardState
import com.android.systemui.power.domain.interactor.PowerInteractor
-import com.android.systemui.shade.data.repository.ShadeRepository
-import com.android.systemui.shade.shared.flag.DualShade
-import com.android.systemui.shade.shared.model.ShadeMode
import com.android.systemui.statusbar.disableflags.data.repository.DisableFlagsRepository
import com.android.systemui.statusbar.phone.DozeParameters
import com.android.systemui.statusbar.policy.data.repository.UserSetupRepository
@@ -55,11 +51,14 @@ constructor(
keyguardRepository: KeyguardRepository,
keyguardTransitionInteractor: KeyguardTransitionInteractor,
powerInteractor: PowerInteractor,
- private val shadeRepository: ShadeRepository,
userSetupRepository: UserSetupRepository,
userSwitcherInteractor: UserSwitcherInteractor,
private val baseShadeInteractor: BaseShadeInteractor,
-) : ShadeInteractor, BaseShadeInteractor by baseShadeInteractor {
+ shadeModeInteractor: ShadeModeInteractor,
+) :
+ ShadeInteractor,
+ BaseShadeInteractor by baseShadeInteractor,
+ ShadeModeInteractor by shadeModeInteractor {
override val isShadeEnabled: StateFlow<Boolean> =
disableFlagsRepository.disableFlags
.map { it.isShadeEnabled() }
@@ -103,27 +102,6 @@ constructor(
}
}
- override val isShadeLayoutWide: StateFlow<Boolean> = shadeRepository.isShadeLayoutWide
-
- @FloatRange(from = 0.0, to = 1.0)
- override fun getTopEdgeSplitFraction(): Float {
- // Note: this implicitly relies on isShadeLayoutWide being hot (i.e. collected). This
- // assumption allows us to query its value on demand (during swipe source detection) instead
- // of running another infinite coroutine.
- // TODO(b/338577208): Instead of being fixed at 0.8f, this should dynamically updated based
- // on the position of system-status icons in the status bar.
- return if (shadeRepository.isShadeLayoutWide.value) 0.8f else 0.5f
- }
-
- override val shadeMode: StateFlow<ShadeMode> =
- isShadeLayoutWide
- .map(this::determineShadeMode)
- .stateIn(
- scope,
- SharingStarted.Eagerly,
- initialValue = determineShadeMode(isShadeLayoutWide.value)
- )
-
override val isExpandToQsEnabled: Flow<Boolean> =
combine(
disableFlagsRepository.disableFlags,
@@ -140,12 +118,4 @@ constructor(
disableFlags.isQuickSettingsEnabled() &&
!isDozing
}
-
- private fun determineShadeMode(isShadeLayoutWide: Boolean): ShadeMode {
- return when {
- DualShade.isEnabled -> ShadeMode.Dual
- isShadeLayoutWide -> ShadeMode.Split
- else -> ShadeMode.Single
- }
- }
}
diff --git a/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractor.kt b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractor.kt
new file mode 100644
index 000000000000..77ae679bf018
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractor.kt
@@ -0,0 +1,113 @@
+/*
+ * Copyright (C) 2024 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.shade.domain.interactor
+
+import androidx.annotation.FloatRange
+import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.shade.data.repository.ShadeRepository
+import com.android.systemui.shade.shared.flag.DualShade
+import com.android.systemui.shade.shared.model.ShadeMode
+import javax.inject.Inject
+import kotlinx.coroutines.CoroutineScope
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.SharingStarted
+import kotlinx.coroutines.flow.StateFlow
+import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.stateIn
+
+/**
+ * Defines interface for classes that can provide state and business logic related to the mode of
+ * the shade.
+ */
+interface ShadeModeInteractor {
+
+ /**
+ * The version of the shade layout to use.
+ *
+ * Note: Most likely, you want to read [isShadeLayoutWide] instead of this.
+ */
+ val shadeMode: StateFlow<ShadeMode>
+
+ /**
+ * Whether the shade layout should be wide (true) or narrow (false).
+ *
+ * In a wide layout, notifications and quick settings each take up only half the screen width
+ * (whether they are shown at the same time or not). In a narrow layout, they can each be as
+ * wide as the entire screen.
+ */
+ val isShadeLayoutWide: StateFlow<Boolean>
+
+ /**
+ * The fraction between [0..1] (i.e., percentage) of screen width to consider the threshold
+ * between "top-left" and "top-right" for the purposes of dual-shade invocation.
+ *
+ * When the dual-shade is not wide, this always returns 0.5 (the top edge is evenly split). On
+ * wide layouts however, a larger fraction is returned because only the area of the system
+ * status icons is considered top-right.
+ *
+ * Note that this fraction only determines the split between the absolute left and right
+ * directions. In RTL layouts, the "top-start" edge will resolve to "top-right", and "top-end"
+ * will resolve to "top-left".
+ */
+ @FloatRange(from = 0.0, to = 1.0) fun getTopEdgeSplitFraction(): Float
+}
+
+class ShadeModeInteractorImpl
+@Inject
+constructor(
+ @Application applicationScope: CoroutineScope,
+ private val repository: ShadeRepository,
+) : ShadeModeInteractor {
+
+ override val isShadeLayoutWide: StateFlow<Boolean> = repository.isShadeLayoutWide
+
+ override val shadeMode: StateFlow<ShadeMode> =
+ isShadeLayoutWide
+ .map(this::determineShadeMode)
+ .stateIn(
+ applicationScope,
+ SharingStarted.Eagerly,
+ initialValue = determineShadeMode(isShadeLayoutWide.value),
+ )
+
+ @FloatRange(from = 0.0, to = 1.0)
+ override fun getTopEdgeSplitFraction(): Float {
+ // Note: this implicitly relies on isShadeLayoutWide being hot (i.e. collected). This
+ // assumption allows us to query its value on demand (during swipe source detection) instead
+ // of running another infinite coroutine.
+ // TODO(b/338577208): Instead of being fixed at 0.8f, this should dynamically updated based
+ // on the position of system-status icons in the status bar.
+ return if (repository.isShadeLayoutWide.value) 0.8f else 0.5f
+ }
+
+ private fun determineShadeMode(isShadeLayoutWide: Boolean): ShadeMode {
+ return when {
+ DualShade.isEnabled -> ShadeMode.Dual
+ isShadeLayoutWide -> ShadeMode.Split
+ else -> ShadeMode.Single
+ }
+ }
+}
+
+class ShadeModeInteractorEmptyImpl @Inject constructor() : ShadeModeInteractor {
+
+ override val shadeMode: StateFlow<ShadeMode> = MutableStateFlow(ShadeMode.Single)
+
+ override val isShadeLayoutWide: StateFlow<Boolean> = MutableStateFlow(false)
+
+ override fun getTopEdgeSplitFraction(): Float = 0.5f
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
index f88fd7d00a2b..862f33bb4ec3 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/CommandQueue.java
@@ -63,6 +63,7 @@ import android.view.accessibility.Flags;
import androidx.annotation.NonNull;
import androidx.annotation.VisibleForTesting;
+import com.android.internal.annotations.KeepForWeakReference;
import com.android.internal.os.SomeArgs;
import com.android.internal.statusbar.IAddTileResultCallback;
import com.android.internal.statusbar.IStatusBar;
@@ -192,10 +193,10 @@ public class CommandQueue extends IStatusBar.Stub implements
private static final String SHOW_IME_SWITCHER_KEY = "showImeSwitcherKey";
private final Object mLock = new Object();
- private ArrayList<Callbacks> mCallbacks = new ArrayList<>();
- private Handler mHandler = new H(Looper.getMainLooper());
+ private final ArrayList<Callbacks> mCallbacks = new ArrayList<>();
+ private final Handler mHandler = new H(Looper.getMainLooper());
/** A map of display id - disable flag pair */
- private SparseArray<Pair<Integer, Integer>> mDisplayDisabled = new SparseArray<>();
+ private final SparseArray<Pair<Integer, Integer>> mDisplayDisabled = new SparseArray<>();
/**
* The last ID of the display where IME window for which we received setImeWindowStatus
* event.
@@ -207,6 +208,21 @@ public class CommandQueue extends IStatusBar.Stub implements
private final @Nullable DumpHandler mDumpHandler;
private final @Nullable Lazy<PowerInteractor> mPowerInteractor;
+ @KeepForWeakReference
+ private final DisplayTracker.Callback mDisplayTrackerCallback = new DisplayTracker.Callback() {
+ @Override
+ public void onDisplayRemoved(int displayId) {
+ synchronized (mLock) {
+ mDisplayDisabled.remove(displayId);
+ }
+ // This callback is registered with {@link #mHandler} that already posts to run on
+ // main thread, so it is safe to dispatch directly.
+ for (int i = mCallbacks.size() - 1; i >= 0; i--) {
+ mCallbacks.get(i).onDisplayRemoved(displayId);
+ }
+ }
+ };
+
/**
* These methods are called back on the main thread.
*/
@@ -576,19 +592,8 @@ public class CommandQueue extends IStatusBar.Stub implements
mDisplayTracker = displayTracker;
mRegistry = registry;
mDumpHandler = dumpHandler;
- mDisplayTracker.addDisplayChangeCallback(new DisplayTracker.Callback() {
- @Override
- public void onDisplayRemoved(int displayId) {
- synchronized (mLock) {
- mDisplayDisabled.remove(displayId);
- }
- // This callback is registered with {@link #mHandler} that already posts to run on
- // main thread, so it is safe to dispatch directly.
- for (int i = mCallbacks.size() - 1; i >= 0; i--) {
- mCallbacks.get(i).onDisplayRemoved(displayId);
- }
- }
- }, new HandlerExecutor(mHandler));
+ mDisplayTracker.addDisplayChangeCallback(mDisplayTrackerCallback,
+ new HandlerExecutor(mHandler));
// We always have default display.
setDisabled(mDisplayTracker.getDefaultDisplayId(), DISABLE_NONE, DISABLE2_NONE);
mPowerInteractor = powerInteractor;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/ConnectivityModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/ConnectivityModule.kt
index 400f8af99e07..dac01028ef64 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/ConnectivityModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/connectivity/ConnectivityModule.kt
@@ -21,6 +21,7 @@ import com.android.systemui.flags.FeatureFlags
import com.android.systemui.flags.Flags.SIGNAL_CALLBACK_DEPRECATION
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.qs.tiles.AirplaneModeTile
import com.android.systemui.qs.tiles.BluetoothTile
@@ -95,21 +96,21 @@ interface ConnectivityModule {
@IntoMap
@StringKey(AIRPLANE_MODE_TILE_SPEC)
fun provideAirplaneModeAvailabilityInteractor(
- impl: AirplaneModeTileDataInteractor
+ impl: AirplaneModeTileDataInteractor
): QSTileAvailabilityInteractor
@Binds
@IntoMap
@StringKey(DATA_SAVER_TILE_SPEC)
fun provideDataSaverAvailabilityInteractor(
- impl: DataSaverTileDataInteractor
+ impl: DataSaverTileDataInteractor
): QSTileAvailabilityInteractor
@Binds
@IntoMap
@StringKey(INTERNET_TILE_SPEC)
fun provideInternetAvailabilityInteractor(
- impl: InternetTileDataInteractor
+ impl: InternetTileDataInteractor
): QSTileAvailabilityInteractor
companion object {
@@ -149,6 +150,7 @@ interface ConnectivityModule {
),
instanceId = uiEventLogger.getNewInstanceId(),
policy = QSTilePolicy.Restricted(listOf(UserManager.DISALLOW_AIRPLANE_MODE)),
+ category = TileCategory.CONNECTIVITY,
)
/** Inject AirplaneModeTile into tileViewModelMap in QSModule */
@@ -180,6 +182,7 @@ interface ConnectivityModule {
labelRes = R.string.data_saver,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.CONNECTIVITY,
)
/** Inject DataSaverTile into tileViewModelMap in QSModule */
@@ -211,6 +214,7 @@ interface ConnectivityModule {
labelRes = R.string.quick_settings_internet_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.CONNECTIVITY,
)
/** Inject InternetTile into tileViewModelMap in QSModule */
@@ -242,6 +246,7 @@ interface ConnectivityModule {
labelRes = R.string.quick_settings_hotspot_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.CONNECTIVITY,
)
@Provides
@@ -256,6 +261,7 @@ interface ConnectivityModule {
labelRes = R.string.quick_settings_cast_title,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.CONNECTIVITY,
)
@Provides
@@ -270,6 +276,7 @@ interface ConnectivityModule {
labelRes = R.string.quick_settings_bluetooth_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.CONNECTIVITY,
)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
index 0efd5f15cb09..ec0827b4c478 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/CommonVisualInterruptionSuppressors.kt
@@ -61,6 +61,7 @@ import com.android.systemui.statusbar.policy.BatteryController
import com.android.systemui.statusbar.policy.HeadsUpManager
import com.android.systemui.util.NotificationChannels
import com.android.systemui.util.settings.GlobalSettings
+import com.android.systemui.util.settings.SystemSettings
import com.android.systemui.util.time.SystemClock
import com.android.wm.shell.bubbles.Bubbles
import java.util.Optional
@@ -279,7 +280,8 @@ class AvalancheSuppressor(
private val uiEventLogger: UiEventLogger,
private val context: Context,
private val notificationManager: NotificationManager,
- private val logger: VisualInterruptionDecisionLogger
+ private val logger: VisualInterruptionDecisionLogger,
+ private val systemSettings: SystemSettings,
) :
VisualInterruptionFilter(
types = setOf(PEEK, PULSE),
@@ -300,6 +302,11 @@ class AvalancheSuppressor(
// education HUNs.
private var hasShownOnceForDebug = false
+ // Sometimes the kotlin flow value is false even when the cooldown setting is true (b/356768397)
+ // so let's directly check settings until we confirm that the flow is initialized and in sync
+ // with the real settings value.
+ private var isCooldownFlowInSync = false
+
private fun shouldShowEdu(): Boolean {
val forceShowOnce = SystemProperties.get(FORCE_SHOW_AVALANCHE_EDU_ONCE, "").equals("1")
return !hasSeenEdu || (forceShowOnce && !hasShownOnceForDebug)
@@ -479,6 +486,15 @@ class AvalancheSuppressor(
}
private fun isCooldownEnabled(): Boolean {
- return settingsInteractor.isCooldownEnabled.value
+ val isEnabledFromFlow = settingsInteractor.isCooldownEnabled.value
+ if (isCooldownFlowInSync) {
+ return isEnabledFromFlow
+ }
+ val isEnabled =
+ systemSettings.getInt(Settings.System.NOTIFICATION_COOLDOWN_ENABLED, /* def */ 1) == 1
+ if (isEnabled == isEnabledFromFlow) {
+ isCooldownFlowInSync = true
+ }
+ return isEnabled
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt
index 37ac7c4330af..38cab820c133 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionLogger.kt
@@ -108,7 +108,7 @@ constructor(@NotificationInterruptLog val buffer: LogBuffer) {
TAG,
INFO,
{ bool1 = isEnabled },
- { "Cooldown enabled: $isEnabled" }
+ { "Cooldown enabled: $bool1" }
)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt
index 2f8711a586ef..d4466f8771a6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImpl.kt
@@ -195,7 +195,8 @@ constructor(
uiEventLogger,
context,
notificationManager,
- logger
+ logger,
+ systemSettings
)
)
avalancheProvider.register()
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
index 8ff1ab640442..1214440a6b65 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/stack/NotificationStackScrollLayout.java
@@ -5404,7 +5404,9 @@ public class NotificationStackScrollLayout
println(pw, "intrinsicContentHeight", mIntrinsicContentHeight);
println(pw, "contentHeight", mContentHeight);
println(pw, "intrinsicPadding", mIntrinsicPadding);
- println(pw, "topPadding", getTopPadding());
+ if (!SceneContainerFlag.isEnabled()) {
+ println(pw, "topPadding", getTopPadding());
+ }
println(pw, "bottomPadding", mBottomPadding);
dumpRoundedRectClipping(pw);
println(pw, "requestedClipBounds", mRequestedClipBounds);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
index 1efad3b9fa66..0e7beb9d17da 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
@@ -262,6 +262,9 @@ public class HeadsUpManagerPhone extends BaseHeadsUpManager implements
releaseAllImmediately();
mReleaseOnExpandFinish = false;
} else {
+ for (NotificationEntry entry: getAllEntries().toList()) {
+ entry.setSeenInShade(true);
+ }
for (NotificationEntry entry : mEntriesToRemoveAfterExpand) {
if (isHeadsUpEntry(entry.getKey())) {
// Maybe the heads-up was removed already
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index dd4b0005b034..1ea26e5727ac 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -61,6 +61,7 @@ import com.android.systemui.bouncer.domain.interactor.AlternateBouncerInteractor
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor;
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerCallbackInteractor.PrimaryBouncerExpansionCallback;
import com.android.systemui.bouncer.domain.interactor.PrimaryBouncerInteractor;
+import com.android.systemui.bouncer.shared.flag.ComposeBouncerFlags;
import com.android.systemui.bouncer.ui.BouncerView;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Main;
@@ -70,8 +71,8 @@ import com.android.systemui.dock.DockManager;
import com.android.systemui.dreams.DreamOverlayStateController;
import com.android.systemui.keyguard.DismissCallbackRegistry;
import com.android.systemui.keyguard.KeyguardWmStateRefactor;
-import com.android.systemui.keyguard.domain.interactor.KeyguardDismissTransitionInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardDismissActionInteractor;
+import com.android.systemui.keyguard.domain.interactor.KeyguardDismissTransitionInteractor;
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor;
import com.android.systemui.keyguard.shared.model.DismissAction;
import com.android.systemui.keyguard.shared.model.Edge;
@@ -182,6 +183,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
private boolean mBouncerShowingOverDream;
private int mAttemptsToShowBouncer = 0;
private DelayableExecutor mExecutor;
+ private boolean mIsSleeping = false;
private final PrimaryBouncerExpansionCallback mExpansionCallback =
new PrimaryBouncerExpansionCallback() {
@@ -713,7 +715,11 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
* {@link #needsFullscreenBouncer()}.
*/
protected void showBouncerOrKeyguard(boolean hideBouncerWhenShowing, boolean isFalsingReset) {
- if (needsFullscreenBouncer() && !mDozing) {
+ boolean showBouncer = needsFullscreenBouncer() && !mDozing;
+ if (Flags.simPinRaceConditionOnRestart()) {
+ showBouncer = showBouncer && !mIsSleeping;
+ }
+ if (showBouncer) {
// The keyguard might be showing (already). So we need to hide it.
if (!primaryBouncerIsShowing()) {
if (SceneContainerFlag.isEnabled()) {
@@ -834,7 +840,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
public void dismissWithAction(OnDismissAction r, Runnable cancelAction,
boolean afterKeyguardGone, String message) {
- if (SceneContainerFlag.isEnabled()) {
+ if (ComposeBouncerFlags.INSTANCE.isEnabled()) {
if (r == null) {
return;
}
@@ -886,7 +892,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
return;
}
- if (!SceneContainerFlag.isEnabled()) {
+ if (!ComposeBouncerFlags.INSTANCE.isEnabled()) {
mAfterKeyguardGoneAction = r;
mKeyguardGoneCancelAction = cancelAction;
mDismissActionWillAnimateOnKeyguard = r != null
@@ -960,7 +966,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
* Adds a {@param runnable} to be executed after Keyguard is gone.
*/
public void addAfterKeyguardGoneRunnable(Runnable runnable) {
- if (SceneContainerFlag.isEnabled()) {
+ if (ComposeBouncerFlags.INSTANCE.isEnabled()) {
if (runnable != null) {
mKeyguardDismissActionInteractor.get().runAfterKeyguardGone(runnable);
}
@@ -1041,6 +1047,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
@Override
public void onStartedWakingUp() {
+ mIsSleeping = false;
setRootViewAnimationDisabled(false);
NavigationBarView navBarView = mCentralSurfaces.getNavigationBarView();
if (navBarView != null) {
@@ -1054,6 +1061,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
@Override
public void onStartedGoingToSleep() {
+ mIsSleeping = true;
setRootViewAnimationDisabled(true);
NavigationBarView navBarView = mCentralSurfaces.getNavigationBarView();
if (navBarView != null) {
@@ -1173,7 +1181,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
// We update the state (which will show the keyguard) only if an animation will run on
// the keyguard. If there is no animation, we wait before updating the state so that we
// go directly from bouncer to launcher/app.
- if (SceneContainerFlag.isEnabled()) {
+ if (ComposeBouncerFlags.INSTANCE.isEnabled()) {
if (mKeyguardDismissActionInteractor.get().runDismissAnimationOnKeyguard()) {
updateStates();
}
@@ -1300,7 +1308,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
}
private void executeAfterKeyguardGoneAction() {
- if (SceneContainerFlag.isEnabled()) {
+ if (ComposeBouncerFlags.INSTANCE.isEnabled()) {
return;
}
if (mAfterKeyguardGoneAction != null) {
@@ -1696,6 +1704,8 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
pw.println(" Registered KeyguardViewManagerCallbacks:");
pw.println(" SceneContainerFlag enabled:"
+ SceneContainerFlag.isEnabled());
+ pw.println(" ComposeBouncerFlags enabled:"
+ + ComposeBouncerFlags.INSTANCE.isEnabled());
for (KeyguardViewManagerCallback callback : mCallbacks) {
pw.println(" " + callback);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java
index c04616847ebe..0ad1042a665f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/SystemUIDialog.java
@@ -480,10 +480,16 @@ public class SystemUIDialog extends AlertDialog implements ViewRootImpl.ConfigCh
}
public static AlertDialog applyFlags(AlertDialog dialog) {
+ return applyFlags(dialog, true);
+ }
+
+ public static AlertDialog applyFlags(AlertDialog dialog, boolean showWhenLocked) {
final Window window = dialog.getWindow();
window.setType(WindowManager.LayoutParams.TYPE_STATUS_BAR_SUB_PANEL);
- window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM
- | WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+ window.addFlags(WindowManager.LayoutParams.FLAG_ALT_FOCUSABLE_IM);
+ if (showWhenLocked) {
+ window.addFlags(WindowManager.LayoutParams.FLAG_SHOW_WHEN_LOCKED);
+ }
window.getAttributes().setFitInsetsTypes(
window.getAttributes().getFitInsetsTypes() & ~Type.statusBars());
return dialog;
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/WifiRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/WifiRepository.kt
index fc7a67233bb6..bc7d376a8740 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/WifiRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/WifiRepository.kt
@@ -64,9 +64,6 @@ interface WifiRepository {
const val COL_NAME_IS_ENABLED = "isEnabled"
/** Column name to use for [isWifiDefault] for table logging. */
const val COL_NAME_IS_DEFAULT = "isDefault"
-
- const val CARRIER_MERGED_INVALID_SUB_ID_REASON =
- "Wifi network was carrier merged but had invalid sub ID"
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/demo/DemoWifiRepository.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/demo/DemoWifiRepository.kt
index 7163e67eaa5d..f4bb1a34b05f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/demo/DemoWifiRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/demo/DemoWifiRepository.kt
@@ -46,7 +46,7 @@ constructor(
private val _isWifiDefault = MutableStateFlow(false)
override val isWifiDefault: StateFlow<Boolean> = _isWifiDefault
- private val _wifiNetwork = MutableStateFlow<WifiNetworkModel>(WifiNetworkModel.Inactive)
+ private val _wifiNetwork = MutableStateFlow<WifiNetworkModel>(WifiNetworkModel.Inactive())
override val wifiNetwork: StateFlow<WifiNetworkModel> = _wifiNetwork
private val _secondaryNetworks = MutableStateFlow<List<WifiNetworkModel>>(emptyList())
@@ -82,7 +82,7 @@ constructor(
_isWifiEnabled.value = false
_isWifiDefault.value = false
_wifiActivity.value = DataActivityModel(hasActivityIn = false, hasActivityOut = false)
- _wifiNetwork.value = WifiNetworkModel.Inactive
+ _wifiNetwork.value = WifiNetworkModel.Inactive()
}
private fun processEnabledWifiState(event: FakeWifiEventModel.Wifi) {
@@ -100,7 +100,7 @@ constructor(
}
private fun FakeWifiEventModel.Wifi.toWifiNetworkModel(): WifiNetworkModel =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
isValidated = validated ?: true,
level = level ?: 0,
ssid = ssid ?: DEMO_NET_SSID,
@@ -108,7 +108,7 @@ constructor(
)
private fun FakeWifiEventModel.CarrierMerged.toCarrierMergedModel(): WifiNetworkModel =
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = subscriptionId,
level = level,
numberOfLevels = numberOfLevels,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImpl.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImpl.kt
index b6e73e0f4b9e..76024cd565d1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImpl.kt
@@ -19,7 +19,6 @@ package com.android.systemui.statusbar.pipeline.wifi.data.repository.prod
import android.annotation.SuppressLint
import android.net.wifi.ScanResult
import android.net.wifi.WifiManager
-import android.telephony.SubscriptionManager.INVALID_SUBSCRIPTION_ID
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.LifecycleOwner
import androidx.lifecycle.LifecycleRegistry
@@ -39,18 +38,14 @@ import com.android.systemui.statusbar.pipeline.dagger.WifiTableLog
import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel
import com.android.systemui.statusbar.pipeline.shared.data.model.toWifiDataActivityModel
import com.android.systemui.statusbar.pipeline.wifi.data.repository.RealWifiRepository
-import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepository.Companion.CARRIER_MERGED_INVALID_SUB_ID_REASON
import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepository.Companion.COL_NAME_IS_DEFAULT
import com.android.systemui.statusbar.pipeline.wifi.data.repository.WifiRepository.Companion.COL_NAME_IS_ENABLED
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel
-import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel.Inactive.toHotspotDeviceType
+import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel.Unavailable.toHotspotDeviceType
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiScanEntry
import com.android.wifitrackerlib.HotspotNetworkEntry
import com.android.wifitrackerlib.MergedCarrierEntry
import com.android.wifitrackerlib.WifiEntry
-import com.android.wifitrackerlib.WifiEntry.WIFI_LEVEL_MAX
-import com.android.wifitrackerlib.WifiEntry.WIFI_LEVEL_MIN
-import com.android.wifitrackerlib.WifiEntry.WIFI_LEVEL_UNREACHABLE
import com.android.wifitrackerlib.WifiPickerTracker
import java.util.concurrent.Executor
import javax.inject.Inject
@@ -246,36 +241,28 @@ constructor(
}
private fun MergedCarrierEntry.convertCarrierMergedToModel(): WifiNetworkModel {
- return if (this.subscriptionId == INVALID_SUBSCRIPTION_ID) {
- WifiNetworkModel.Invalid(CARRIER_MERGED_INVALID_SUB_ID_REASON)
- } else {
- WifiNetworkModel.CarrierMerged(
- subscriptionId = this.subscriptionId,
- level = this.level,
- // WifiManager APIs to calculate the signal level start from 0, so
- // maxSignalLevel + 1 represents the total level buckets count.
- numberOfLevels = wifiManager.maxSignalLevel + 1,
- )
- }
+ // WifiEntry instance values aren't guaranteed to be stable between method calls
+ // because
+ // WifiPickerTracker is continuously updating the same object. Save the level in a
+ // local
+ // variable so that checking the level validity here guarantees that the level will
+ // still be
+ // valid when we create the `WifiNetworkModel.Active` instance later. Otherwise, the
+ // level
+ // could be valid here but become invalid later, and `WifiNetworkModel.Active` will
+ // throw
+ // an exception. See b/362384551.
+
+ return WifiNetworkModel.CarrierMerged.of(
+ subscriptionId = this.subscriptionId,
+ level = this.level,
+ // WifiManager APIs to calculate the signal level start from 0, so
+ // maxSignalLevel + 1 represents the total level buckets count.
+ numberOfLevels = wifiManager.maxSignalLevel + 1,
+ )
}
private fun WifiEntry.convertNormalToModel(): WifiNetworkModel {
- // WifiEntry instance values aren't guaranteed to be stable between method calls because
- // WifiPickerTracker is continuously updating the same object. Save the level in a local
- // variable so that checking the level validity here guarantees that the level will still be
- // valid when we create the `WifiNetworkModel.Active` instance later. Otherwise, the level
- // could be valid here but become invalid later, and `WifiNetworkModel.Active` will throw
- // an exception. See b/362384551.
- val currentLevel = this.level
- if (
- currentLevel == WIFI_LEVEL_UNREACHABLE ||
- currentLevel !in WIFI_LEVEL_MIN..WIFI_LEVEL_MAX
- ) {
- // If our level means the network is unreachable or the level is otherwise invalid, we
- // don't have an active network.
- return WifiNetworkModel.Inactive
- }
-
val hotspotDeviceType =
if (this is HotspotNetworkEntry) {
this.deviceType.toHotspotDeviceType()
@@ -283,9 +270,9 @@ constructor(
WifiNetworkModel.HotspotDeviceType.NONE
}
- return WifiNetworkModel.Active(
+ return WifiNetworkModel.Active.of(
isValidated = this.hasInternetAccess(),
- level = currentLevel,
+ level = this.level,
ssid = this.title,
hotspotDeviceType = hotspotDeviceType,
)
@@ -421,7 +408,7 @@ constructor(
companion object {
// Start out with no known wifi network.
- @VisibleForTesting val WIFI_NETWORK_DEFAULT = WifiNetworkModel.Inactive
+ @VisibleForTesting val WIFI_NETWORK_DEFAULT = WifiNetworkModel.Inactive()
private const val WIFI_STATE_DEFAULT = WifiManager.WIFI_STATE_DISABLED
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/shared/model/WifiNetworkModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/shared/model/WifiNetworkModel.kt
index 39842fb39e24..32203774afd1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/shared/model/WifiNetworkModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/wifi/shared/model/WifiNetworkModel.kt
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar.pipeline.wifi.shared.model
+import android.net.wifi.WifiManager
import android.net.wifi.WifiManager.UNKNOWN_SSID
import android.net.wifi.sharedconnectivity.app.NetworkProviderInfo
import android.telephony.SubscriptionManager
@@ -23,8 +24,12 @@ import androidx.annotation.VisibleForTesting
import com.android.systemui.log.table.Diffable
import com.android.systemui.log.table.TableRowLogger
import com.android.systemui.statusbar.pipeline.mobile.data.repository.MobileConnectionRepository
+import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel.Active.Companion.MAX_VALID_LEVEL
+import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel.Active.Companion.isValid
+import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel.Active.Companion.of
import com.android.wifitrackerlib.HotspotNetworkEntry.DeviceType
import com.android.wifitrackerlib.WifiEntry
+import com.android.wifitrackerlib.WifiEntry.WIFI_LEVEL_UNREACHABLE
/** Provides information about the current wifi network. */
sealed class WifiNetworkModel : Diffable<WifiNetworkModel> {
@@ -64,7 +69,7 @@ sealed class WifiNetworkModel : Diffable<WifiNetworkModel> {
/** A description of why the wifi information was invalid. */
val invalidReason: String,
) : WifiNetworkModel() {
- override fun toString() = "WifiNetwork.Invalid[$invalidReason]"
+ override fun toString() = "WifiNetwork.Invalid[reason=$invalidReason]"
override fun logDiffs(prevVal: WifiNetworkModel, row: TableRowLogger) {
if (prevVal !is Invalid) {
@@ -73,12 +78,12 @@ sealed class WifiNetworkModel : Diffable<WifiNetworkModel> {
}
if (invalidReason != prevVal.invalidReason) {
- row.logChange(COL_NETWORK_TYPE, "$TYPE_UNAVAILABLE $invalidReason")
+ row.logChange(COL_NETWORK_TYPE, "$TYPE_UNAVAILABLE[reason=$invalidReason]")
}
}
override fun logFull(row: TableRowLogger) {
- row.logChange(COL_NETWORK_TYPE, "$TYPE_UNAVAILABLE $invalidReason")
+ row.logChange(COL_NETWORK_TYPE, "$TYPE_UNAVAILABLE[reason=$invalidReason]")
row.logChange(COL_SUB_ID, SUB_ID_DEFAULT)
row.logChange(COL_VALIDATED, false)
row.logChange(COL_LEVEL, LEVEL_DEFAULT)
@@ -89,20 +94,25 @@ sealed class WifiNetworkModel : Diffable<WifiNetworkModel> {
}
/** A model representing that we have no active wifi network. */
- object Inactive : WifiNetworkModel() {
- override fun toString() = "WifiNetwork.Inactive"
+ data class Inactive(
+ /** An optional description of why the wifi information was inactive. */
+ val inactiveReason: String? = null,
+ ) : WifiNetworkModel() {
+ override fun toString() = "WifiNetwork.Inactive[reason=$inactiveReason]"
override fun logDiffs(prevVal: WifiNetworkModel, row: TableRowLogger) {
- if (prevVal is Inactive) {
+ if (prevVal !is Inactive) {
+ logFull(row)
return
}
- // When changing to Inactive, we need to log diffs to all the fields.
- logFull(row)
+ if (inactiveReason != prevVal.inactiveReason) {
+ row.logChange(COL_NETWORK_TYPE, "$TYPE_INACTIVE[reason=$inactiveReason]")
+ }
}
override fun logFull(row: TableRowLogger) {
- row.logChange(COL_NETWORK_TYPE, TYPE_INACTIVE)
+ row.logChange(COL_NETWORK_TYPE, "$TYPE_INACTIVE[reason=$inactiveReason]")
row.logChange(COL_SUB_ID, SUB_ID_DEFAULT)
row.logChange(COL_VALIDATED, false)
row.logChange(COL_LEVEL, LEVEL_DEFAULT)
@@ -117,31 +127,71 @@ sealed class WifiNetworkModel : Diffable<WifiNetworkModel> {
* treated as more of a mobile network.
*
* See [android.net.wifi.WifiInfo.isCarrierMerged] for more information.
+ *
+ * IMPORTANT: Do *not* call [copy] on this class. Instead, use the factory [of] methods. [of]
+ * will verify preconditions correctly.
*/
- data class CarrierMerged(
+ data class CarrierMerged
+ private constructor(
/**
* The subscription ID that this connection represents.
*
* Comes from [android.net.wifi.WifiInfo.getSubscriptionId].
*
- * Per that method, this value must not be [INVALID_SUBSCRIPTION_ID] (if it was invalid,
- * then this is *not* a carrier merged network).
+ * Per that method, this value must not be [SubscriptionManager.INVALID_SUBSCRIPTION_ID] (if
+ * it was invalid, then this is *not* a carrier merged network).
*/
val subscriptionId: Int,
- /** The signal level, guaranteed to be 0 <= level <= numberOfLevels. */
+ /** The signal level, required to be 0 <= level <= numberOfLevels. */
val level: Int,
/** The maximum possible level. */
- val numberOfLevels: Int = MobileConnectionRepository.DEFAULT_NUM_LEVELS,
+ val numberOfLevels: Int,
) : WifiNetworkModel() {
- init {
- require(level in MIN_VALID_LEVEL..numberOfLevels) {
- "CarrierMerged: $MIN_VALID_LEVEL <= wifi level <= $numberOfLevels required; " +
+ companion object {
+ /**
+ * Creates a [CarrierMerged] instance, or an [Invalid] instance if any of the arguments
+ * are invalid.
+ */
+ fun of(
+ subscriptionId: Int,
+ level: Int,
+ numberOfLevels: Int = MobileConnectionRepository.DEFAULT_NUM_LEVELS
+ ): WifiNetworkModel {
+ if (!subscriptionId.isSubscriptionIdValid()) {
+ return Invalid(INVALID_SUB_ID_ERROR_STRING)
+ }
+ if (!level.isLevelValid(numberOfLevels)) {
+ return Invalid(getInvalidLevelErrorString(level, numberOfLevels))
+ }
+ return CarrierMerged(subscriptionId, level, numberOfLevels)
+ }
+
+ private fun Int.isLevelValid(maxLevel: Int): Boolean {
+ return this != WIFI_LEVEL_UNREACHABLE && this in MIN_VALID_LEVEL..maxLevel
+ }
+
+ private fun getInvalidLevelErrorString(level: Int, maxLevel: Int): String {
+ return "Wifi network was carrier merged but had invalid level. " +
+ "$MIN_VALID_LEVEL <= wifi level <= $maxLevel required; " +
"level was $level"
}
- require(subscriptionId != SubscriptionManager.INVALID_SUBSCRIPTION_ID) {
- "subscription ID cannot be invalid"
+
+ private fun Int.isSubscriptionIdValid(): Boolean {
+ return this != SubscriptionManager.INVALID_SUBSCRIPTION_ID
+ }
+
+ private const val INVALID_SUB_ID_ERROR_STRING =
+ "Wifi network was carrier merged but had invalid sub ID"
+ }
+
+ init {
+ require(level.isLevelValid(numberOfLevels)) {
+ "${getInvalidLevelErrorString(level, numberOfLevels)}. $DO_NOT_USE_COPY_ERROR"
+ }
+ require(subscriptionId.isSubscriptionIdValid()) {
+ "$INVALID_SUB_ID_ERROR_STRING. $DO_NOT_USE_COPY_ERROR"
}
}
@@ -173,28 +223,64 @@ sealed class WifiNetworkModel : Diffable<WifiNetworkModel> {
}
}
- /** Provides information about an active wifi network. */
- data class Active(
+ /**
+ * Provides information about an active wifi network.
+ *
+ * IMPORTANT: Do *not* call [copy] on this class. Instead, use the factory [of] method. [of]
+ * will verify preconditions correctly.
+ */
+ data class Active
+ private constructor(
/** See [android.net.NetworkCapabilities.NET_CAPABILITY_VALIDATED]. */
- val isValidated: Boolean = false,
+ val isValidated: Boolean,
- /** The wifi signal level, guaranteed to be 0 <= level <= 4. */
+ /** The wifi signal level, required to be 0 <= level <= 4. */
val level: Int,
/** See [android.net.wifi.WifiInfo.ssid]. */
- val ssid: String? = null,
+ val ssid: String?,
/**
* The type of device providing a hotspot connection, or [HotspotDeviceType.NONE] if this
* isn't a hotspot connection.
*/
- val hotspotDeviceType: HotspotDeviceType = WifiNetworkModel.HotspotDeviceType.NONE,
+ val hotspotDeviceType: HotspotDeviceType,
) : WifiNetworkModel() {
- init {
- require(level in MIN_VALID_LEVEL..MAX_VALID_LEVEL) {
- "Active: $MIN_VALID_LEVEL <= wifi level <= $MAX_VALID_LEVEL required; " +
+ companion object {
+ /**
+ * Creates an [Active] instance, or an [Inactive] instance if any of the arguments are
+ * invalid.
+ */
+ @JvmStatic
+ fun of(
+ isValidated: Boolean = false,
+ level: Int,
+ ssid: String? = null,
+ hotspotDeviceType: HotspotDeviceType = HotspotDeviceType.NONE,
+ ): WifiNetworkModel {
+ if (!level.isValid()) {
+ return Inactive(getInvalidLevelErrorString(level))
+ }
+ return Active(isValidated, level, ssid, hotspotDeviceType)
+ }
+
+ private fun Int.isValid(): Boolean {
+ return this != WIFI_LEVEL_UNREACHABLE && this in MIN_VALID_LEVEL..MAX_VALID_LEVEL
+ }
+
+ private fun getInvalidLevelErrorString(level: Int): String {
+ return "Wifi network was active but had invalid level. " +
+ "$MIN_VALID_LEVEL <= wifi level <= $MAX_VALID_LEVEL required; " +
"level was $level"
}
+
+ @VisibleForTesting internal const val MAX_VALID_LEVEL = WifiEntry.WIFI_LEVEL_MAX
+ }
+
+ init {
+ require(level.isValid()) {
+ "${getInvalidLevelErrorString(level)}. $DO_NOT_USE_COPY_ERROR"
+ }
}
/** Returns true if this network has a valid SSID and false otherwise. */
@@ -231,10 +317,6 @@ sealed class WifiNetworkModel : Diffable<WifiNetworkModel> {
row.logChange(COL_SSID, ssid)
row.logChange(COL_HOTSPOT, hotspotDeviceType.name)
}
-
- companion object {
- @VisibleForTesting internal const val MAX_VALID_LEVEL = WifiEntry.WIFI_LEVEL_MAX
- }
}
companion object {
@@ -292,3 +374,7 @@ const val COL_HOTSPOT = "hotspot"
val LEVEL_DEFAULT: String? = null
val NUM_LEVELS_DEFAULT: String? = null
val SUB_ID_DEFAULT: String? = null
+
+private const val DO_NOT_USE_COPY_ERROR =
+ "This should only be an issue if the caller incorrectly used `copy` to get a new instance. " +
+ "Please use the `of` method instead."
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/PolicyModule.kt b/packages/SystemUI/src/com/android/systemui/statusbar/policy/PolicyModule.kt
index 591d7af44db1..cf9f9f4a2a81 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/PolicyModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/PolicyModule.kt
@@ -23,6 +23,7 @@ import android.os.UserManager.DISALLOW_SHARE_LOCATION
import com.android.systemui.Flags
import com.android.systemui.qs.QsEventLogger
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tileimpl.QSTileImpl
import com.android.systemui.qs.tiles.AlarmTile
import com.android.systemui.qs.tiles.CameraToggleTile
@@ -157,6 +158,7 @@ interface PolicyModule {
labelRes = R.string.quick_settings_flashlight_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.UTILITIES,
)
/** Inject FlashlightTile into tileViewModelMap in QSModule */
@@ -192,7 +194,8 @@ interface PolicyModule {
policy =
QSTilePolicy.Restricted(
listOf(DISALLOW_SHARE_LOCATION, DISALLOW_CONFIG_LOCATION)
- )
+ ),
+ category = TileCategory.PRIVACY,
)
/** Inject LocationTile into tileViewModelMap in QSModule */
@@ -225,6 +228,7 @@ interface PolicyModule {
labelRes = R.string.status_bar_alarm,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.UTILITIES,
)
/** Inject AlarmTile into tileViewModelMap in QSModule */
@@ -257,6 +261,7 @@ interface PolicyModule {
labelRes = R.string.quick_settings_ui_mode_night_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.DISPLAY,
)
/** Inject uimodenight into tileViewModelMap in QSModule */
@@ -290,6 +295,7 @@ interface PolicyModule {
),
instanceId = uiEventLogger.getNewInstanceId(),
autoRemoveOnUnavailable = false,
+ category = TileCategory.PRIVACY,
)
/** Inject work mode into tileViewModelMap in QSModule */
@@ -323,6 +329,7 @@ interface PolicyModule {
),
instanceId = uiEventLogger.getNewInstanceId(),
policy = QSTilePolicy.Restricted(listOf(DISALLOW_CAMERA_TOGGLE)),
+ category = TileCategory.PRIVACY,
)
/** Inject camera toggle tile into tileViewModelMap in QSModule */
@@ -365,6 +372,7 @@ interface PolicyModule {
),
instanceId = uiEventLogger.getNewInstanceId(),
policy = QSTilePolicy.Restricted(listOf(DISALLOW_MICROPHONE_TOGGLE)),
+ category = TileCategory.PRIVACY,
)
/** Inject microphone toggle tile into tileViewModelMap in QSModule */
@@ -407,6 +415,7 @@ interface PolicyModule {
labelRes = R.string.quick_settings_modes_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.CONNECTIVITY,
)
} else {
QSTileConfig(
@@ -417,6 +426,7 @@ interface PolicyModule {
labelRes = R.string.quick_settings_dnd_label,
),
instanceId = uiEventLogger.getNewInstanceId(),
+ category = TileCategory.CONNECTIVITY,
)
}
diff --git a/packages/SystemUI/src/com/android/systemui/wallet/dagger/WalletModule.java b/packages/SystemUI/src/com/android/systemui/wallet/dagger/WalletModule.java
index ea213cba9567..dd1c11d11d1e 100644
--- a/packages/SystemUI/src/com/android/systemui/wallet/dagger/WalletModule.java
+++ b/packages/SystemUI/src/com/android/systemui/wallet/dagger/WalletModule.java
@@ -25,6 +25,7 @@ import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Background;
import com.android.systemui.qs.QsEventLogger;
import com.android.systemui.qs.pipeline.shared.TileSpec;
+import com.android.systemui.qs.shared.model.TileCategory;
import com.android.systemui.qs.tileimpl.QSTileImpl;
import com.android.systemui.qs.tiles.QuickAccessWalletTile;
import com.android.systemui.qs.tiles.viewmodel.QSTileConfig;
@@ -34,8 +35,6 @@ import com.android.systemui.res.R;
import com.android.systemui.wallet.controller.WalletContextualLocationsService;
import com.android.systemui.wallet.ui.WalletActivity;
-import java.util.concurrent.Executor;
-
import dagger.Binds;
import dagger.Module;
import dagger.Provides;
@@ -43,6 +42,8 @@ import dagger.multibindings.ClassKey;
import dagger.multibindings.IntoMap;
import dagger.multibindings.StringKey;
+import java.util.concurrent.Executor;
+
/**
* Module for injecting classes in Wallet.
*/
@@ -90,6 +91,7 @@ public abstract class WalletModule {
R.string.wallet_title
),
uiEventLogger.getNewInstanceId(),
+ TileCategory.UTILITIES,
tileSpec.getSpec(),
QSTilePolicy.NoRestrictions.INSTANCE
);
diff --git a/packages/SystemUI/tests/goldens/bouncerPredictiveBackMotion.json b/packages/SystemUI/tests/goldens/bouncerPredictiveBackMotion.json
new file mode 100644
index 000000000000..f37580dd47d4
--- /dev/null
+++ b/packages/SystemUI/tests/goldens/bouncerPredictiveBackMotion.json
@@ -0,0 +1,831 @@
+{
+ "frame_ids": [
+ "before",
+ 0,
+ 16,
+ 32,
+ 48,
+ 64,
+ 80,
+ 96,
+ 112,
+ 128,
+ 144,
+ 160,
+ 176,
+ 192,
+ 208,
+ 224,
+ 240,
+ 256,
+ 272,
+ 288,
+ 304,
+ 320,
+ 336,
+ 352,
+ 368,
+ 384,
+ 400,
+ 416,
+ 432,
+ 448,
+ 464,
+ 480,
+ 496,
+ 512,
+ 528,
+ 544,
+ 560,
+ 576,
+ 592,
+ 608,
+ 624,
+ 640,
+ 656,
+ 672,
+ 688,
+ 704,
+ 720,
+ 736,
+ 752,
+ 768,
+ 784,
+ 800,
+ 816,
+ 832,
+ 848,
+ 864,
+ 880,
+ 896,
+ 912,
+ 928,
+ 944,
+ 960,
+ 976,
+ 992,
+ 1008,
+ 1024,
+ "after"
+ ],
+ "features": [
+ {
+ "name": "content_alpha",
+ "type": "float",
+ "data_points": [
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 0.9954499,
+ 0.9805035,
+ 0.9527822,
+ 0.9092045,
+ 0.84588075,
+ 0.7583043,
+ 0.6424476,
+ 0.49766344,
+ 0.33080608,
+ 0.15650165,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ 0,
+ {
+ "type": "not_found"
+ }
+ ]
+ },
+ {
+ "name": "content_scale",
+ "type": "scale",
+ "data_points": [
+ "default",
+ {
+ "x": 0.9995097,
+ "y": 0.9995097,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.997352,
+ "y": 0.997352,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.990635,
+ "y": 0.990635,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.97249764,
+ "y": 0.97249764,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.94287145,
+ "y": 0.94287145,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.9128026,
+ "y": 0.9128026,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8859569,
+ "y": 0.8859569,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8629254,
+ "y": 0.8629254,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8442908,
+ "y": 0.8442908,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8303209,
+ "y": 0.8303209,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8205137,
+ "y": 0.8205137,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.81387186,
+ "y": 0.81387186,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.80941653,
+ "y": 0.80941653,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.80641484,
+ "y": 0.80641484,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.80437464,
+ "y": 0.80437464,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.80297637,
+ "y": 0.80297637,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.80201286,
+ "y": 0.80201286,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8013477,
+ "y": 0.8013477,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8008894,
+ "y": 0.8008894,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8005756,
+ "y": 0.8005756,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.80036324,
+ "y": 0.80036324,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8002219,
+ "y": 0.8002219,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.80012995,
+ "y": 0.80012995,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8000721,
+ "y": 0.8000721,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.80003715,
+ "y": 0.80003715,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8000173,
+ "y": 0.8000173,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.800007,
+ "y": 0.800007,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8000022,
+ "y": 0.8000022,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8000004,
+ "y": 0.8000004,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.79999995,
+ "y": 0.79999995,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "x": 0.8,
+ "y": 0.8,
+ "pivot": "unspecified"
+ },
+ {
+ "type": "not_found"
+ }
+ ]
+ },
+ {
+ "name": "content_offset",
+ "type": "dpOffset",
+ "data_points": [
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "x": 0,
+ "y": 0.5714286
+ },
+ {
+ "x": 0,
+ "y": 2.857143
+ },
+ {
+ "x": 0,
+ "y": 7.142857
+ },
+ {
+ "x": 0,
+ "y": 13.714286
+ },
+ {
+ "x": 0,
+ "y": 23.142857
+ },
+ {
+ "x": 0,
+ "y": 36.285713
+ },
+ {
+ "x": 0,
+ "y": 53.714287
+ },
+ {
+ "x": 0,
+ "y": 75.42857
+ },
+ {
+ "x": 0,
+ "y": 100.28571
+ },
+ {
+ "x": 0,
+ "y": 126.57143
+ },
+ {
+ "x": 0,
+ "y": 151.42857
+ },
+ {
+ "x": 0,
+ "y": 174
+ },
+ {
+ "x": 0,
+ "y": 193.42857
+ },
+ {
+ "x": 0,
+ "y": 210.28572
+ },
+ {
+ "x": 0,
+ "y": 224.85715
+ },
+ {
+ "x": 0,
+ "y": 237.14285
+ },
+ {
+ "x": 0,
+ "y": 247.71428
+ },
+ {
+ "x": 0,
+ "y": 256.85715
+ },
+ {
+ "x": 0,
+ "y": 264.57144
+ },
+ {
+ "x": 0,
+ "y": 271.42856
+ },
+ {
+ "x": 0,
+ "y": 277.14285
+ },
+ {
+ "x": 0,
+ "y": 282
+ },
+ {
+ "x": 0,
+ "y": 286.2857
+ },
+ {
+ "x": 0,
+ "y": 289.7143
+ },
+ {
+ "x": 0,
+ "y": 292.57144
+ },
+ {
+ "x": 0,
+ "y": 294.85715
+ },
+ {
+ "x": 0,
+ "y": 296.85715
+ },
+ {
+ "x": 0,
+ "y": 298.2857
+ },
+ {
+ "x": 0,
+ "y": 299.14285
+ },
+ {
+ "x": 0,
+ "y": 299.7143
+ },
+ {
+ "x": 0,
+ "y": 300
+ },
+ {
+ "x": 0,
+ "y": 0
+ },
+ {
+ "type": "not_found"
+ }
+ ]
+ },
+ {
+ "name": "background_alpha",
+ "type": "float",
+ "data_points": [
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 1,
+ 0.9900334,
+ 0.8403853,
+ 0.71002257,
+ 0.5979084,
+ 0.50182605,
+ 0.41945767,
+ 0.34874845,
+ 0.28797746,
+ 0.23573697,
+ 0.19087732,
+ 0.1524564,
+ 0.11970067,
+ 0.091962695,
+ 0.068702936,
+ 0.049464583,
+ 0.033859253,
+ 0.021552086,
+ 0.012255073,
+ 0.005717635,
+ 0.0017191172,
+ 6.711483e-05,
+ 0,
+ {
+ "type": "not_found"
+ }
+ ]
+ }
+ ]
+} \ No newline at end of file
diff --git a/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextManagerTest.java b/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextManagerTest.java
index d85b77413338..bf13ceb5666a 100644
--- a/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/keyguard/CarrierTextManagerTest.java
@@ -445,7 +445,7 @@ public class CarrierTextManagerTest extends SysuiTestCase {
assertFalse(mWifiRepository.isWifiConnectedWithValidSsid());
mWifiRepository.setWifiNetwork(
- new WifiNetworkModel.Active(
+ WifiNetworkModel.Active.Companion.of(
/* isValidated= */ false,
/* level= */ 0,
/* ssid= */ "",
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityButtonModeObserverTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityButtonModeObserverTest.java
index 4a5c1bed7b44..038ec406c3d1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityButtonModeObserverTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityButtonModeObserverTest.java
@@ -32,12 +32,14 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.settings.UserTracker;
+import com.android.systemui.util.settings.SecureSettings;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -66,7 +68,7 @@ public class AccessibilityButtonModeObserverTest extends SysuiTestCase {
Settings.Secure.ACCESSIBILITY_BUTTON_MODE,
Settings.Secure.ACCESSIBILITY_BUTTON_MODE_NAVIGATION_BAR, MY_USER_ID);
mAccessibilityButtonModeObserver = new AccessibilityButtonModeObserver(mContext,
- mUserTracker);
+ mUserTracker, Mockito.mock(SecureSettings.class));
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityButtonTargetsObserverTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityButtonTargetsObserverTest.java
index a5a7a4a09227..f5649266d0a9 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityButtonTargetsObserverTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityButtonTargetsObserverTest.java
@@ -31,12 +31,14 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.settings.UserTracker;
+import com.android.systemui.util.settings.SecureSettings;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -62,7 +64,7 @@ public class AccessibilityButtonTargetsObserverTest extends SysuiTestCase {
public void setUp() {
when(mUserTracker.getUserId()).thenReturn(MY_USER_ID);
mAccessibilityButtonTargetsObserver = new AccessibilityButtonTargetsObserver(mContext,
- mUserTracker);
+ mUserTracker, Mockito.mock(SecureSettings.class));
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityGestureTargetsObserverTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityGestureTargetsObserverTest.java
index ba990efd5162..afed12fb700b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityGestureTargetsObserverTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/AccessibilityGestureTargetsObserverTest.java
@@ -31,12 +31,14 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.settings.UserTracker;
+import com.android.systemui.util.settings.SecureSettings;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mock;
+import org.mockito.Mockito;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -62,7 +64,7 @@ public class AccessibilityGestureTargetsObserverTest extends SysuiTestCase {
public void setUp() {
when(mUserTracker.getUserId()).thenReturn(MY_USER_ID);
mAccessibilityGestureTargetsObserver = new AccessibilityGestureTargetsObserver(mContext,
- mUserTracker);
+ mUserTracker, Mockito.mock(SecureSettings.class));
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/SecureSettingsContentObserverTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/SecureSettingsContentObserverTest.java
index 9222fc2222be..1d88b904668c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/SecureSettingsContentObserverTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/SecureSettingsContentObserverTest.java
@@ -27,6 +27,7 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.settings.UserTracker;
+import com.android.systemui.util.settings.SecureSettings;
import org.junit.Before;
import org.junit.Test;
@@ -72,7 +73,7 @@ public class SecureSettingsContentObserverTest extends SysuiTestCase {
protected FakeSecureSettingsContentObserver(Context context, UserTracker userTracker,
String secureSettingsKey) {
- super(context, userTracker, secureSettingsKey);
+ super(context, userTracker, Mockito.mock(SecureSettings.class), secureSettingsKey);
}
@Override
diff --git a/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt
index 55fd3440ea07..48505102eba5 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/biometrics/ui/viewmodel/PromptViewModelTest.kt
@@ -54,6 +54,7 @@ import com.android.systemui.biometrics.data.repository.biometricStatusRepository
import com.android.systemui.biometrics.data.repository.fakeFingerprintPropertyRepository
import com.android.systemui.biometrics.domain.interactor.PromptSelectorInteractor
import com.android.systemui.biometrics.domain.interactor.promptSelectorInteractor
+import com.android.systemui.biometrics.domain.interactor.sideFpsOverlayInteractor
import com.android.systemui.biometrics.domain.interactor.udfpsOverlayInteractor
import com.android.systemui.biometrics.extractAuthenticatorTypes
import com.android.systemui.biometrics.faceSensorPropertiesInternal
@@ -1453,11 +1454,15 @@ internal class PromptViewModelTest(private val testCase: TestCase) : SysuiTestCa
@Test
fun switch_to_credential_fallback() = runGenericTest {
val size by collectLastValue(kosmos.promptViewModel.size)
+ val isShowingSfpsIndicator by collectLastValue(kosmos.sideFpsOverlayInteractor.isShowing)
// TODO(b/251476085): remove Spaghetti, migrate logic, and update this test
kosmos.promptViewModel.onSwitchToCredential()
assertThat(size).isEqualTo(PromptSize.LARGE)
+ if (testCase.modalities.hasSfps) {
+ assertThat(isShowingSfpsIndicator).isFalse()
+ }
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/composable/BouncerPredictiveBackTest.kt b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/composable/BouncerPredictiveBackTest.kt
new file mode 100644
index 000000000000..22946c8e6ad0
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/bouncer/ui/composable/BouncerPredictiveBackTest.kt
@@ -0,0 +1,348 @@
+/*
+ * Copyright (C) 2024 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.bouncer.ui.composable
+
+import android.app.AlertDialog
+import android.platform.test.annotations.MotionTest
+import android.testing.TestableLooper.RunWithLooper
+import androidx.activity.BackEventCompat
+import androidx.compose.animation.core.Animatable
+import androidx.compose.animation.core.tween
+import androidx.compose.foundation.layout.Box
+import androidx.compose.material3.Text
+import androidx.compose.runtime.Composable
+import androidx.compose.runtime.LaunchedEffect
+import androidx.compose.runtime.remember
+import androidx.compose.ui.Alignment
+import androidx.compose.ui.Modifier
+import androidx.compose.ui.geometry.Offset
+import androidx.compose.ui.geometry.isFinite
+import androidx.compose.ui.geometry.isUnspecified
+import androidx.compose.ui.semantics.SemanticsNode
+import androidx.compose.ui.test.junit4.AndroidComposeTestRule
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.LargeTest
+import com.android.compose.animation.scene.ObservableTransitionState
+import com.android.compose.animation.scene.Scale
+import com.android.compose.animation.scene.SceneKey
+import com.android.compose.animation.scene.SceneScope
+import com.android.compose.animation.scene.UserAction
+import com.android.compose.animation.scene.UserActionResult
+import com.android.compose.animation.scene.isElement
+import com.android.compose.animation.scene.testing.lastAlphaForTesting
+import com.android.compose.animation.scene.testing.lastScaleForTesting
+import com.android.compose.theme.PlatformTheme
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.bouncer.domain.interactor.bouncerInteractor
+import com.android.systemui.bouncer.ui.BouncerDialogFactory
+import com.android.systemui.bouncer.ui.viewmodel.BouncerSceneContentViewModel
+import com.android.systemui.bouncer.ui.viewmodel.BouncerUserActionsViewModel
+import com.android.systemui.bouncer.ui.viewmodel.bouncerSceneContentViewModel
+import com.android.systemui.classifier.domain.interactor.falsingInteractor
+import com.android.systemui.flags.EnableSceneContainer
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.Kosmos.Fixture
+import com.android.systemui.lifecycle.ExclusiveActivatable
+import com.android.systemui.lifecycle.rememberViewModel
+import com.android.systemui.motion.createSysUiComposeMotionTestRule
+import com.android.systemui.power.domain.interactor.powerInteractor
+import com.android.systemui.scene.domain.interactor.sceneInteractor
+import com.android.systemui.scene.domain.startable.sceneContainerStartable
+import com.android.systemui.scene.shared.logger.sceneLogger
+import com.android.systemui.scene.shared.model.SceneContainerConfig
+import com.android.systemui.scene.shared.model.Scenes
+import com.android.systemui.scene.shared.model.sceneDataSourceDelegator
+import com.android.systemui.scene.ui.composable.Scene
+import com.android.systemui.scene.ui.composable.SceneContainer
+import com.android.systemui.scene.ui.viewmodel.SceneContainerViewModel
+import com.android.systemui.scene.ui.viewmodel.splitEdgeDetector
+import com.android.systemui.shade.domain.interactor.shadeInteractor
+import com.android.systemui.testKosmos
+import kotlinx.coroutines.awaitCancellation
+import kotlinx.coroutines.flow.Flow
+import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.flowOf
+import org.json.JSONObject
+import org.junit.Before
+import org.junit.Rule
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.MockitoAnnotations
+import platform.test.motion.compose.ComposeFeatureCaptures.positionInRoot
+import platform.test.motion.compose.ComposeRecordingSpec
+import platform.test.motion.compose.MotionControl
+import platform.test.motion.compose.feature
+import platform.test.motion.compose.recordMotion
+import platform.test.motion.compose.runTest
+import platform.test.motion.golden.DataPoint
+import platform.test.motion.golden.DataPointType
+import platform.test.motion.golden.DataPointTypes
+import platform.test.motion.golden.FeatureCapture
+import platform.test.motion.golden.UnknownTypeException
+import platform.test.screenshot.DeviceEmulationSpec
+import platform.test.screenshot.Displays.Phone
+
+/** MotionTest for the Bouncer Predictive Back animation */
+@LargeTest
+@RunWith(AndroidJUnit4::class)
+@RunWithLooper
+@EnableSceneContainer
+@MotionTest
+class BouncerPredictiveBackTest : SysuiTestCase() {
+
+ private val deviceSpec = DeviceEmulationSpec(Phone)
+ private val kosmos = testKosmos()
+
+ @get:Rule val motionTestRule = createSysUiComposeMotionTestRule(kosmos, deviceSpec)
+ private val androidComposeTestRule =
+ motionTestRule.toolkit.composeContentTestRule as AndroidComposeTestRule<*, *>
+
+ private val sceneInteractor by lazy { kosmos.sceneInteractor }
+ private val Kosmos.sceneKeys by Fixture { listOf(Scenes.Lockscreen, Scenes.Bouncer) }
+ private val Kosmos.initialSceneKey by Fixture { Scenes.Bouncer }
+ private val Kosmos.sceneContainerConfig by Fixture {
+ val navigationDistances =
+ mapOf(
+ Scenes.Lockscreen to 1,
+ Scenes.Bouncer to 0,
+ )
+ SceneContainerConfig(sceneKeys, initialSceneKey, emptyList(), navigationDistances)
+ }
+
+ private val transitionState by lazy {
+ MutableStateFlow<ObservableTransitionState>(
+ ObservableTransitionState.Idle(kosmos.sceneContainerConfig.initialSceneKey)
+ )
+ }
+ private val sceneContainerViewModel by lazy {
+ SceneContainerViewModel(
+ sceneInteractor = kosmos.sceneInteractor,
+ falsingInteractor = kosmos.falsingInteractor,
+ powerInteractor = kosmos.powerInteractor,
+ shadeInteractor = kosmos.shadeInteractor,
+ splitEdgeDetector = kosmos.splitEdgeDetector,
+ logger = kosmos.sceneLogger,
+ motionEventHandlerReceiver = {},
+ )
+ .apply { setTransitionState(transitionState) }
+ }
+
+ private val bouncerDialogFactory =
+ object : BouncerDialogFactory {
+ override fun invoke(): AlertDialog {
+ throw AssertionError()
+ }
+ }
+ private val bouncerSceneActionsViewModelFactory =
+ object : BouncerUserActionsViewModel.Factory {
+ override fun create() = BouncerUserActionsViewModel(kosmos.bouncerInteractor)
+ }
+ private lateinit var bouncerSceneContentViewModel: BouncerSceneContentViewModel
+ private val bouncerSceneContentViewModelFactory =
+ object : BouncerSceneContentViewModel.Factory {
+ override fun create() = bouncerSceneContentViewModel
+ }
+ private val bouncerScene =
+ BouncerScene(
+ bouncerSceneActionsViewModelFactory,
+ bouncerSceneContentViewModelFactory,
+ bouncerDialogFactory
+ )
+
+ @Before
+ fun setUp() {
+ MockitoAnnotations.initMocks(this)
+
+ bouncerSceneContentViewModel = kosmos.bouncerSceneContentViewModel
+
+ val startable = kosmos.sceneContainerStartable
+ startable.start()
+ }
+
+ @Test
+ fun bouncerPredictiveBackMotion() =
+ motionTestRule.runTest {
+ val motion =
+ recordMotion(
+ content = { play ->
+ PlatformTheme {
+ BackGestureAnimation(play)
+ SceneContainer(
+ viewModel =
+ rememberViewModel("BouncerPredictiveBackTest") {
+ sceneContainerViewModel
+ },
+ sceneByKey =
+ mapOf(
+ Scenes.Lockscreen to FakeLockscreen(),
+ Scenes.Bouncer to bouncerScene
+ ),
+ initialSceneKey = Scenes.Bouncer,
+ overlayByKey = emptyMap(),
+ dataSourceDelegator = kosmos.sceneDataSourceDelegator
+ )
+ }
+ },
+ ComposeRecordingSpec(
+ MotionControl(
+ delayRecording = {
+ awaitCondition {
+ sceneInteractor.transitionState.value.isTransitioning()
+ }
+ }
+ ) {
+ awaitCondition {
+ sceneInteractor.transitionState.value.isIdle(Scenes.Lockscreen)
+ }
+ }
+ ) {
+ feature(isElement(Bouncer.Elements.Content), elementAlpha, "content_alpha")
+ feature(isElement(Bouncer.Elements.Content), elementScale, "content_scale")
+ feature(
+ isElement(Bouncer.Elements.Content),
+ positionInRoot,
+ "content_offset"
+ )
+ feature(
+ isElement(Bouncer.Elements.Background),
+ elementAlpha,
+ "background_alpha"
+ )
+ }
+ )
+
+ assertThat(motion).timeSeriesMatchesGolden()
+ }
+
+ @Composable
+ private fun BackGestureAnimation(play: Boolean) {
+ val backProgress = remember { Animatable(0f) }
+
+ LaunchedEffect(play) {
+ if (play) {
+ val dispatcher = androidComposeTestRule.activity.onBackPressedDispatcher
+ androidComposeTestRule.runOnUiThread {
+ dispatcher.dispatchOnBackStarted(backEvent())
+ }
+ backProgress.animateTo(
+ targetValue = 1f,
+ animationSpec = tween(durationMillis = 500)
+ ) {
+ androidComposeTestRule.runOnUiThread {
+ dispatcher.dispatchOnBackProgressed(
+ backEvent(progress = backProgress.value)
+ )
+ if (backProgress.value == 1f) {
+ dispatcher.onBackPressed()
+ }
+ }
+ }
+ }
+ }
+ }
+
+ private fun backEvent(progress: Float = 0f): BackEventCompat {
+ return BackEventCompat(
+ touchX = 0f,
+ touchY = 0f,
+ progress = progress,
+ swipeEdge = BackEventCompat.EDGE_LEFT,
+ )
+ }
+
+ private class FakeLockscreen : ExclusiveActivatable(), Scene {
+ override val key: SceneKey = Scenes.Lockscreen
+ override val userActions: Flow<Map<UserAction, UserActionResult>> = flowOf()
+
+ @Composable
+ override fun SceneScope.Content(modifier: Modifier) {
+ Box(modifier = modifier, contentAlignment = Alignment.Center) {
+ Text(text = "Fake Lockscreen")
+ }
+ }
+
+ override suspend fun onActivated() = awaitCancellation()
+ }
+
+ companion object {
+ private val elementAlpha =
+ FeatureCapture<SemanticsNode, Float>("alpha") {
+ DataPoint.of(it.lastAlphaForTesting, DataPointTypes.float)
+ }
+
+ private val elementScale =
+ FeatureCapture<SemanticsNode, Scale>("scale") {
+ DataPoint.of(it.lastScaleForTesting, scale)
+ }
+
+ private val scale: DataPointType<Scale> =
+ DataPointType(
+ "scale",
+ jsonToValue = {
+ when (it) {
+ "unspecified" -> Scale.Unspecified
+ "default" -> Scale.Default
+ "zero" -> Scale.Zero
+ is JSONObject -> {
+ val pivot = it.get("pivot")
+ Scale(
+ scaleX = it.getDouble("x").toFloat(),
+ scaleY = it.getDouble("y").toFloat(),
+ pivot =
+ when (pivot) {
+ "unspecified" -> Offset.Unspecified
+ "infinite" -> Offset.Infinite
+ is JSONObject ->
+ Offset(
+ pivot.getDouble("x").toFloat(),
+ pivot.getDouble("y").toFloat()
+ )
+ else -> throw UnknownTypeException()
+ }
+ )
+ }
+ else -> throw UnknownTypeException()
+ }
+ },
+ valueToJson = {
+ when (it) {
+ Scale.Unspecified -> "unspecified"
+ Scale.Default -> "default"
+ Scale.Zero -> "zero"
+ else -> {
+ JSONObject().apply {
+ put("x", it.scaleX)
+ put("y", it.scaleY)
+ put(
+ "pivot",
+ when {
+ it.pivot.isUnspecified -> "unspecified"
+ !it.pivot.isFinite -> "infinite"
+ else ->
+ JSONObject().apply {
+ put("x", it.pivot.x)
+ put("y", it.pivot.y)
+ }
+ }
+ )
+ }
+ }
+ }
+ }
+ )
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialCoreStartableTest.kt b/packages/SystemUI/tests/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialCoreStartableTest.kt
new file mode 100644
index 000000000000..9da68853a5aa
--- /dev/null
+++ b/packages/SystemUI/tests/src/com/android/systemui/inputdevice/tutorial/KeyboardTouchpadTutorialCoreStartableTest.kt
@@ -0,0 +1,60 @@
+/*
+ * Copyright (C) 2024 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.inputdevice.tutorial
+
+import android.content.Context
+import android.content.Intent
+import android.os.UserHandle
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.broadcast.broadcastDispatcher
+import com.android.systemui.inputdevice.tutorial.ui.TutorialNotificationCoordinator
+import com.android.systemui.testKosmos
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.kotlin.any
+import org.mockito.kotlin.eq
+import org.mockito.kotlin.mock
+import org.mockito.kotlin.verify
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class KeyboardTouchpadTutorialCoreStartableTest : SysuiTestCase() {
+
+ private val kosmos = testKosmos()
+ private val broadcastDispatcher = kosmos.broadcastDispatcher
+ private val context = mock<Context>()
+ private val underTest =
+ KeyboardTouchpadTutorialCoreStartable(
+ { mock<TutorialNotificationCoordinator>() },
+ broadcastDispatcher,
+ context
+ )
+
+ @Test
+ fun registersBroadcastReceiverStartingActivityAsSystemUser() {
+ underTest.start()
+
+ broadcastDispatcher.sendIntentToMatchingReceiversOnly(
+ context,
+ Intent("com.android.systemui.action.KEYBOARD_TOUCHPAD_TUTORIAL")
+ )
+
+ verify(context).startActivityAsUser(any(), eq(UserHandle.SYSTEM))
+ }
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorTest.kt
index 3cbbb648af94..bea415cbb934 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorTest.kt
@@ -22,8 +22,8 @@ import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.authentication.data.repository.fakeAuthenticationRepository
import com.android.systemui.authentication.shared.model.AuthenticationMethodModel
-import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
import com.android.systemui.bouncer.data.repository.fakeKeyguardBouncerRepository
+import com.android.systemui.bouncer.domain.interactor.alternateBouncerInteractor
import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.deviceentry.domain.interactor.deviceEntryInteractor
import com.android.systemui.flags.EnableSceneContainer
@@ -42,6 +42,7 @@ import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.domain.resolver.notifShadeSceneFamilyResolver
import com.android.systemui.scene.domain.resolver.quickSettingsSceneFamilyResolver
import com.android.systemui.scene.shared.model.Scenes
+import com.android.systemui.shade.domain.interactor.shadeInteractor
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.ExperimentalCoroutinesApi
@@ -77,12 +78,14 @@ class KeyguardDismissActionInteractorTest : SysuiTestCase() {
transitionInteractor = kosmos.keyguardTransitionInteractor,
dismissInteractor = dismissInteractor,
applicationScope = testScope.backgroundScope,
- sceneInteractor = kosmos.sceneInteractor,
- deviceEntryInteractor = kosmos.deviceEntryInteractor,
- quickSettingsSceneFamilyResolver = kosmos.quickSettingsSceneFamilyResolver,
- notifShadeSceneFamilyResolver = kosmos.notifShadeSceneFamilyResolver,
+ sceneInteractor = { kosmos.sceneInteractor },
+ deviceEntryInteractor = { kosmos.deviceEntryInteractor },
+ quickSettingsSceneFamilyResolver = { kosmos.quickSettingsSceneFamilyResolver },
+ notifShadeSceneFamilyResolver = { kosmos.notifShadeSceneFamilyResolver },
powerInteractor = kosmos.powerInteractor,
alternateBouncerInteractor = kosmos.alternateBouncerInteractor,
+ keyguardInteractor = { kosmos.keyguardInteractor },
+ shadeInteractor = { kosmos.shadeInteractor },
)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt
index 3c743744dd58..823a23dec4ea 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/LegacyMediaDataManagerImplTest.kt
@@ -38,6 +38,8 @@ import android.media.session.MediaSession
import android.media.session.PlaybackState
import android.net.Uri
import android.os.Bundle
+import android.platform.test.annotations.DisableFlags
+import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.FlagsParameterization
import android.provider.Settings
import android.service.notification.StatusBarNotification
@@ -61,6 +63,8 @@ import com.android.systemui.kosmos.testDispatcher
import com.android.systemui.kosmos.testScope
import com.android.systemui.media.controls.domain.resume.MediaResumeListener
import com.android.systemui.media.controls.domain.resume.ResumeMediaBrowser
+import com.android.systemui.media.controls.shared.mediaLogger
+import com.android.systemui.media.controls.shared.mockMediaLogger
import com.android.systemui.media.controls.shared.model.EXTRA_KEY_TRIGGER_SOURCE
import com.android.systemui.media.controls.shared.model.EXTRA_VALUE_TRIGGER_PERIODIC
import com.android.systemui.media.controls.shared.model.MediaData
@@ -69,7 +73,6 @@ import com.android.systemui.media.controls.shared.model.SmartspaceMediaDataProvi
import com.android.systemui.media.controls.util.MediaUiEventLogger
import com.android.systemui.media.controls.util.fakeMediaControllerFactory
import com.android.systemui.media.controls.util.mediaFlags
-import com.android.systemui.plugins.activityStarter
import com.android.systemui.res.R
import com.android.systemui.statusbar.SbnBuilder
import com.android.systemui.testKosmos
@@ -186,11 +189,10 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa
mSetFlagsRule.setFlagsParameterization(flags)
}
- private val kosmos = testKosmos()
+ private val kosmos = testKosmos().apply { mediaLogger = mockMediaLogger }
private val testDispatcher = kosmos.testDispatcher
private val testScope = kosmos.testScope
private val fakeFeatureFlags = kosmos.fakeFeatureFlagsClassic
- private val activityStarter = kosmos.activityStarter
private val mediaControllerFactory = kosmos.fakeMediaControllerFactory
private val instanceIdSequence = InstanceIdSequenceFake(1 shl 20)
@@ -240,7 +242,6 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa
mediaDeviceManager = mediaDeviceManager,
mediaDataCombineLatest = mediaDataCombineLatest,
mediaDataFilter = mediaDataFilter,
- activityStarter = activityStarter,
smartspaceMediaDataProvider = smartspaceMediaDataProvider,
useMediaResumption = true,
useQsMediaPlayer = true,
@@ -251,6 +252,7 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa
smartspaceManager = smartspaceManager,
keyguardUpdateMonitor = keyguardUpdateMonitor,
mediaDataLoader = { kosmos.mediaDataLoader },
+ mediaLogger = kosmos.mediaLogger,
)
verify(tunerService)
.addTunable(capture(tunableCaptor), eq(Settings.Secure.MEDIA_CONTROLS_RECOMMENDATION))
@@ -2404,6 +2406,45 @@ class LegacyMediaDataManagerImplTest(flags: FlagsParameterization) : SysuiTestCa
assertThat(mediaDataCaptor.value.artwork).isNull()
}
+ @Test
+ @EnableFlags(Flags.FLAG_MEDIA_CONTROLS_POSTS_OPTIMIZATION)
+ fun postDuplicateNotification_doesNotCallListeners() {
+ addNotificationAndLoad()
+ reset(listener)
+ mediaDataManager.onNotificationAdded(KEY, mediaNotification)
+
+ testScope.assertRunAllReady(foreground = 0, background = 1)
+ verify(listener, never())
+ .onMediaDataLoaded(
+ eq(KEY),
+ eq(KEY),
+ capture(mediaDataCaptor),
+ eq(true),
+ eq(0),
+ eq(false)
+ )
+ verify(kosmos.mediaLogger).logDuplicateMediaNotification(eq(KEY))
+ }
+
+ @Test
+ @DisableFlags(Flags.FLAG_MEDIA_CONTROLS_POSTS_OPTIMIZATION)
+ fun postDuplicateNotification_callsListeners() {
+ addNotificationAndLoad()
+ reset(listener)
+ mediaDataManager.onNotificationAdded(KEY, mediaNotification)
+ testScope.assertRunAllReady(foreground = 1, background = 1)
+ verify(listener)
+ .onMediaDataLoaded(
+ eq(KEY),
+ eq(KEY),
+ capture(mediaDataCaptor),
+ eq(true),
+ eq(0),
+ eq(false)
+ )
+ verify(kosmos.mediaLogger, never()).logDuplicateMediaNotification(eq(KEY))
+ }
+
private fun TestScope.assertRunAllReady(foreground: Int = 0, background: Int = 0) {
runCurrent()
if (Flags.mediaLoadMetadataViaMediaDataLoader()) {
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerTest.kt
index 6a66c4087615..0c8d88065a73 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerTest.kt
@@ -54,6 +54,7 @@ import com.android.systemui.media.muteawait.MediaMuteAwaitConnectionManager
import com.android.systemui.media.muteawait.MediaMuteAwaitConnectionManagerFactory
import com.android.systemui.res.R
import com.android.systemui.statusbar.policy.ConfigurationController
+import com.android.systemui.testKosmos
import com.android.systemui.util.concurrency.FakeExecutor
import com.android.systemui.util.time.FakeSystemClock
import com.google.common.truth.Truth.assertThat
@@ -125,6 +126,8 @@ public class MediaDeviceManagerTest : SysuiTestCase() {
private lateinit var mediaData: MediaData
@JvmField @Rule val mockito = MockitoJUnit.rule()
+ private val kosmos = testKosmos()
+
@Before
fun setUp() {
fakeFgExecutor = FakeExecutor(FakeSystemClock())
@@ -141,6 +144,7 @@ public class MediaDeviceManagerTest : SysuiTestCase() {
{ localBluetoothManager },
fakeFgExecutor,
fakeBgExecutor,
+ kosmos.mediaDeviceLogger,
)
manager.addListener(listener)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/resume/MediaResumeListenerTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/resume/MediaResumeListenerTest.kt
index 02d741385cf9..bc29d2a8ba0d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/resume/MediaResumeListenerTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/domain/resume/MediaResumeListenerTest.kt
@@ -138,6 +138,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
whenever(mockContext.packageManager).thenReturn(context.packageManager)
whenever(mockContext.contentResolver).thenReturn(context.contentResolver)
whenever(mockContext.userId).thenReturn(context.userId)
+ whenever(mockContext.resources).thenReturn(context.resources)
whenever(mediaFlags.isRemoteResumeAllowed()).thenReturn(false)
executor = FakeExecutor(clock)
@@ -210,7 +211,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
@Test
fun testOnLoad_checksForResume_noService() {
// When media data is loaded that has not been checked yet, and does not have a MBS
- resumeListener.onMediaDataLoaded(KEY, null, data)
+ onMediaDataLoaded(KEY, null, data)
// Then we report back to the manager
verify(mediaDataManager).setResumeAction(KEY, null)
@@ -223,8 +224,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
whenever(resumeBrowser.testConnection()).thenAnswer { callbackCaptor.value.onError() }
// When media data is loaded that has not been checked yet, and does not have a MBS
- resumeListener.onMediaDataLoaded(KEY, null, data)
- executor.runAllReady()
+ onMediaDataLoaded(KEY, null, data)
// Then we report back to the manager
verify(mediaDataManager).setResumeAction(eq(KEY), eq(null))
@@ -234,7 +234,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
fun testOnLoad_localCast_doesNotCheck() {
// When media data is loaded that has not been checked yet, and is a local cast
val dataCast = data.copy(playbackLocation = MediaData.PLAYBACK_CAST_LOCAL)
- resumeListener.onMediaDataLoaded(KEY, null, dataCast)
+ onMediaDataLoaded(KEY, null, dataCast, false)
// Then we do not take action
verify(mediaDataManager, never()).setResumeAction(any(), any())
@@ -244,7 +244,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
fun testOnload_remoteCast_doesNotCheck() {
// When media data is loaded that has not been checked yet, and is a remote cast
val dataRcn = data.copy(playbackLocation = MediaData.PLAYBACK_CAST_REMOTE)
- resumeListener.onMediaDataLoaded(KEY, null, dataRcn)
+ onMediaDataLoaded(KEY, null, dataRcn, resume = false)
// Then we do not take action
verify(mediaDataManager, never()).setResumeAction(any(), any())
@@ -257,7 +257,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
// When media data is loaded that has not been checked yet, and is a local cast
val dataCast = data.copy(playbackLocation = MediaData.PLAYBACK_CAST_LOCAL)
- resumeListener.onMediaDataLoaded(KEY, null, dataCast)
+ onMediaDataLoaded(KEY, null, dataCast)
// Then we report back to the manager
verify(mediaDataManager).setResumeAction(KEY, null)
@@ -270,7 +270,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
// When media data is loaded that has not been checked yet, and is a remote cast
val dataRcn = data.copy(playbackLocation = MediaData.PLAYBACK_CAST_REMOTE)
- resumeListener.onMediaDataLoaded(KEY, null, dataRcn)
+ onMediaDataLoaded(KEY, null, dataRcn, false)
// Then we do not take action
verify(mediaDataManager, never()).setResumeAction(any(), any())
@@ -288,10 +288,9 @@ class MediaResumeListenerTest : SysuiTestCase() {
// When media data is loaded that has not been checked yet, and does have a MBS
val dataCopy = data.copy(resumeAction = null, hasCheckedForResume = false)
- resumeListener.onMediaDataLoaded(KEY, null, dataCopy)
+ onMediaDataLoaded(KEY, null, dataCopy)
// Then we test whether the service is valid
- executor.runAllReady()
verify(mediaDataManager).setResumeAction(eq(KEY), eq(null))
verify(resumeBrowser).testConnection()
@@ -307,7 +306,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
fun testOnLoad_doesNotCheckAgain() {
// When a media data is loaded that has been checked already
var dataCopy = data.copy(hasCheckedForResume = true)
- resumeListener.onMediaDataLoaded(KEY, null, dataCopy)
+ onMediaDataLoaded(KEY, null, dataCopy, resume = false)
// Then we should not check it again
verify(resumeBrowser, never()).testConnection()
@@ -320,17 +319,15 @@ class MediaResumeListenerTest : SysuiTestCase() {
setUpMbsWithValidResolveInfo()
resumeListener.onMediaDataLoaded(KEY, null, data)
- // We notify the manager to set a null action
- verify(mediaDataManager).setResumeAction(KEY, null)
-
// If we then get another update from the app before the first check completes
assertThat(executor.numPending()).isEqualTo(1)
var dataWithCheck = data.copy(hasCheckedForResume = true)
resumeListener.onMediaDataLoaded(KEY, null, dataWithCheck)
// We do not try to start another check
- assertThat(executor.numPending()).isEqualTo(1)
+ executor.runAllReady()
verify(mediaDataManager).setResumeAction(KEY, null)
+ verify(resumeBrowserFactory, times(1)).create(any(), any(), anyInt())
}
@Test
@@ -363,6 +360,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
resumeListener.userUnlockReceiver.onReceive(context, intent)
// Then we should attempt to find recent media for each saved component
+ executor.runAllReady()
verify(resumeBrowser, times(3)).findRecentMedia()
// Then since the mock service found media, the manager should be informed
@@ -382,10 +380,9 @@ class MediaResumeListenerTest : SysuiTestCase() {
// When media data is loaded that has not been checked yet, and does have a MBS
val dataCopy = data.copy(resumeAction = null, hasCheckedForResume = false)
- resumeListener.onMediaDataLoaded(KEY, null, dataCopy)
+ onMediaDataLoaded(KEY, null, dataCopy)
// Then we test whether the service is valid and set the resume action
- executor.runAllReady()
verify(mediaDataManager).setResumeAction(eq(KEY), eq(null))
verify(resumeBrowser).testConnection()
verify(mediaDataManager, times(2)).setResumeAction(eq(KEY), capture(actionCaptor))
@@ -455,6 +452,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
resumeListener.userUnlockReceiver.onReceive(mockContext, intent)
// We add its resume controls
+ executor.runAllReady()
verify(resumeBrowser).findRecentMedia()
verify(mediaDataManager)
.addResumptionControls(anyInt(), any(), any(), any(), any(), any(), eq(PACKAGE_NAME))
@@ -527,7 +525,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
// When media data is loaded that has not been checked yet, and does have a MBS
val dataCopy = data.copy(resumeAction = null, hasCheckedForResume = false)
- resumeListener.onMediaDataLoaded(KEY, null, dataCopy)
+ onMediaDataLoaded(KEY, null, dataCopy)
// Then we store the new lastPlayed time
verify(sharedPrefsEditor).putString(any(), (capture(componentCaptor)))
@@ -546,10 +544,9 @@ class MediaResumeListenerTest : SysuiTestCase() {
fun testOnMediaDataLoaded_newKeyDifferent_oldMediaBrowserDisconnected() {
setUpMbsWithValidResolveInfo()
- resumeListener.onMediaDataLoaded(key = KEY, oldKey = null, data)
- executor.runAllReady()
+ onMediaDataLoaded(key = KEY, oldKey = null, data)
- resumeListener.onMediaDataLoaded(key = "newKey", oldKey = KEY, data)
+ onMediaDataLoaded(key = "newKey", oldKey = KEY, data)
verify(resumeBrowser).disconnect()
}
@@ -561,8 +558,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
// Set up mocks to return with an error
whenever(resumeBrowser.testConnection()).thenAnswer { callbackCaptor.value.onError() }
- resumeListener.onMediaDataLoaded(key = KEY, oldKey = null, data)
- executor.runAllReady()
+ onMediaDataLoaded(key = KEY, oldKey = null, data)
// Ensure we disconnect the browser
verify(resumeBrowser).disconnect()
@@ -579,8 +575,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
callbackCaptor.value.addTrack(description, component, resumeBrowser)
}
- resumeListener.onMediaDataLoaded(key = KEY, oldKey = null, data)
- executor.runAllReady()
+ onMediaDataLoaded(key = KEY, oldKey = null, data)
// Ensure we disconnect the browser
verify(resumeBrowser).disconnect()
@@ -598,8 +593,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
// Load media data that will require us to get the resume action
val dataCopy = data.copy(resumeAction = null, hasCheckedForResume = false)
- resumeListener.onMediaDataLoaded(KEY, null, dataCopy)
- executor.runAllReady()
+ onMediaDataLoaded(KEY, null, dataCopy)
verify(mediaDataManager, times(2)).setResumeAction(eq(KEY), capture(actionCaptor))
// Set up our factory to return a new browser so we can verify we disconnected the old one
@@ -634,6 +628,7 @@ class MediaResumeListenerTest : SysuiTestCase() {
// When the first user unlocks and we query their recent media
userCallbackCaptor.value.onUserChanged(firstUserId, context)
resumeListener.userUnlockReceiver.onReceive(context, unlockIntent)
+ executor.runAllReady()
whenever(resumeBrowser.userId).thenReturn(userIdCaptor.value)
verify(resumeBrowser, times(3)).findRecentMedia()
@@ -688,4 +683,16 @@ class MediaResumeListenerTest : SysuiTestCase() {
whenever(pm.resolveServiceAsUser(any(), anyInt(), anyInt())).thenReturn(resolveInfo)
whenever(pm.getApplicationLabel(any())).thenReturn(PACKAGE_NAME)
}
+
+ private fun onMediaDataLoaded(
+ key: String,
+ oldKey: String?,
+ data: MediaData,
+ resume: Boolean = true
+ ) {
+ resumeListener.onMediaDataLoaded(key, oldKey, data)
+ if (resume) {
+ assertThat(executor.runAllReady()).isEqualTo(1)
+ }
+ }
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileLifecycleManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileLifecycleManagerTest.java
index c1cf91d6520c..bc0ec2d784f4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileLifecycleManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/external/TileLifecycleManagerTest.java
@@ -22,6 +22,7 @@ import static android.service.quicksettings.TileService.START_ACTIVITY_NEEDS_PEN
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession;
import static com.android.systemui.Flags.FLAG_QS_CUSTOM_TILE_CLICK_GUARANTEED_BUG_FIX;
+import static com.android.systemui.Flags.FLAG_QS_QUICK_REBIND_ACTIVE_TILES;
import static com.google.common.truth.Truth.assertThat;
@@ -75,6 +76,8 @@ import com.android.systemui.broadcast.BroadcastDispatcher;
import com.android.systemui.util.concurrency.FakeExecutor;
import com.android.systemui.util.time.FakeSystemClock;
+import com.google.common.truth.Truth;
+
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
@@ -95,7 +98,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
@Parameters(name = "{0}")
public static List<FlagsParameterization> getParams() {
- return allCombinationsOf(FLAG_QS_CUSTOM_TILE_CLICK_GUARANTEED_BUG_FIX);
+ return allCombinationsOf(FLAG_QS_CUSTOM_TILE_CLICK_GUARANTEED_BUG_FIX,
+ FLAG_QS_QUICK_REBIND_ACTIVE_TILES);
}
private final PackageManagerAdapter mMockPackageManagerAdapter =
@@ -154,7 +158,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mUser,
mActivityManager,
mDeviceIdleController,
- mExecutor);
+ mExecutor,
+ mClock);
}
@After
@@ -169,12 +174,12 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mStateManager.handleDestroy();
}
- private void setPackageEnabled(boolean enabled) throws Exception {
+ private void setPackageEnabledAndActive(boolean enabled, boolean active) throws Exception {
ServiceInfo defaultServiceInfo = null;
if (enabled) {
defaultServiceInfo = new ServiceInfo();
defaultServiceInfo.metaData = new Bundle();
- defaultServiceInfo.metaData.putBoolean(TileService.META_DATA_ACTIVE_TILE, true);
+ defaultServiceInfo.metaData.putBoolean(TileService.META_DATA_ACTIVE_TILE, active);
defaultServiceInfo.metaData.putBoolean(TileService.META_DATA_TOGGLEABLE_TILE, true);
}
when(mMockPackageManagerAdapter.getServiceInfo(any(), anyInt(), anyInt()))
@@ -186,6 +191,10 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
.thenReturn(defaultPackageInfo);
}
+ private void setPackageEnabled(boolean enabled) throws Exception {
+ setPackageEnabledAndActive(enabled, true);
+ }
+
private void setPackageInstalledForUser(
boolean installed,
boolean active,
@@ -396,18 +405,125 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
}
@Test
- public void testKillProcess() throws Exception {
+ public void testKillProcessWhenTileServiceIsNotActive() throws Exception {
+ setPackageEnabledAndActive(true, false);
mStateManager.onStartListening();
mStateManager.executeSetBindService(true);
mExecutor.runAllReady();
+ verifyBind(1);
+ verify(mMockTileService, times(1)).onStartListening();
+
mStateManager.onBindingDied(mTileServiceComponentName);
mExecutor.runAllReady();
- mClock.advanceTime(5000);
+ mClock.advanceTime(1000);
+ mExecutor.runAllReady();
+
+ // still 4 seconds left because non active tile service rebind time is 5 seconds
+ Truth.assertThat(mContext.isBound(mTileServiceComponentName)).isFalse();
+
+ mClock.advanceTime(4000); // 5 seconds delay for nonActive service rebinding
+ mExecutor.runAllReady();
+ verifyBind(2);
+ verify(mMockTileService, times(2)).onStartListening();
+ }
+
+ @EnableFlags(FLAG_QS_QUICK_REBIND_ACTIVE_TILES)
+ @Test
+ public void testKillProcessWhenTileServiceIsActive_withRebindFlagOn() throws Exception {
+ mStateManager.onStartListening();
+ mStateManager.executeSetBindService(true);
+ mExecutor.runAllReady();
+ verifyBind(1);
+ verify(mMockTileService, times(1)).onStartListening();
+
+ mStateManager.onBindingDied(mTileServiceComponentName);
+ mExecutor.runAllReady();
+ mClock.advanceTime(1000);
+ mExecutor.runAllReady();
+
+ // Two calls: one for the first bind, one for the restart.
+ verifyBind(2);
+ verify(mMockTileService, times(2)).onStartListening();
+ }
+
+ @DisableFlags(FLAG_QS_QUICK_REBIND_ACTIVE_TILES)
+ @Test
+ public void testKillProcessWhenTileServiceIsActive_withRebindFlagOff() throws Exception {
+ mStateManager.onStartListening();
+ mStateManager.executeSetBindService(true);
+ mExecutor.runAllReady();
+ verifyBind(1);
+ verify(mMockTileService, times(1)).onStartListening();
+
+ mStateManager.onBindingDied(mTileServiceComponentName);
+ mExecutor.runAllReady();
+ mClock.advanceTime(1000);
+ mExecutor.runAllReady();
+ verifyBind(0); // the rebind happens after 4 more seconds
+
+ mClock.advanceTime(4000);
+ mExecutor.runAllReady();
+ verifyBind(1);
+ }
+
+ @EnableFlags(FLAG_QS_QUICK_REBIND_ACTIVE_TILES)
+ @Test
+ public void testKillProcessWhenTileServiceIsActiveTwice_withRebindFlagOn_delaysSecondRebind()
+ throws Exception {
+ mStateManager.onStartListening();
+ mStateManager.executeSetBindService(true);
+ mExecutor.runAllReady();
+ verifyBind(1);
+ verify(mMockTileService, times(1)).onStartListening();
+
+ mStateManager.onBindingDied(mTileServiceComponentName);
+ mExecutor.runAllReady();
+ mClock.advanceTime(1000);
mExecutor.runAllReady();
// Two calls: one for the first bind, one for the restart.
verifyBind(2);
verify(mMockTileService, times(2)).onStartListening();
+
+ mStateManager.onBindingDied(mTileServiceComponentName);
+ mExecutor.runAllReady();
+ mClock.advanceTime(1000);
+ mExecutor.runAllReady();
+ // because active tile will take 5 seconds to bind the second time, not 1
+ verifyBind(0);
+
+ mClock.advanceTime(4000);
+ mExecutor.runAllReady();
+ verifyBind(1);
+ }
+
+ @DisableFlags(FLAG_QS_QUICK_REBIND_ACTIVE_TILES)
+ @Test
+ public void testKillProcessWhenTileServiceIsActiveTwice_withRebindFlagOff_rebindsFromFirstKill()
+ throws Exception {
+ mStateManager.onStartListening();
+ mStateManager.executeSetBindService(true);
+ mExecutor.runAllReady();
+ verifyBind(1);
+ verify(mMockTileService, times(1)).onStartListening();
+
+ mStateManager.onBindingDied(mTileServiceComponentName); // rebind scheduled for 5 seconds
+ mExecutor.runAllReady();
+ mClock.advanceTime(1000);
+ mExecutor.runAllReady();
+
+ verifyBind(0); // it would bind in 4 more seconds
+
+ mStateManager.onBindingDied(mTileServiceComponentName); // this does not affect the rebind
+ mExecutor.runAllReady();
+ mClock.advanceTime(1000);
+ mExecutor.runAllReady();
+
+ verifyBind(0); // only 2 seconds passed from first kill
+
+ mClock.advanceTime(3000);
+ mExecutor.runAllReady();
+ verifyBind(1); // the rebind scheduled 5 seconds from the first kill should now happen
}
@Test
@@ -510,7 +626,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mUser,
mActivityManager,
mDeviceIdleController,
- mExecutor);
+ mExecutor,
+ mClock);
manager.executeSetBindService(true);
mExecutor.runAllReady();
@@ -533,7 +650,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mUser,
mActivityManager,
mDeviceIdleController,
- mExecutor);
+ mExecutor,
+ mClock);
manager.executeSetBindService(true);
mExecutor.runAllReady();
@@ -556,7 +674,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mUser,
mActivityManager,
mDeviceIdleController,
- mExecutor);
+ mExecutor,
+ mClock);
manager.executeSetBindService(true);
mExecutor.runAllReady();
@@ -581,7 +700,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mUser,
mActivityManager,
mDeviceIdleController,
- mExecutor);
+ mExecutor,
+ mClock);
manager.executeSetBindService(true);
mExecutor.runAllReady();
@@ -607,7 +727,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mUser,
mActivityManager,
mDeviceIdleController,
- mExecutor);
+ mExecutor,
+ mClock);
assertThat(manager.isActiveTile()).isTrue();
}
@@ -626,7 +747,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mUser,
mActivityManager,
mDeviceIdleController,
- mExecutor);
+ mExecutor,
+ mClock);
assertThat(manager.isActiveTile()).isTrue();
}
@@ -644,7 +766,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mUser,
mActivityManager,
mDeviceIdleController,
- mExecutor);
+ mExecutor,
+ mClock);
assertThat(manager.isToggleableTile()).isTrue();
}
@@ -663,7 +786,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mUser,
mActivityManager,
mDeviceIdleController,
- mExecutor);
+ mExecutor,
+ mClock);
assertThat(manager.isToggleableTile()).isTrue();
}
@@ -682,7 +806,8 @@ public class TileLifecycleManagerTest extends SysuiTestCase {
mUser,
mActivityManager,
mDeviceIdleController,
- mExecutor);
+ mExecutor,
+ mClock);
assertThat(manager.isToggleableTile()).isFalse();
assertThat(manager.isActiveTile()).isFalse();
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt
index d9faa30cb072..70af5e75105d 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/panels/ui/compose/DragAndDropTest.kt
@@ -31,17 +31,18 @@ import androidx.compose.ui.test.onChildren
import androidx.compose.ui.test.onNodeWithContentDescription
import androidx.compose.ui.test.onNodeWithTag
import androidx.compose.ui.test.onNodeWithText
+import androidx.compose.ui.text.AnnotatedString
import androidx.test.ext.junit.runners.AndroidJUnit4
import androidx.test.filters.FlakyTest
import androidx.test.filters.SmallTest
import com.android.systemui.SysuiTestCase
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.common.shared.model.Icon
-import com.android.systemui.common.shared.model.Text
import com.android.systemui.qs.panels.shared.model.SizedTile
import com.android.systemui.qs.panels.shared.model.SizedTileImpl
import com.android.systemui.qs.panels.ui.viewmodel.EditTileViewModel
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import org.junit.Rule
import org.junit.Test
import org.junit.runner.RunWith
@@ -199,10 +200,11 @@ class DragAndDropTest : SysuiTestCase() {
android.R.drawable.star_on,
ContentDescription.Loaded(tileSpec)
),
- label = Text.Loaded(tileSpec),
+ label = AnnotatedString(tileSpec),
appName = null,
isCurrent = true,
availableEditActions = emptySet(),
+ category = TileCategory.UNKNOWN,
),
getWidth(tileSpec),
)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileNewImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileNewImplTest.kt
index e6ec07e97d17..9f84e346d54a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileNewImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/qs/tiles/InternetTileNewImplTest.kt
@@ -258,7 +258,7 @@ class InternetTileNewImplTest : SysuiTestCase() {
companion object {
const val WIFI_SSID = "test ssid"
val ACTIVE_WIFI =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
isValidated = true,
level = 4,
ssid = WIFI_SSID,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/SaveImageInBackgroundTaskTest.kt b/packages/SystemUI/tests/src/com/android/systemui/screenshot/SaveImageInBackgroundTaskTest.kt
deleted file mode 100644
index 5e07aef7d8e9..000000000000
--- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/SaveImageInBackgroundTaskTest.kt
+++ /dev/null
@@ -1,278 +0,0 @@
-/*
- * 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.screenshot
-
-import android.app.Notification
-import android.app.PendingIntent
-import android.content.ComponentName
-import android.content.Intent
-import android.graphics.Bitmap
-import android.graphics.drawable.Icon
-import android.net.Uri
-import android.os.UserHandle
-import androidx.test.filters.SmallTest
-import com.android.systemui.SysuiTestCase
-import com.android.systemui.flags.FakeFeatureFlags
-import com.android.systemui.screenshot.ScreenshotNotificationSmartActionsProvider.ScreenshotSmartActionType
-import com.android.systemui.util.mockito.any
-import com.android.systemui.util.mockito.eq
-import com.android.systemui.util.mockito.mock
-import com.android.systemui.util.mockito.whenever
-import java.util.concurrent.CompletableFuture
-import org.junit.Assert.assertEquals
-import org.junit.Assert.assertNull
-import org.junit.Before
-import org.junit.Test
-
-@SmallTest
-class SaveImageInBackgroundTaskTest : SysuiTestCase() {
- private val imageExporter = mock<ImageExporter>()
- private val smartActions = mock<ScreenshotSmartActions>()
- private val smartActionsProvider = mock<ScreenshotNotificationSmartActionsProvider>()
- private val saveImageData = SaveImageInBackgroundTask.SaveImageInBackgroundData()
- private val testScreenshotId: String = "testScreenshotId"
- private val testBitmap = mock<Bitmap>()
- private val testUser = UserHandle.getUserHandleForUid(0)
- private val testIcon = mock<Icon>()
- private val testImageTime = 1234.toLong()
- private val flags = FakeFeatureFlags()
-
- private val smartActionsUriFuture = mock<CompletableFuture<List<Notification.Action>>>()
- private val smartActionsFuture = mock<CompletableFuture<List<Notification.Action>>>()
-
- private val testUri: Uri = Uri.parse("testUri")
- private val intent =
- Intent(Intent.ACTION_SEND)
- .setComponent(
- ComponentName.unflattenFromString(
- "com.google.android.test/com.google.android.test.TestActivity"
- )
- )
- private val immutablePendingIntent =
- PendingIntent.getBroadcast(
- mContext,
- 0,
- intent,
- PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_IMMUTABLE
- )
- private val mutablePendingIntent =
- PendingIntent.getBroadcast(
- mContext,
- 0,
- intent,
- PendingIntent.FLAG_CANCEL_CURRENT or PendingIntent.FLAG_MUTABLE
- )
-
- private val saveImageTask =
- SaveImageInBackgroundTask(
- mContext,
- flags,
- imageExporter,
- smartActions,
- saveImageData,
- smartActionsProvider,
- )
-
- @Before
- fun setup() {
- whenever(
- smartActions.getSmartActionsFuture(
- eq(testScreenshotId),
- any(Uri::class.java),
- eq(testBitmap),
- eq(smartActionsProvider),
- any(ScreenshotSmartActionType::class.java),
- any(Boolean::class.java),
- eq(testUser)
- )
- )
- .thenReturn(smartActionsUriFuture)
- whenever(
- smartActions.getSmartActionsFuture(
- eq(testScreenshotId),
- eq(null),
- eq(testBitmap),
- eq(smartActionsProvider),
- any(ScreenshotSmartActionType::class.java),
- any(Boolean::class.java),
- eq(testUser)
- )
- )
- .thenReturn(smartActionsFuture)
- }
-
- @Test
- fun testQueryQuickShare_noAction() {
- whenever(
- smartActions.getSmartActions(
- eq(testScreenshotId),
- eq(smartActionsFuture),
- any(Int::class.java),
- eq(smartActionsProvider),
- eq(ScreenshotSmartActionType.QUICK_SHARE_ACTION)
- )
- )
- .thenReturn(ArrayList<Notification.Action>())
-
- val quickShareAction =
- saveImageTask.queryQuickShareAction(testScreenshotId, testBitmap, testUser, testUri)
-
- assertNull(quickShareAction)
- }
-
- @Test
- fun testQueryQuickShare_withActions() {
- val actions = ArrayList<Notification.Action>()
- actions.add(constructAction("Action One", mutablePendingIntent))
- actions.add(constructAction("Action Two", mutablePendingIntent))
- whenever(
- smartActions.getSmartActions(
- eq(testScreenshotId),
- eq(smartActionsUriFuture),
- any(Int::class.java),
- eq(smartActionsProvider),
- eq(ScreenshotSmartActionType.QUICK_SHARE_ACTION)
- )
- )
- .thenReturn(actions)
-
- val quickShareAction =
- saveImageTask.queryQuickShareAction(testScreenshotId, testBitmap, testUser, testUri)!!
-
- assertEquals("Action One", quickShareAction.title)
- assertEquals(mutablePendingIntent, quickShareAction.actionIntent)
- }
-
- @Test
- fun testCreateQuickShareAction_originalWasNull_returnsNull() {
- val quickShareAction =
- saveImageTask.createQuickShareAction(
- null,
- testScreenshotId,
- testUri,
- testImageTime,
- testBitmap,
- testUser
- )
-
- assertNull(quickShareAction)
- }
-
- @Test
- fun testCreateQuickShareAction_immutableIntentDifferentAction_returnsNull() {
- val actions = ArrayList<Notification.Action>()
- actions.add(constructAction("New Test Action", immutablePendingIntent))
- whenever(
- smartActions.getSmartActions(
- eq(testScreenshotId),
- eq(smartActionsUriFuture),
- any(Int::class.java),
- eq(smartActionsProvider),
- eq(ScreenshotSmartActionType.QUICK_SHARE_ACTION)
- )
- )
- .thenReturn(actions)
- val origAction = constructAction("Old Test Action", immutablePendingIntent)
-
- val quickShareAction =
- saveImageTask.createQuickShareAction(
- origAction,
- testScreenshotId,
- testUri,
- testImageTime,
- testBitmap,
- testUser,
- )
-
- assertNull(quickShareAction)
- }
-
- @Test
- fun testCreateQuickShareAction_mutableIntent_returnsSafeIntent() {
- val actions = ArrayList<Notification.Action>()
- val action = constructAction("Action One", mutablePendingIntent)
- actions.add(action)
- whenever(
- smartActions.getSmartActions(
- eq(testScreenshotId),
- eq(smartActionsUriFuture),
- any(Int::class.java),
- eq(smartActionsProvider),
- eq(ScreenshotSmartActionType.QUICK_SHARE_ACTION)
- )
- )
- .thenReturn(actions)
-
- val quickShareAction =
- saveImageTask.createQuickShareAction(
- constructAction("Test Action", mutablePendingIntent),
- testScreenshotId,
- testUri,
- testImageTime,
- testBitmap,
- testUser
- )
- val quickSharePendingIntent =
- quickShareAction.actionIntent.intent.extras!!.getParcelable(
- SmartActionsReceiver.EXTRA_ACTION_INTENT,
- PendingIntent::class.java
- )
-
- assertEquals("Test Action", quickShareAction.title)
- assertEquals(mutablePendingIntent, quickSharePendingIntent)
- }
-
- @Test
- fun testCreateQuickShareAction_immutableIntent_returnsSafeIntent() {
- val actions = ArrayList<Notification.Action>()
- val action = constructAction("Test Action", immutablePendingIntent)
- actions.add(action)
- whenever(
- smartActions.getSmartActions(
- eq(testScreenshotId),
- eq(smartActionsUriFuture),
- any(Int::class.java),
- eq(smartActionsProvider),
- eq(ScreenshotSmartActionType.QUICK_SHARE_ACTION)
- )
- )
- .thenReturn(actions)
-
- val quickShareAction =
- saveImageTask.createQuickShareAction(
- constructAction("Test Action", immutablePendingIntent),
- testScreenshotId,
- testUri,
- testImageTime,
- testBitmap,
- testUser,
- )!!
-
- assertEquals("Test Action", quickShareAction.title)
- assertEquals(
- immutablePendingIntent,
- quickShareAction.actionIntent.intent.extras!!.getParcelable(
- SmartActionsReceiver.EXTRA_ACTION_INTENT,
- PendingIntent::class.java
- )
- )
- }
-
- private fun constructAction(title: String, intent: PendingIntent): Notification.Action {
- return Notification.Action.Builder(testIcon, title, intent).build()
- }
-}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/screenshot/appclips/AppClipsViewModelTest.java b/packages/SystemUI/tests/src/com/android/systemui/screenshot/appclips/AppClipsViewModelTest.java
index 5d71c054244a..886b32b09225 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/screenshot/appclips/AppClipsViewModelTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/screenshot/appclips/AppClipsViewModelTest.java
@@ -24,6 +24,7 @@ import static android.content.Intent.ACTION_MAIN;
import static android.content.Intent.ACTION_VIEW;
import static android.content.Intent.CAPTURE_CONTENT_FOR_NOTE_FAILED;
import static android.content.Intent.CATEGORY_LAUNCHER;
+import static android.content.pm.PackageManager.MATCH_DEFAULT_ONLY;
import static android.view.Display.DEFAULT_DISPLAY;
import static com.google.common.truth.Truth.assertThat;
@@ -32,6 +33,7 @@ import static com.google.common.util.concurrent.MoreExecutors.directExecutor;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyBoolean;
import static org.mockito.ArgumentMatchers.anyInt;
+import static org.mockito.ArgumentMatchers.argThat;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.doAnswer;
import static org.mockito.Mockito.reset;
@@ -73,6 +75,7 @@ import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.ArgumentMatcher;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
@@ -108,19 +111,24 @@ public final class AppClipsViewModelTest extends SysuiTestCase {
Context mMockedContext;
@Mock
private PackageManager mPackageManager;
- private ArgumentCaptor<Intent> mPackageManagerIntentCaptor;
+ private ArgumentCaptor<Intent> mPackageManagerLauncherIntentCaptor;
+ private ArgumentCaptor<Intent> mPackageManagerBacklinkIntentCaptor;
private AppClipsViewModel mViewModel;
@Before
public void setUp() throws RemoteException {
MockitoAnnotations.initMocks(this);
- mPackageManagerIntentCaptor = ArgumentCaptor.forClass(Intent.class);
+ mPackageManagerLauncherIntentCaptor = ArgumentCaptor.forClass(Intent.class);
+ mPackageManagerBacklinkIntentCaptor = ArgumentCaptor.forClass(Intent.class);
// Set up mocking for backlinks.
when(mAtmService.getTasks(Integer.MAX_VALUE, false, false, DEFAULT_DISPLAY))
.thenReturn(List.of(createTaskInfoForBacklinksTask()));
- when(mPackageManager.resolveActivity(mPackageManagerIntentCaptor.capture(), anyInt()))
- .thenReturn(createBacklinksTaskResolveInfo());
+ ResolveInfo expectedResolveInfo = createBacklinksTaskResolveInfo();
+ when(mPackageManager.resolveActivity(mPackageManagerLauncherIntentCaptor.capture(),
+ anyInt())).thenReturn(expectedResolveInfo);
+ when(mPackageManager.queryIntentActivities(mPackageManagerBacklinkIntentCaptor.capture(),
+ eq(MATCH_DEFAULT_ONLY))).thenReturn(List.of(expectedResolveInfo));
when(mPackageManager.loadItemIcon(any(), any())).thenReturn(FAKE_DRAWABLE);
when(mMockedContext.getPackageManager()).thenReturn(mPackageManager);
@@ -209,7 +217,7 @@ public final class AppClipsViewModelTest extends SysuiTestCase {
mViewModel.triggerBacklinks(Collections.emptySet(), DEFAULT_DISPLAY);
waitForIdleSync();
- Intent queriedIntent = mPackageManagerIntentCaptor.getValue();
+ Intent queriedIntent = mPackageManagerBacklinkIntentCaptor.getValue();
assertThat(queriedIntent.getData()).isEqualTo(expectedUri);
assertThat(queriedIntent.getAction()).isEqualTo(ACTION_VIEW);
@@ -226,6 +234,63 @@ public final class AppClipsViewModelTest extends SysuiTestCase {
}
@Test
+ public void triggerBacklinks_shouldUpdateBacklinks_withUriForDifferentApp() {
+ Uri expectedUri = Uri.parse("https://android.com");
+ AssistContent contentWithUri = new AssistContent();
+ contentWithUri.setWebUri(expectedUri);
+ mockForAssistContent(contentWithUri, BACKLINKS_TASK_ID);
+
+ // Reset PackageManager mocking done in setup.
+ reset(mPackageManager);
+ String package2 = BACKLINKS_TASK_PACKAGE_NAME + 2;
+ String appName2 = BACKLINKS_TASK_APP_NAME + 2;
+ ResolveInfo resolveInfo2 = createBacklinksTaskResolveInfo();
+ ActivityInfo activityInfo2 = resolveInfo2.activityInfo;
+ activityInfo2.name = appName2;
+ activityInfo2.packageName = package2;
+ activityInfo2.applicationInfo.packageName = package2;
+
+ Intent app2LauncherIntent = new Intent(ACTION_MAIN).addCategory(
+ CATEGORY_LAUNCHER).setPackage(package2);
+ when(mPackageManager.resolveActivity(intentEquals(app2LauncherIntent), eq(/* flags= */ 0)))
+ .thenReturn(resolveInfo2);
+ Intent uriIntent = new Intent(ACTION_VIEW).setData(expectedUri);
+ when(mPackageManager.queryIntentActivities(intentEquals(uriIntent), eq(MATCH_DEFAULT_ONLY)))
+ .thenReturn(List.of(resolveInfo2));
+ when(mPackageManager.loadItemIcon(any(), any())).thenReturn(FAKE_DRAWABLE);
+
+ mViewModel.triggerBacklinks(Collections.emptySet(), DEFAULT_DISPLAY);
+ waitForIdleSync();
+
+ BacklinksData result = (BacklinksData) mViewModel.mSelectedBacklinksLiveData.getValue();
+ ClipData clipData = result.getClipData();
+ ClipDescription resultDescription = clipData.getDescription();
+ assertThat(resultDescription.getLabel().toString()).isEqualTo(appName2);
+ assertThat(resultDescription.getMimeType(0)).isEqualTo(MIMETYPE_TEXT_URILIST);
+ assertThat(clipData.getItemCount()).isEqualTo(1);
+ assertThat(clipData.getItemAt(0).getUri()).isEqualTo(expectedUri);
+
+ assertThat(mViewModel.getBacklinksLiveData().getValue().size()).isEqualTo(1);
+ }
+
+ private static class IntentMatcher implements ArgumentMatcher<Intent> {
+ private final Intent mExpectedIntent;
+
+ IntentMatcher(Intent expectedIntent) {
+ mExpectedIntent = expectedIntent;
+ }
+
+ @Override
+ public boolean matches(Intent actualIntent) {
+ return actualIntent != null && mExpectedIntent.filterEquals(actualIntent);
+ }
+ }
+
+ private static Intent intentEquals(Intent intent) {
+ return argThat(new IntentMatcher(intent));
+ }
+
+ @Test
public void triggerBacklinks_withNonResolvableUri_usesMainLauncherIntent() {
Uri expectedUri = Uri.parse("https://developers.android.com");
AssistContent contentWithUri = new AssistContent();
@@ -249,7 +314,7 @@ public final class AppClipsViewModelTest extends SysuiTestCase {
mViewModel.triggerBacklinks(Collections.emptySet(), DEFAULT_DISPLAY);
waitForIdleSync();
- Intent queriedIntent = mPackageManagerIntentCaptor.getValue();
+ Intent queriedIntent = mPackageManagerBacklinkIntentCaptor.getValue();
assertThat(queriedIntent.getPackage()).isEqualTo(expectedIntent.getPackage());
BacklinksData result = (BacklinksData) mViewModel.mSelectedBacklinksLiveData.getValue();
@@ -283,7 +348,7 @@ public final class AppClipsViewModelTest extends SysuiTestCase {
mViewModel.triggerBacklinks(Collections.emptySet(), DEFAULT_DISPLAY);
waitForIdleSync();
- Intent queriedIntent = mPackageManagerIntentCaptor.getValue();
+ Intent queriedIntent = mPackageManagerLauncherIntentCaptor.getValue();
assertThat(queriedIntent.getPackage()).isEqualTo(BACKLINKS_TASK_PACKAGE_NAME);
assertThat(queriedIntent.getAction()).isEqualTo(ACTION_MAIN);
assertThat(queriedIntent.getCategories()).containsExactly(CATEGORY_LAUNCHER);
@@ -356,7 +421,9 @@ public final class AppClipsViewModelTest extends SysuiTestCase {
// For each task, the logic queries PM 3 times, twice for verifying if an app can be
// launched via launcher and once with the data provided in backlink intent.
when(mPackageManager.resolveActivity(any(), anyInt())).thenReturn(resolveInfo1,
- resolveInfo1, resolveInfo1, resolveInfo2, resolveInfo2, resolveInfo2);
+ resolveInfo1, resolveInfo2, resolveInfo2);
+ when(mPackageManager.queryIntentActivities(any(Intent.class), eq(MATCH_DEFAULT_ONLY)))
+ .thenReturn(List.of(resolveInfo1)).thenReturn(List.of(resolveInfo2));
when(mPackageManager.loadItemIcon(any(), any())).thenReturn(FAKE_DRAWABLE);
when(mAtmService.getTasks(Integer.MAX_VALUE, false, false, DEFAULT_DISPLAY))
.thenReturn(List.of(runningTaskInfo1, runningTaskInfo2));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
index 9481e5a52098..e0c4ab737511 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/NotificationPanelViewControllerBaseTest.java
@@ -431,7 +431,6 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
mFakeKeyguardRepository,
mKeyguardTransitionInteractor,
mPowerInteractor,
- mShadeRepository,
new FakeUserSetupRepository(),
mock(UserSwitcherInteractor.class),
new ShadeInteractorLegacyImpl(
@@ -447,8 +446,8 @@ public class NotificationPanelViewControllerBaseTest extends SysuiTestCase {
() -> mLargeScreenHeaderHelper
),
mShadeRepository
- )
- );
+ ),
+ mKosmos.getShadeModeInteractor());
SystemClock systemClock = new FakeSystemClock();
mStatusBarStateController = new StatusBarStateControllerImpl(
mUiEventLogger,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java b/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java
index 3f6617b32131..a52f1737117a 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/shade/QuickSettingsControllerImplBaseTest.java
@@ -217,7 +217,6 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase {
mKeyguardRepository,
keyguardTransitionInteractor,
powerInteractor,
- mShadeRepository,
new FakeUserSetupRepository(),
mUserSwitcherInteractor,
new ShadeInteractorLegacyImpl(
@@ -232,8 +231,8 @@ public class QuickSettingsControllerImplBaseTest extends SysuiTestCase {
deviceEntryUdfpsInteractor,
() -> mLargeScreenHeaderHelper),
mShadeRepository
- )
- );
+ ),
+ mKosmos.getShadeModeInteractor());
mActiveNotificationsInteractor = new ActiveNotificationsInteractor(
new ActiveNotificationListRepository(),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt
index ed99705b194e..b177e4a3e22e 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/notification/interruption/VisualInterruptionDecisionProviderImplTest.kt
@@ -101,7 +101,7 @@ class VisualInterruptionDecisionProviderImplTest : VisualInterruptionDecisionPro
private fun getAvalancheSuppressor() : AvalancheSuppressor {
return AvalancheSuppressor(
avalancheProvider, systemClock, settingsInteractor, packageManager,
- uiEventLogger, context, notificationManager, logger
+ uiEventLogger, context, notificationManager, logger, systemSettings
)
}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
index 01a3d36a05ec..1d74331e429b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
@@ -1112,9 +1112,11 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
public void testShowBouncerOrKeyguard_showsKeyguardIfShowBouncerReturnsFalse() {
when(mKeyguardSecurityModel.getSecurityMode(anyInt())).thenReturn(
KeyguardSecurityModel.SecurityMode.SimPin);
+ // Returning false means unable to show the bouncer
when(mPrimaryBouncerInteractor.show(true)).thenReturn(false);
when(mKeyguardTransitionInteractor.getTransitionState().getValue().getTo())
.thenReturn(KeyguardState.LOCKSCREEN);
+ mStatusBarKeyguardViewManager.onStartedWakingUp();
reset(mCentralSurfaces);
// Advance past reattempts
@@ -1127,6 +1129,23 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
@Test
@DisableSceneContainer
+ @EnableFlags(Flags.FLAG_SIM_PIN_RACE_CONDITION_ON_RESTART)
+ public void testShowBouncerOrKeyguard_showsKeyguardIfSleeping() {
+ when(mKeyguardTransitionInteractor.getTransitionState().getValue().getTo())
+ .thenReturn(KeyguardState.LOCKSCREEN);
+ mStatusBarKeyguardViewManager.onStartedGoingToSleep();
+
+ reset(mCentralSurfaces);
+ reset(mPrimaryBouncerInteractor);
+ mStatusBarKeyguardViewManager.showBouncerOrKeyguard(
+ /* hideBouncerWhenShowing= */true, false);
+ verify(mCentralSurfaces).showKeyguard();
+ verify(mPrimaryBouncerInteractor).hide();
+ }
+
+
+ @Test
+ @DisableSceneContainer
public void testShowBouncerOrKeyguard_needsFullScreen_bouncerAlreadyShowing() {
boolean isFalsingReset = false;
when(mKeyguardSecurityModel.getSecurityMode(anyInt())).thenReturn(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepositoryTest.kt
index b6e23c1f42ee..715e3b472373 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/CarrierMergedConnectionRepositoryTest.kt
@@ -85,7 +85,7 @@ class CarrierMergedConnectionRepositoryTest : SysuiTestCase() {
underTest.dataConnectionState.onEach { latestConnState = it }.launchIn(this)
val netJob = underTest.resolvedNetworkType.onEach { latestNetType = it }.launchIn(this)
- wifiRepository.setWifiNetwork(WifiNetworkModel.Inactive)
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Inactive())
assertThat(latestConnState).isEqualTo(DataConnectionState.Disconnected)
assertThat(latestNetType).isNotEqualTo(ResolvedNetworkType.CarrierMergedNetworkType)
@@ -104,7 +104,7 @@ class CarrierMergedConnectionRepositoryTest : SysuiTestCase() {
underTest.dataConnectionState.onEach { latestConnState = it }.launchIn(this)
val netJob = underTest.resolvedNetworkType.onEach { latestNetType = it }.launchIn(this)
- wifiRepository.setWifiNetwork(WifiNetworkModel.Active(level = 1))
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Active.of(level = 1))
assertThat(latestConnState).isEqualTo(DataConnectionState.Disconnected)
assertThat(latestNetType).isNotEqualTo(ResolvedNetworkType.CarrierMergedNetworkType)
@@ -123,7 +123,7 @@ class CarrierMergedConnectionRepositoryTest : SysuiTestCase() {
wifiRepository.setIsWifiDefault(true)
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = SUB_ID,
level = 3,
)
@@ -143,7 +143,7 @@ class CarrierMergedConnectionRepositoryTest : SysuiTestCase() {
wifiRepository.setIsWifiEnabled(true)
wifiRepository.setIsWifiDefault(true)
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = SUB_ID,
level = 3,
)
@@ -180,7 +180,7 @@ class CarrierMergedConnectionRepositoryTest : SysuiTestCase() {
val typeJob = underTest.resolvedNetworkType.onEach { latestType = it }.launchIn(this)
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = SUB_ID + 10,
level = 3,
)
@@ -201,7 +201,7 @@ class CarrierMergedConnectionRepositoryTest : SysuiTestCase() {
val job = underTest.primaryLevel.onEach { latest = it }.launchIn(this)
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = SUB_ID,
level = 3,
)
@@ -221,7 +221,7 @@ class CarrierMergedConnectionRepositoryTest : SysuiTestCase() {
val job = underTest.primaryLevel.onEach { latest = it }.launchIn(this)
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = SUB_ID,
level = 3,
)
@@ -240,7 +240,7 @@ class CarrierMergedConnectionRepositoryTest : SysuiTestCase() {
val job = underTest.numberOfLevels.onEach { latest = it }.launchIn(this)
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = SUB_ID,
level = 1,
numberOfLevels = 6,
@@ -303,7 +303,7 @@ class CarrierMergedConnectionRepositoryTest : SysuiTestCase() {
whenever(telephonyManager.simOperatorName).thenReturn("New SIM name")
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = SUB_ID,
level = 3,
)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt
index a03980a9d45f..fd23655ffc1c 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/mobile/data/repository/prod/FullMobileConnectionRepositoryTest.kt
@@ -488,7 +488,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() {
// WHEN we set up carrier merged info
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
SUB_ID,
level = 3,
)
@@ -499,7 +499,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() {
// WHEN we update the info
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
SUB_ID,
level = 1,
)
@@ -538,7 +538,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() {
// WHEN isCarrierMerged is set to true
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
SUB_ID,
level = 3,
)
@@ -550,7 +550,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() {
// WHEN the carrier merge network is updated
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
SUB_ID,
level = 4,
)
@@ -602,7 +602,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() {
// THEN updates to the carrier merged level aren't logged
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
SUB_ID,
level = 4,
)
@@ -610,7 +610,7 @@ class FullMobileConnectionRepositoryTest : SysuiTestCase() {
assertThat(dumpBuffer()).doesNotContain("$COL_PRIMARY_LEVEL${BUFFER_SEPARATOR}4")
wifiRepository.setWifiNetwork(
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
SUB_ID,
level = 3,
)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/domain/interactor/DeviceBasedSatelliteInteractorTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/domain/interactor/DeviceBasedSatelliteInteractorTest.kt
index a1cb29b8e95c..c0a206afe64b 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/domain/interactor/DeviceBasedSatelliteInteractorTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/domain/interactor/DeviceBasedSatelliteInteractorTest.kt
@@ -574,7 +574,7 @@ class DeviceBasedSatelliteInteractorTest : SysuiTestCase() {
val latest by collectLastValue(underTest.isWifiActive)
// WHEN wifi is active
- wifiRepository.setWifiNetwork(WifiNetworkModel.Active(level = 1))
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Active.of(level = 1))
// THEN the interactor returns true due to the wifi network being active
assertThat(latest).isTrue()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModelTest.kt
index c1abf9826ea3..e7e496938033 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/satellite/ui/viewmodel/DeviceBasedSatelliteViewModelTest.kt
@@ -375,7 +375,7 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
repo.isSatelliteProvisioned.value = true
// GIVEN wifi network is active
- wifiRepository.setWifiNetwork(WifiNetworkModel.Active(level = 1))
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Active.of(level = 1))
// THEN icon is null because the device is connected to wifi
assertThat(latest).isNull()
@@ -573,7 +573,7 @@ class DeviceBasedSatelliteViewModelTest : SysuiTestCase() {
repo.isSatelliteProvisioned.value = true
// GIVEN wifi network is active
- wifiRepository.setWifiNetwork(WifiNetworkModel.Active(level = 1))
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Active.of(level = 1))
// THEN carrier text is null because the device is connected to wifi
assertThat(latest).isNull()
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModelTest.kt
index fed33179250b..975e2caef2fe 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/shared/ui/viewmodel/InternetTileViewModelTest.kt
@@ -154,7 +154,7 @@ class InternetTileViewModelTest : SysuiTestCase() {
val latest by collectLastValue(underTest.tileModel)
val networkModel =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = 4,
ssid = "test ssid",
)
@@ -183,7 +183,7 @@ class InternetTileViewModelTest : SysuiTestCase() {
val latest by collectLastValue(underTest.tileModel)
val networkModel =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = 4,
ssid = "test ssid",
hotspotDeviceType = WifiNetworkModel.HotspotDeviceType.NONE,
@@ -295,7 +295,7 @@ class InternetTileViewModelTest : SysuiTestCase() {
testScope.runTest {
val latest by collectLastValue(underTest.tileModel)
- val networkModel = WifiNetworkModel.Inactive
+ val networkModel = WifiNetworkModel.Inactive()
connectivityRepository.setWifiConnected(validated = false)
wifiRepository.setIsWifiDefault(true)
@@ -310,7 +310,7 @@ class InternetTileViewModelTest : SysuiTestCase() {
testScope.runTest {
val latest by collectLastValue(underTest.tileModel)
- val networkModel = WifiNetworkModel.Inactive
+ val networkModel = WifiNetworkModel.Inactive()
connectivityRepository.setWifiConnected(validated = false)
wifiRepository.setIsWifiDefault(true)
@@ -390,7 +390,7 @@ class InternetTileViewModelTest : SysuiTestCase() {
private fun setWifiNetworkWithHotspot(hotspot: WifiNetworkModel.HotspotDeviceType) {
val networkModel =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = 4,
ssid = "test ssid",
hotspotDeviceType = hotspot,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImplTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImplTest.kt
index 46f34e82c688..fd4b77d7fb95 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImplTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/prod/WifiRepositoryImplTest.kt
@@ -295,7 +295,10 @@ class WifiRepositoryImplTest : SysuiTestCase() {
whenever(wifiPickerTracker.connectedWifiEntry).thenReturn(wifiEntry)
getCallback().onWifiEntriesChanged()
- assertThat(latest).isEqualTo(WifiNetworkModel.Inactive)
+ assertThat(latest).isInstanceOf(WifiNetworkModel.Inactive::class.java)
+ val inactiveReason = (latest as WifiNetworkModel.Inactive).inactiveReason
+ assertThat(inactiveReason).contains("level")
+ assertThat(inactiveReason).contains("$WIFI_LEVEL_UNREACHABLE")
}
@Test
@@ -311,7 +314,10 @@ class WifiRepositoryImplTest : SysuiTestCase() {
whenever(wifiPickerTracker.connectedWifiEntry).thenReturn(wifiEntry)
getCallback().onWifiEntriesChanged()
- assertThat(latest).isEqualTo(WifiNetworkModel.Inactive)
+ assertThat(latest).isInstanceOf(WifiNetworkModel.Inactive::class.java)
+ val inactiveReason = (latest as WifiNetworkModel.Inactive).inactiveReason
+ assertThat(inactiveReason).contains("level")
+ assertThat(inactiveReason).contains("${WIFI_LEVEL_MAX + 1}")
}
@Test
@@ -327,7 +333,10 @@ class WifiRepositoryImplTest : SysuiTestCase() {
whenever(wifiPickerTracker.connectedWifiEntry).thenReturn(wifiEntry)
getCallback().onWifiEntriesChanged()
- assertThat(latest).isEqualTo(WifiNetworkModel.Inactive)
+ assertThat(latest).isInstanceOf(WifiNetworkModel.Inactive::class.java)
+ val inactiveReason = (latest as WifiNetworkModel.Inactive).inactiveReason
+ assertThat(inactiveReason).contains("level")
+ assertThat(inactiveReason).contains("${WIFI_LEVEL_MIN - 1}")
}
@Test
@@ -530,6 +539,25 @@ class WifiRepositoryImplTest : SysuiTestCase() {
}
@Test
+ fun wifiNetwork_carrierMergedButInvalidLevel_flowHasInvalid() =
+ testScope.runTest {
+ val latest by collectLastValue(underTest.wifiNetwork)
+
+ val mergedEntry =
+ mock<MergedCarrierEntry>().apply {
+ whenever(this.isPrimaryNetwork).thenReturn(true)
+ whenever(this.subscriptionId).thenReturn(3)
+ whenever(this.isDefaultNetwork).thenReturn(true)
+ whenever(this.level).thenReturn(WIFI_LEVEL_UNREACHABLE)
+ }
+ whenever(wifiPickerTracker.mergedCarrierEntry).thenReturn(mergedEntry)
+
+ getCallback().onWifiEntriesChanged()
+
+ assertThat(latest).isInstanceOf(WifiNetworkModel.Invalid::class.java)
+ }
+
+ @Test
fun wifiNetwork_notValidated_networkNotValidated() =
testScope.runTest {
val latest by collectLastValue(underTest.wifiNetwork)
@@ -571,7 +599,7 @@ class WifiRepositoryImplTest : SysuiTestCase() {
whenever(wifiPickerTracker.connectedWifiEntry).thenReturn(wifiEntry)
getCallback().onWifiEntriesChanged()
- assertThat(latest).isEqualTo(WifiNetworkModel.Inactive)
+ assertThat(latest).isEqualTo(WifiNetworkModel.Inactive())
}
@Test
@@ -587,7 +615,7 @@ class WifiRepositoryImplTest : SysuiTestCase() {
whenever(wifiPickerTracker.connectedWifiEntry).thenReturn(null)
getCallback().onWifiEntriesChanged()
- assertThat(latest).isEqualTo(WifiNetworkModel.Inactive)
+ assertThat(latest).isEqualTo(WifiNetworkModel.Inactive())
}
@Test
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/shared/model/WifiNetworkModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/shared/model/WifiNetworkModelTest.kt
index 92860efc0c35..1495519cc1a1 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/shared/model/WifiNetworkModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/shared/model/WifiNetworkModelTest.kt
@@ -24,6 +24,7 @@ import com.android.systemui.SysuiTestCase
import com.android.systemui.log.table.TableRowLogger
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel.Active.Companion.MAX_VALID_LEVEL
import com.android.systemui.statusbar.pipeline.wifi.shared.model.WifiNetworkModel.Companion.MIN_VALID_LEVEL
+import com.android.wifitrackerlib.WifiEntry.WIFI_LEVEL_UNREACHABLE
import com.google.common.truth.Truth.assertThat
import org.junit.Test
import org.junit.runner.RunWith
@@ -32,59 +33,109 @@ import org.junit.runner.RunWith
@RunWith(AndroidJUnit4::class)
class WifiNetworkModelTest : SysuiTestCase() {
@Test
- fun active_levelsInValidRange_noException() {
+ fun active_levelsInValidRange_createsActive() {
(MIN_VALID_LEVEL..MAX_VALID_LEVEL).forEach { level ->
- WifiNetworkModel.Active(level = level)
- // No assert, just need no crash
+ val result = WifiNetworkModel.Active.of(level = level)
+ assertThat(result).isInstanceOf(WifiNetworkModel.Active::class.java)
}
}
+ fun active_levelTooLow_returnsInactive() {
+ val result = WifiNetworkModel.Active.of(level = MIN_VALID_LEVEL - 1)
+ assertThat(result).isInstanceOf(WifiNetworkModel.Inactive::class.java)
+ }
+
@Test(expected = IllegalArgumentException::class)
- fun active_levelNegative_exceptionThrown() {
- WifiNetworkModel.Active(level = MIN_VALID_LEVEL - 1)
+ fun active_levelTooLow_createdByCopy_exceptionThrown() {
+ val starting = WifiNetworkModel.Active.of(level = MIN_VALID_LEVEL)
+
+ (starting as WifiNetworkModel.Active).copy(level = MIN_VALID_LEVEL - 1)
+ }
+
+ fun active_levelTooHigh_returnsInactive() {
+ val result = WifiNetworkModel.Active.of(level = MAX_VALID_LEVEL + 1)
+
+ assertThat(result).isInstanceOf(WifiNetworkModel.Inactive::class.java)
}
@Test(expected = IllegalArgumentException::class)
- fun active_levelTooHigh_exceptionThrown() {
- WifiNetworkModel.Active(level = MAX_VALID_LEVEL + 1)
+ fun active_levelTooHigh_createdByCopy_exceptionThrown() {
+ val starting = WifiNetworkModel.Active.of(level = MAX_VALID_LEVEL)
+
+ (starting as WifiNetworkModel.Active).copy(level = MAX_VALID_LEVEL + 1)
+ }
+
+ fun active_levelUnreachable_returnsInactive() {
+ val result = WifiNetworkModel.Active.of(level = WIFI_LEVEL_UNREACHABLE)
+
+ assertThat(result).isInstanceOf(WifiNetworkModel.Inactive::class.java)
}
@Test(expected = IllegalArgumentException::class)
- fun carrierMerged_invalidSubId_exceptionThrown() {
- WifiNetworkModel.CarrierMerged(INVALID_SUBSCRIPTION_ID, 1)
+ fun active_levelUnreachable_createdByCopy_exceptionThrown() {
+ val starting = WifiNetworkModel.Active.of(level = MAX_VALID_LEVEL)
+
+ (starting as WifiNetworkModel.Active).copy(level = WIFI_LEVEL_UNREACHABLE)
+ }
+
+ fun carrierMerged_invalidSubId_returnsInvalid() {
+ val result = WifiNetworkModel.CarrierMerged.of(INVALID_SUBSCRIPTION_ID, level = 1)
+
+ assertThat(result).isInstanceOf(WifiNetworkModel.Invalid::class.java)
+ }
+
+ @Test(expected = IllegalArgumentException::class)
+ fun carrierMerged_invalidSubId_createdByCopy_exceptionThrown() {
+ val starting = WifiNetworkModel.CarrierMerged.of(subscriptionId = 1, level = 1)
+
+ (starting as WifiNetworkModel.CarrierMerged).copy(subscriptionId = INVALID_SUBSCRIPTION_ID)
+ }
+
+ fun carrierMerged_levelUnreachable_returnsInvalid() {
+ val result =
+ WifiNetworkModel.CarrierMerged.of(subscriptionId = 1, level = WIFI_LEVEL_UNREACHABLE)
+
+ assertThat(result).isInstanceOf(WifiNetworkModel.Invalid::class.java)
+ }
+
+ @Test(expected = IllegalArgumentException::class)
+ fun carrierMerged_levelUnreachable_createdByCopy_exceptionThrown() {
+ val starting = WifiNetworkModel.CarrierMerged.of(subscriptionId = 1, level = 1)
+
+ (starting as WifiNetworkModel.CarrierMerged).copy(level = WIFI_LEVEL_UNREACHABLE)
}
@Test
fun active_hasValidSsid_nullSsid_false() {
val network =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = MAX_VALID_LEVEL,
ssid = null,
)
- assertThat(network.hasValidSsid()).isFalse()
+ assertThat((network as WifiNetworkModel.Active).hasValidSsid()).isFalse()
}
@Test
fun active_hasValidSsid_unknownSsid_false() {
val network =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = MAX_VALID_LEVEL,
ssid = UNKNOWN_SSID,
)
- assertThat(network.hasValidSsid()).isFalse()
+ assertThat((network as WifiNetworkModel.Active).hasValidSsid()).isFalse()
}
@Test
fun active_hasValidSsid_validSsid_true() {
val network =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
level = MAX_VALID_LEVEL,
ssid = "FakeSsid",
)
- assertThat(network.hasValidSsid()).isTrue()
+ assertThat((network as WifiNetworkModel.Active).hasValidSsid()).isTrue()
}
// Non-exhaustive logDiffs test -- just want to make sure the logging logic isn't totally broken
@@ -93,14 +144,15 @@ class WifiNetworkModelTest : SysuiTestCase() {
fun logDiffs_carrierMergedToInactive_resetsAllFields() {
val logger = TestLogger()
val prevVal =
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = 3,
level = 1,
)
- WifiNetworkModel.Inactive.logDiffs(prevVal, logger)
+ WifiNetworkModel.Inactive(inactiveReason = "TestReason").logDiffs(prevVal, logger)
- assertThat(logger.changes).contains(Pair(COL_NETWORK_TYPE, TYPE_INACTIVE))
+ assertThat(logger.changes)
+ .contains(Pair(COL_NETWORK_TYPE, "$TYPE_INACTIVE[reason=TestReason]"))
assertThat(logger.changes).contains(Pair(COL_VALIDATED, "false"))
assertThat(logger.changes).contains(Pair(COL_LEVEL, LEVEL_DEFAULT.toString()))
assertThat(logger.changes).contains(Pair(COL_SSID, "null"))
@@ -110,12 +162,12 @@ class WifiNetworkModelTest : SysuiTestCase() {
fun logDiffs_inactiveToCarrierMerged_logsAllFields() {
val logger = TestLogger()
val carrierMerged =
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = 3,
level = 2,
)
- carrierMerged.logDiffs(prevVal = WifiNetworkModel.Inactive, logger)
+ carrierMerged.logDiffs(prevVal = WifiNetworkModel.Inactive(), logger)
assertThat(logger.changes).contains(Pair(COL_NETWORK_TYPE, TYPE_CARRIER_MERGED))
assertThat(logger.changes).contains(Pair(COL_SUB_ID, "3"))
@@ -128,14 +180,14 @@ class WifiNetworkModelTest : SysuiTestCase() {
fun logDiffs_inactiveToActive_logsAllActiveFields() {
val logger = TestLogger()
val activeNetwork =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
isValidated = true,
level = 3,
ssid = "Test SSID",
hotspotDeviceType = WifiNetworkModel.HotspotDeviceType.LAPTOP,
)
- activeNetwork.logDiffs(prevVal = WifiNetworkModel.Inactive, logger)
+ activeNetwork.logDiffs(prevVal = WifiNetworkModel.Inactive(), logger)
assertThat(logger.changes).contains(Pair(COL_NETWORK_TYPE, TYPE_ACTIVE))
assertThat(logger.changes).contains(Pair(COL_VALIDATED, "true"))
@@ -148,11 +200,13 @@ class WifiNetworkModelTest : SysuiTestCase() {
fun logDiffs_activeToInactive_resetsAllActiveFields() {
val logger = TestLogger()
val activeNetwork =
- WifiNetworkModel.Active(isValidated = true, level = 3, ssid = "Test SSID")
+ WifiNetworkModel.Active.of(isValidated = true, level = 3, ssid = "Test SSID")
- WifiNetworkModel.Inactive.logDiffs(prevVal = activeNetwork, logger)
+ WifiNetworkModel.Inactive(inactiveReason = "TestReason")
+ .logDiffs(prevVal = activeNetwork, logger)
- assertThat(logger.changes).contains(Pair(COL_NETWORK_TYPE, TYPE_INACTIVE))
+ assertThat(logger.changes)
+ .contains(Pair(COL_NETWORK_TYPE, "$TYPE_INACTIVE[reason=TestReason]"))
assertThat(logger.changes).contains(Pair(COL_VALIDATED, "false"))
assertThat(logger.changes).contains(Pair(COL_LEVEL, LEVEL_DEFAULT.toString()))
assertThat(logger.changes).contains(Pair(COL_SSID, "null"))
@@ -163,14 +217,14 @@ class WifiNetworkModelTest : SysuiTestCase() {
fun logDiffs_carrierMergedToActive_logsAllActiveFields() {
val logger = TestLogger()
val activeNetwork =
- WifiNetworkModel.Active(
+ WifiNetworkModel.Active.of(
isValidated = true,
level = 3,
ssid = "Test SSID",
hotspotDeviceType = WifiNetworkModel.HotspotDeviceType.AUTO,
)
val prevVal =
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = 3,
level = 1,
)
@@ -188,9 +242,9 @@ class WifiNetworkModelTest : SysuiTestCase() {
fun logDiffs_activeToCarrierMerged_logsAllFields() {
val logger = TestLogger()
val activeNetwork =
- WifiNetworkModel.Active(isValidated = true, level = 3, ssid = "Test SSID")
+ WifiNetworkModel.Active.of(isValidated = true, level = 3, ssid = "Test SSID")
val carrierMerged =
- WifiNetworkModel.CarrierMerged(
+ WifiNetworkModel.CarrierMerged.of(
subscriptionId = 3,
level = 2,
)
@@ -208,9 +262,9 @@ class WifiNetworkModelTest : SysuiTestCase() {
fun logDiffs_activeChangesLevel_onlyLevelLogged() {
val logger = TestLogger()
val prevActiveNetwork =
- WifiNetworkModel.Active(isValidated = true, level = 3, ssid = "Test SSID")
+ WifiNetworkModel.Active.of(isValidated = true, level = 3, ssid = "Test SSID")
val newActiveNetwork =
- WifiNetworkModel.Active(isValidated = true, level = 2, ssid = "Test SSID")
+ WifiNetworkModel.Active.of(isValidated = true, level = 2, ssid = "Test SSID")
newActiveNetwork.logDiffs(prevActiveNetwork, logger)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/view/ModernStatusBarWifiViewTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/view/ModernStatusBarWifiViewTest.kt
index ff398f988636..37c7a484a117 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/view/ModernStatusBarWifiViewTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/view/ModernStatusBarWifiViewTest.kt
@@ -195,7 +195,7 @@ class ModernStatusBarWifiViewTest : SysuiTestCase() {
@Test
fun isIconVisible_notEnabled_outputsFalse() {
wifiRepository.setIsWifiEnabled(false)
- wifiRepository.setWifiNetwork(WifiNetworkModel.Active(isValidated = true, level = 2))
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Active.of(isValidated = true, level = 2))
val view = ModernStatusBarWifiView.constructAndBind(context, SLOT_NAME, viewModel)
@@ -210,7 +210,7 @@ class ModernStatusBarWifiViewTest : SysuiTestCase() {
@Test
fun isIconVisible_enabled_outputsTrue() {
wifiRepository.setIsWifiEnabled(true)
- wifiRepository.setWifiNetwork(WifiNetworkModel.Active(isValidated = true, level = 2))
+ wifiRepository.setWifiNetwork(WifiNetworkModel.Active.of(isValidated = true, level = 2))
val view = ModernStatusBarWifiView.constructAndBind(context, SLOT_NAME, viewModel)
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelIconParameterizedTest.kt b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelIconParameterizedTest.kt
index 82acb40ec90c..96a01949b243 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelIconParameterizedTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/pipeline/wifi/ui/viewmodel/WifiViewModelIconParameterizedTest.kt
@@ -206,51 +206,51 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
// Enabled = false => no networks shown
TestCase(
enabled = false,
- network = WifiNetworkModel.CarrierMerged(subscriptionId = 1, level = 1),
+ network = WifiNetworkModel.CarrierMerged.of(subscriptionId = 1, level = 1),
expected = null,
),
TestCase(
enabled = false,
- network = WifiNetworkModel.Inactive,
+ network = WifiNetworkModel.Inactive(),
expected = null,
),
TestCase(
enabled = false,
- network = WifiNetworkModel.Active(isValidated = false, level = 1),
+ network = WifiNetworkModel.Active.of(isValidated = false, level = 1),
expected = null,
),
TestCase(
enabled = false,
- network = WifiNetworkModel.Active(isValidated = true, level = 3),
+ network = WifiNetworkModel.Active.of(isValidated = true, level = 3),
expected = null,
),
// forceHidden = true => no networks shown
TestCase(
forceHidden = true,
- network = WifiNetworkModel.CarrierMerged(subscriptionId = 1, level = 1),
+ network = WifiNetworkModel.CarrierMerged.of(subscriptionId = 1, level = 1),
expected = null,
),
TestCase(
forceHidden = true,
- network = WifiNetworkModel.Inactive,
+ network = WifiNetworkModel.Inactive(),
expected = null,
),
TestCase(
enabled = false,
- network = WifiNetworkModel.Active(isValidated = false, level = 2),
+ network = WifiNetworkModel.Active.of(isValidated = false, level = 2),
expected = null,
),
TestCase(
forceHidden = true,
- network = WifiNetworkModel.Active(isValidated = true, level = 1),
+ network = WifiNetworkModel.Active.of(isValidated = true, level = 1),
expected = null,
),
// alwaysShowIconWhenEnabled = true => all Inactive and Active networks shown
TestCase(
alwaysShowIconWhenEnabled = true,
- network = WifiNetworkModel.Inactive,
+ network = WifiNetworkModel.Inactive(),
expected =
Expected(
iconResource = WIFI_NO_NETWORK,
@@ -263,7 +263,7 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
),
TestCase(
alwaysShowIconWhenEnabled = true,
- network = WifiNetworkModel.Active(isValidated = false, level = 4),
+ network = WifiNetworkModel.Active.of(isValidated = false, level = 4),
expected =
Expected(
iconResource = WIFI_NO_INTERNET_ICONS[4],
@@ -276,7 +276,7 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
),
TestCase(
alwaysShowIconWhenEnabled = true,
- network = WifiNetworkModel.Active(isValidated = true, level = 2),
+ network = WifiNetworkModel.Active.of(isValidated = true, level = 2),
expected =
Expected(
iconResource = WIFI_FULL_ICONS[2],
@@ -290,7 +290,7 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
// hasDataCapabilities = false => all Inactive and Active networks shown
TestCase(
hasDataCapabilities = false,
- network = WifiNetworkModel.Inactive,
+ network = WifiNetworkModel.Inactive(),
expected =
Expected(
iconResource = WIFI_NO_NETWORK,
@@ -303,7 +303,7 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
),
TestCase(
hasDataCapabilities = false,
- network = WifiNetworkModel.Active(isValidated = false, level = 2),
+ network = WifiNetworkModel.Active.of(isValidated = false, level = 2),
expected =
Expected(
iconResource = WIFI_NO_INTERNET_ICONS[2],
@@ -316,7 +316,7 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
),
TestCase(
hasDataCapabilities = false,
- network = WifiNetworkModel.Active(isValidated = true, level = 0),
+ network = WifiNetworkModel.Active.of(isValidated = true, level = 0),
expected =
Expected(
iconResource = WIFI_FULL_ICONS[0],
@@ -330,7 +330,7 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
// isDefault = true => all Inactive and Active networks shown
TestCase(
isDefault = true,
- network = WifiNetworkModel.Inactive,
+ network = WifiNetworkModel.Inactive(),
expected =
Expected(
iconResource = WIFI_NO_NETWORK,
@@ -343,7 +343,7 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
),
TestCase(
isDefault = true,
- network = WifiNetworkModel.Active(isValidated = false, level = 3),
+ network = WifiNetworkModel.Active.of(isValidated = false, level = 3),
expected =
Expected(
iconResource = WIFI_NO_INTERNET_ICONS[3],
@@ -356,7 +356,7 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
),
TestCase(
isDefault = true,
- network = WifiNetworkModel.Active(isValidated = true, level = 1),
+ network = WifiNetworkModel.Active.of(isValidated = true, level = 1),
expected =
Expected(
iconResource = WIFI_FULL_ICONS[1],
@@ -372,14 +372,14 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
enabled = true,
isDefault = true,
forceHidden = false,
- network = WifiNetworkModel.CarrierMerged(subscriptionId = 1, level = 1),
+ network = WifiNetworkModel.CarrierMerged.of(subscriptionId = 1, level = 1),
expected = null,
),
// isDefault = false => no networks shown
TestCase(
isDefault = false,
- network = WifiNetworkModel.Inactive,
+ network = WifiNetworkModel.Inactive(),
expected = null,
),
TestCase(
@@ -389,7 +389,7 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
),
TestCase(
isDefault = false,
- network = WifiNetworkModel.Active(isValidated = false, level = 3),
+ network = WifiNetworkModel.Active.of(isValidated = false, level = 3),
expected = null,
),
@@ -397,7 +397,7 @@ internal class WifiViewModelIconParameterizedTest(private val testCase: TestCase
// because wifi isn't the default connection (b/272509965).
TestCase(
isDefault = false,
- network = WifiNetworkModel.Active(isValidated = true, level = 4),
+ network = WifiNetworkModel.Active.of(isValidated = true, level = 4),
expected = null,
),
)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorKosmos.kt
new file mode 100644
index 000000000000..15c7e25f8a5c
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/domain/interactor/SideFpsOverlayInteractorKosmos.kt
@@ -0,0 +1,32 @@
+/*
+ * Copyright (C) 2024 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.biometrics.domain.interactor
+
+import com.android.systemui.keyguard.domain.interactor.deviceEntrySideFpsOverlayInteractor
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.Kosmos.Fixture
+import kotlinx.coroutines.ExperimentalCoroutinesApi
+
+@OptIn(ExperimentalCoroutinesApi::class)
+val Kosmos.sideFpsOverlayInteractor by Fixture {
+ SideFpsOverlayInteractorImpl(
+ biometricStatusInteractor,
+ displayStateInteractor,
+ deviceEntrySideFpsOverlayInteractor,
+ sideFpsSensorInteractor,
+ )
+}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinderKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinderKosmos.kt
index 79d58a1d4e40..59809e3d253f 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinderKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/binder/SideFpsOverlayViewBinderKosmos.kt
@@ -19,27 +19,19 @@ package com.android.systemui.biometrics.ui.binder
import android.content.applicationContext
import android.view.layoutInflater
import android.view.windowManager
-import com.android.systemui.biometrics.domain.interactor.biometricStatusInteractor
-import com.android.systemui.biometrics.domain.interactor.displayStateInteractor
-import com.android.systemui.biometrics.domain.interactor.sideFpsSensorInteractor
-import com.android.systemui.keyguard.domain.interactor.deviceEntrySideFpsOverlayInteractor
-import com.android.systemui.keyguard.ui.viewmodel.sideFpsProgressBarViewModel
+import com.android.systemui.biometrics.domain.interactor.sideFpsOverlayInteractor
+import com.android.systemui.biometrics.ui.viewmodel.sideFpsOverlayViewModel
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.Kosmos.Fixture
import com.android.systemui.kosmos.applicationCoroutineScope
-import kotlinx.coroutines.ExperimentalCoroutinesApi
-@OptIn(ExperimentalCoroutinesApi::class)
val Kosmos.sideFpsOverlayViewBinder by Fixture {
SideFpsOverlayViewBinder(
- applicationScope = applicationCoroutineScope,
- applicationContext = applicationContext,
- { biometricStatusInteractor },
- { displayStateInteractor },
- { deviceEntrySideFpsOverlayInteractor },
+ applicationCoroutineScope,
+ applicationContext,
{ layoutInflater },
- { sideFpsProgressBarViewModel },
- { sideFpsSensorInteractor },
+ { sideFpsOverlayInteractor },
+ { sideFpsOverlayViewModel },
{ windowManager }
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModelKosmos.kt
index de038559fc38..e10b2dd6497d 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/biometrics/ui/viewmodel/SideFpsOverlayViewModelKosmos.kt
@@ -27,9 +27,9 @@ import kotlinx.coroutines.ExperimentalCoroutinesApi
@OptIn(ExperimentalCoroutinesApi::class)
val Kosmos.sideFpsOverlayViewModel by Fixture {
SideFpsOverlayViewModel(
- applicationContext = applicationContext,
- deviceEntrySideFpsOverlayInteractor = deviceEntrySideFpsOverlayInteractor,
- displayStateInteractor = displayStateInteractor,
- sfpsSensorInteractor = sideFpsSensorInteractor,
+ applicationContext,
+ deviceEntrySideFpsOverlayInteractor,
+ displayStateInteractor,
+ sideFpsSensorInteractor,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorKosmos.kt
index 811c6533c656..80f6fc24ef2c 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/education/domain/interactor/KeyboardTouchpadEduInteractorKosmos.kt
@@ -19,6 +19,7 @@ package com.android.systemui.education.domain.interactor
import android.hardware.input.InputManager
import com.android.systemui.education.data.repository.fakeEduClock
import com.android.systemui.inputdevice.data.repository.UserInputDeviceRepository
+import com.android.systemui.inputdevice.tutorial.tutorialSchedulerRepository
import com.android.systemui.keyboard.data.repository.keyboardRepository
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.testDispatcher
@@ -50,6 +51,15 @@ var Kosmos.keyboardTouchpadEduStatsInteractor by
Kosmos.Fixture {
KeyboardTouchpadEduStatsInteractorImpl(
backgroundScope = testScope.backgroundScope,
- contextualEducationInteractor = contextualEducationInteractor
+ contextualEducationInteractor = contextualEducationInteractor,
+ inputDeviceRepository =
+ UserInputDeviceRepository(
+ testDispatcher,
+ keyboardRepository,
+ touchpadRepository,
+ userRepository
+ ),
+ tutorialSchedulerRepository,
+ fakeEduClock
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/inputdevice/tutorial/InputDeviceTutorialKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/inputdevice/tutorial/InputDeviceTutorialKosmos.kt
index 827f0d277d11..a83baffd78b2 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/inputdevice/tutorial/InputDeviceTutorialKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/inputdevice/tutorial/InputDeviceTutorialKosmos.kt
@@ -16,8 +16,20 @@
package com.android.systemui.inputdevice.tutorial
+import android.content.applicationContext
+import com.android.systemui.inputdevice.tutorial.data.repository.TutorialSchedulerRepository
import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.testScope
import org.mockito.kotlin.mock
var Kosmos.inputDeviceTutorialLogger: InputDeviceTutorialLogger by
Kosmos.Fixture { mock<InputDeviceTutorialLogger>() }
+
+var Kosmos.tutorialSchedulerRepository by
+ Kosmos.Fixture {
+ TutorialSchedulerRepository(
+ applicationContext = applicationContext,
+ testScope.backgroundScope,
+ "KosmosTutorialSchedulerRepository"
+ )
+ }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorKosmos.kt
index 27eadb147055..d920c4f05b03 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/keyguard/domain/interactor/KeyguardDismissActionInteractorKosmos.kt
@@ -25,6 +25,7 @@ import com.android.systemui.power.domain.interactor.powerInteractor
import com.android.systemui.scene.domain.interactor.sceneInteractor
import com.android.systemui.scene.domain.resolver.notifShadeSceneFamilyResolver
import com.android.systemui.scene.domain.resolver.quickSettingsSceneFamilyResolver
+import com.android.systemui.shade.domain.interactor.shadeInteractor
import kotlinx.coroutines.ExperimentalCoroutinesApi
@ExperimentalCoroutinesApi
@@ -35,11 +36,13 @@ val Kosmos.keyguardDismissActionInteractor by
transitionInteractor = keyguardTransitionInteractor,
dismissInteractor = keyguardDismissInteractor,
applicationScope = testScope.backgroundScope,
- sceneInteractor = sceneInteractor,
- deviceEntryInteractor = deviceEntryInteractor,
- quickSettingsSceneFamilyResolver = quickSettingsSceneFamilyResolver,
- notifShadeSceneFamilyResolver = notifShadeSceneFamilyResolver,
+ sceneInteractor = { sceneInteractor },
+ deviceEntryInteractor = { deviceEntryInteractor },
+ quickSettingsSceneFamilyResolver = { quickSettingsSceneFamilyResolver },
+ notifShadeSceneFamilyResolver = { notifShadeSceneFamilyResolver },
powerInteractor = powerInteractor,
alternateBouncerInteractor = alternateBouncerInteractor,
+ keyguardInteractor = { keyguardInteractor },
+ shadeInteractor = { shadeInteractor },
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
index 457bd284ea8d..c60305e85b22 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/kosmos/KosmosJavaAdapter.kt
@@ -61,6 +61,7 @@ import com.android.systemui.scene.shared.model.sceneDataSource
import com.android.systemui.settings.brightness.domain.interactor.brightnessMirrorShowingInteractor
import com.android.systemui.shade.data.repository.shadeRepository
import com.android.systemui.shade.domain.interactor.shadeInteractor
+import com.android.systemui.shade.domain.interactor.shadeModeInteractor
import com.android.systemui.shade.shadeController
import com.android.systemui.shade.ui.viewmodel.notificationShadeWindowModel
import com.android.systemui.statusbar.chips.ui.viewmodel.ongoingActivityChipsViewModel
@@ -156,4 +157,5 @@ class KosmosJavaAdapter() {
val scrimStartable by lazy { kosmos.scrimStartable }
val sceneContainerOcclusionInteractor by lazy { kosmos.sceneContainerOcclusionInteractor }
val msdlPlayer by lazy { kosmos.fakeMSDLPlayer }
+ val shadeModeInteractor by lazy { kosmos.shadeModeInteractor }
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceLoggerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceLoggerKosmos.kt
new file mode 100644
index 000000000000..76d71dd05edd
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceLoggerKosmos.kt
@@ -0,0 +1,23 @@
+/*
+ * Copyright (C) 2024 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.media.controls.domain.pipeline
+
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.log.logcatLogBuffer
+
+var Kosmos.mediaDeviceLogger by
+ Kosmos.Fixture { MediaDeviceLogger(logcatLogBuffer("MediaDeviceLoggerKosmos")) }
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerKosmos.kt
index c479ce676761..11408d8a4b90 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/media/controls/domain/pipeline/MediaDeviceManagerKosmos.kt
@@ -41,5 +41,6 @@ val Kosmos.mediaDeviceManager by
},
fgExecutor = fakeExecutor,
bgExecutor = fakeExecutor,
+ logger = mediaDeviceLogger,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/external/TileLifecycleManagerKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/external/TileLifecycleManagerKosmos.kt
index a0fc76b3d7de..4978558ff8a2 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/external/TileLifecycleManagerKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/external/TileLifecycleManagerKosmos.kt
@@ -24,6 +24,7 @@ import com.android.systemui.concurrency.fakeExecutor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.qs.tiles.impl.custom.packageManagerAdapterFacade
import com.android.systemui.util.mockito.mock
+import com.android.systemui.util.time.fakeSystemClock
val Kosmos.tileLifecycleManagerFactory: TileLifecycleManager.Factory by
Kosmos.Fixture {
@@ -39,6 +40,7 @@ val Kosmos.tileLifecycleManagerFactory: TileLifecycleManager.Factory by
activityManager,
mock(),
fakeExecutor,
+ fakeSystemClock,
)
}
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelKosmos.kt
index b03542cb569e..33227a4fcc62 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/panels/ui/viewmodel/EditModeViewModelKosmos.kt
@@ -16,6 +16,8 @@
package com.android.systemui.qs.panels.ui.viewmodel
+import android.content.applicationContext
+import com.android.systemui.common.ui.domain.interactor.configurationInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.qs.panels.domain.interactor.editTilesListInteractor
@@ -33,6 +35,8 @@ val Kosmos.editModeViewModel by
currentTilesInteractor,
tilesAvailabilityInteractor,
minimumTilesInteractor,
+ configurationInteractor,
+ applicationContext,
infiniteGridLayout,
applicationCoroutineScope,
gridLayoutTypeInteractor,
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/di/NewQSTileFactoryKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/di/NewQSTileFactoryKosmos.kt
index dceb8bff0ae7..f66125a6087e 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/di/NewQSTileFactoryKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/di/NewQSTileFactoryKosmos.kt
@@ -20,6 +20,7 @@ import android.os.UserHandle
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.qs.instanceIdSequenceFake
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
import com.android.systemui.qs.tiles.base.viewmodel.QSTileViewModelFactory
import com.android.systemui.qs.tiles.viewmodel.QSTileConfig
import com.android.systemui.qs.tiles.viewmodel.QSTileState
@@ -47,6 +48,7 @@ val Kosmos.customTileViewModelFactory: QSTileViewModelFactory.Component by
tileSpec,
QSTileUIConfig.Empty,
instanceIdSequenceFake.newInstanceId(),
+ category = TileCategory.PROVIDED_BY_APP,
)
object : QSTileViewModel {
override val state: StateFlow<QSTileState?> =
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigTestBuilder.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigTestBuilder.kt
index 2a0ee888db35..73d9b3233375 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigTestBuilder.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/qs/tiles/viewmodel/QSTileConfigTestBuilder.kt
@@ -18,6 +18,7 @@ package com.android.systemui.qs.tiles.viewmodel
import com.android.internal.logging.InstanceId
import com.android.systemui.qs.pipeline.shared.TileSpec
+import com.android.systemui.qs.shared.model.TileCategory
object QSTileConfigTestBuilder {
@@ -30,12 +31,14 @@ object QSTileConfigTestBuilder {
var instanceId: InstanceId = InstanceId.fakeInstanceId(0)
var metricsSpec: String = tileSpec.spec
var policy: QSTilePolicy = QSTilePolicy.NoRestrictions
+ var category: TileCategory = TileCategory.UNKNOWN
fun build() =
QSTileConfig(
tileSpec,
uiConfig,
instanceId,
+ category,
metricsSpec,
policy,
)
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/resolver/SceneResolverKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/resolver/SceneResolverKosmos.kt
index ae33aead67a7..d17b5750b937 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/resolver/SceneResolverKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/scene/domain/resolver/SceneResolverKosmos.kt
@@ -24,7 +24,7 @@ import com.android.systemui.keyguard.domain.interactor.keyguardEnabledInteractor
import com.android.systemui.kosmos.Kosmos
import com.android.systemui.kosmos.applicationCoroutineScope
import com.android.systemui.scene.shared.model.SceneFamilies
-import com.android.systemui.shade.domain.interactor.shadeInteractor
+import com.android.systemui.shade.domain.interactor.shadeModeInteractor
import kotlinx.coroutines.ExperimentalCoroutinesApi
val Kosmos.sceneFamilyResolvers: Map<SceneKey, SceneResolver>
@@ -48,7 +48,7 @@ val Kosmos.notifShadeSceneFamilyResolver by
Kosmos.Fixture {
NotifShadeSceneFamilyResolver(
applicationScope = applicationCoroutineScope,
- shadeInteractor = shadeInteractor,
+ shadeModeInteractor = shadeModeInteractor,
)
}
@@ -56,6 +56,6 @@ val Kosmos.quickSettingsSceneFamilyResolver by
Kosmos.Fixture {
QuickSettingsSceneFamilyResolver(
applicationScope = applicationCoroutineScope,
- shadeInteractor = shadeInteractor,
+ shadeModeInteractor = shadeModeInteractor,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeInteractorKosmos.kt
index 54208b9cdaef..04d930c72792 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeInteractorKosmos.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeInteractorKosmos.kt
@@ -53,7 +53,7 @@ val Kosmos.shadeInteractorLegacyImpl by
scope = applicationCoroutineScope,
keyguardRepository = keyguardRepository,
sharedNotificationContainerInteractor = sharedNotificationContainerInteractor,
- repository = shadeRepository
+ repository = shadeRepository,
)
}
var Kosmos.shadeInteractor: ShadeInteractor by Kosmos.Fixture { shadeInteractorImpl }
@@ -70,6 +70,6 @@ val Kosmos.shadeInteractorImpl by
userSetupRepository = userSetupRepository,
userSwitcherInteractor = userSwitcherInteractor,
baseShadeInteractor = baseShadeInteractor,
- shadeRepository = shadeRepository,
+ shadeModeInteractor = shadeModeInteractor,
)
}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorKosmos.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorKosmos.kt
new file mode 100644
index 000000000000..7892e962d63d
--- /dev/null
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/shade/domain/interactor/ShadeModeInteractorKosmos.kt
@@ -0,0 +1,29 @@
+/*
+ * Copyright (C) 2024 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.shade.domain.interactor
+
+import com.android.systemui.kosmos.Kosmos
+import com.android.systemui.kosmos.Kosmos.Fixture
+import com.android.systemui.kosmos.applicationCoroutineScope
+import com.android.systemui.shade.data.repository.shadeRepository
+
+val Kosmos.shadeModeInteractor by Fixture {
+ ShadeModeInteractorImpl(
+ applicationScope = applicationCoroutineScope,
+ repository = shadeRepository,
+ )
+}
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/FakeWifiRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/FakeWifiRepository.kt
index 709be5edf4c0..7ca90ea4bd7d 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/FakeWifiRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/statusbar/pipeline/wifi/data/repository/FakeWifiRepository.kt
@@ -32,7 +32,7 @@ class FakeWifiRepository : WifiRepository {
override val isWifiDefault: StateFlow<Boolean> = _isWifiDefault
private val _wifiNetwork: MutableStateFlow<WifiNetworkModel> =
- MutableStateFlow(WifiNetworkModel.Inactive)
+ MutableStateFlow(WifiNetworkModel.Inactive())
override val wifiNetwork: StateFlow<WifiNetworkModel> = _wifiNetwork
override val secondaryNetworks = MutableStateFlow<List<WifiNetworkModel>>(emptyList())
diff --git a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/data/repository/FakeAudioRepository.kt b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/data/repository/FakeAudioRepository.kt
index 888351f0a882..ba6ffd742611 100644
--- a/packages/SystemUI/tests/utils/src/com/android/systemui/volume/data/repository/FakeAudioRepository.kt
+++ b/packages/SystemUI/tests/utils/src/com/android/systemui/volume/data/repository/FakeAudioRepository.kt
@@ -33,11 +33,7 @@ import kotlinx.coroutines.flow.update
class FakeAudioRepository : AudioRepository {
- private val unMutableStreams =
- setOf(
- AudioManager.STREAM_VOICE_CALL,
- AudioManager.STREAM_ALARM,
- )
+ private val unMutableStreams = setOf(AudioManager.STREAM_VOICE_CALL, AudioManager.STREAM_ALARM)
private val mutableMode = MutableStateFlow(AudioManager.MODE_NORMAL)
override val mode: StateFlow<Int> = mutableMode.asStateFlow()
@@ -126,7 +122,7 @@ class FakeAudioRepository : AudioRepository {
lastAudibleVolumes[audioStream] = volume
}
- override suspend fun setRingerMode(audioStream: AudioStream, mode: RingerMode) {
+ override suspend fun setRingerModeInternal(audioStream: AudioStream, mode: RingerMode) {
mutableRingerMode.value = mode
}
diff --git a/packages/services/CameraExtensionsProxy/src/com/android/cameraextensions/CameraExtensionsProxyService.java b/packages/services/CameraExtensionsProxy/src/com/android/cameraextensions/CameraExtensionsProxyService.java
index 26b0f617d971..136738fcb343 100644
--- a/packages/services/CameraExtensionsProxy/src/com/android/cameraextensions/CameraExtensionsProxyService.java
+++ b/packages/services/CameraExtensionsProxy/src/com/android/cameraextensions/CameraExtensionsProxyService.java
@@ -22,6 +22,7 @@ import android.content.pm.PackageManager;
import android.graphics.GraphicBuffer;
import android.graphics.Rect;
import android.hardware.HardwareBuffer;
+import android.hardware.SyncFence;
import android.hardware.camera2.CameraAccessException;
import android.hardware.camera2.CameraCharacteristics;
import android.hardware.camera2.CameraExtensionCharacteristics;
@@ -2525,6 +2526,19 @@ public class CameraExtensionsProxyService extends Service {
}
@Override
+ public SyncFence getFence() {
+ if (mParcelImage.fence != null) {
+ try {
+ return SyncFence.create(mParcelImage.fence.dup());
+ } catch (IOException e) {
+ Log.e(TAG, "Failed to parcel buffer fence!");
+ }
+ }
+
+ return SyncFence.createEmpty();
+ }
+
+ @Override
protected final void finalize() throws Throwable {
try {
close();
diff --git a/ravenwood/Android.bp b/ravenwood/Android.bp
index 333fe4c8147f..8ff99e4af30d 100644
--- a/ravenwood/Android.bp
+++ b/ravenwood/Android.bp
@@ -94,6 +94,9 @@ java_library {
libs: [
"ravenwood-runtime-common-ravenwood",
],
+ static_libs: [
+ "framework-annotations-lib", // should it be "libs" instead?
+ ],
visibility: ["//visibility:private"],
}
@@ -126,9 +129,9 @@ java_library {
],
libs: [
"framework-minus-apex.ravenwood",
- "ravenwood-junit",
"ravenwood-helper-libcore-runtime",
],
+ sdk_version: "core_current",
visibility: ["//visibility:private"],
}
@@ -162,6 +165,8 @@ java_library {
"services.core.ravenwood",
"junit",
"framework-annotations-lib",
+ "ravenwood-helper-framework-runtime",
+ "ravenwood-helper-libcore-runtime",
],
sdk_version: "core_current",
visibility: ["//frameworks/base"],
diff --git a/ravenwood/TEST_MAPPING b/ravenwood/TEST_MAPPING
index 469759bc4b40..7f9d9c29484c 100644
--- a/ravenwood/TEST_MAPPING
+++ b/ravenwood/TEST_MAPPING
@@ -142,6 +142,10 @@
"host": true
},
{
+ "name": "RavenwoodCoreTest",
+ "host": true
+ },
+ {
"name": "RavenwoodMinimumTest",
"host": true
},
diff --git a/ravenwood/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodConfigTest.java b/ravenwood/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodConfigTest.java
new file mode 100644
index 000000000000..a5a16c14600b
--- /dev/null
+++ b/ravenwood/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodConfigTest.java
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2024 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.ravenwoodtest.bivalenttest;
+
+import static android.platform.test.ravenwood.RavenwoodConfig.isOnRavenwood;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assume.assumeTrue;
+
+import android.platform.test.ravenwood.RavenwoodConfig;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+/**
+ * Test to make sure the config field is used.
+ */
+@RunWith(AndroidJUnit4.class)
+public class RavenwoodConfigTest {
+ private static final String PACKAGE_NAME = "com.test";
+
+ @RavenwoodConfig.Config
+ public static RavenwoodConfig sConfig =
+ new RavenwoodConfig.Builder()
+ .setPackageName(PACKAGE_NAME)
+ .build();
+
+ @Test
+ public void testConfig() {
+ assumeTrue(isOnRavenwood());
+ assertEquals(PACKAGE_NAME,
+ InstrumentationRegistry.getInstrumentation().getContext().getPackageName());
+ }
+}
diff --git a/ravenwood/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodMultipleRuleTest.java b/ravenwood/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodMultipleRuleTest.java
new file mode 100644
index 000000000000..c25d2b4cbc4d
--- /dev/null
+++ b/ravenwood/bivalenttest/test/com/android/ravenwoodtest/bivalenttest/RavenwoodMultipleRuleTest.java
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2024 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.ravenwoodtest.bivalenttest;
+
+import android.platform.test.ravenwood.RavenwoodConfig;
+import android.platform.test.ravenwood.RavenwoodRule;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.Assume;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.ExpectedException;
+import org.junit.runner.RunWith;
+
+/**
+ * Make sure having multiple RavenwoodRule's is detected.
+ * (But only when running on ravenwod. Otherwise it'll be ignored.)
+ */
+@RunWith(AndroidJUnit4.class)
+public class RavenwoodMultipleRuleTest {
+
+ @Rule(order = Integer.MIN_VALUE)
+ public final ExpectedException mExpectedException = ExpectedException.none();
+
+ @Rule
+ public final RavenwoodRule mRavenwood1 = new RavenwoodRule();
+
+ @Rule
+ public final RavenwoodRule mRavenwood2 = new RavenwoodRule();
+
+ public RavenwoodMultipleRuleTest() {
+ // We can't call it within the test method because the exception happens before
+ // calling the method, so set it up here.
+ if (RavenwoodConfig.isOnRavenwood()) {
+ mExpectedException.expectMessage("Multiple nesting RavenwoodRule");
+ }
+ }
+
+ @Test
+ public void testMultipleRulesNotAllowed() {
+ Assume.assumeTrue(RavenwoodConfig.isOnRavenwood());
+ }
+}
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java
index 1d182da5e7fd..68472c12a568 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java
@@ -28,14 +28,20 @@ import android.util.Log;
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.internal.os.RuntimeInit;
+import com.android.platform.test.ravenwood.runtimehelper.ClassLoadHook;
import com.android.ravenwood.common.RavenwoodCommonUtils;
import org.junit.runner.Description;
-import org.junit.runner.Runner;
import org.junit.runners.model.TestClass;
/**
* Provide hook points created by {@link RavenwoodAwareTestRunner}.
+ *
+ * States are associated with each {@link RavenwoodAwareTestRunner} are stored in
+ * {@link RavenwoodRunnerState}, rather than as members of {@link RavenwoodAwareTestRunner}.
+ * See its javadoc for the reasons.
+ *
+ * All methods in this class must be called from the test main thread.
*/
public class RavenwoodAwareTestRunnerHook {
private static final String TAG = RavenwoodAwareTestRunner.TAG;
@@ -43,22 +49,10 @@ public class RavenwoodAwareTestRunnerHook {
private RavenwoodAwareTestRunnerHook() {
}
- private static RavenwoodTestStats sStats; // lazy initialization.
- private static Description sCurrentClassDescription;
-
- private static RavenwoodTestStats getStats() {
- if (sStats == null) {
- // We don't want to throw in the static initializer, because tradefed may not report
- // it properly, so we initialize it here.
- sStats = new RavenwoodTestStats();
- }
- return sStats;
- }
-
/**
* Called when a runner starts, before the inner runner gets a chance to run.
*/
- public static void onRunnerInitializing(Runner runner, TestClass testClass) {
+ public static void onRunnerInitializing(RavenwoodAwareTestRunner runner, TestClass testClass) {
// TODO: Move the initialization code to a better place.
initOnce();
@@ -82,6 +76,9 @@ public class RavenwoodAwareTestRunnerHook {
// We haven't initialized liblog yet, so directly write to System.out here.
RavenwoodCommonUtils.log(TAG, "initOnce()");
+ // Make sure libandroid_runtime is loaded.
+ ClassLoadHook.onClassLoaded(Log.class);
+
// Redirect stdout/stdin to liblog.
RuntimeInit.redirectLogStreams();
@@ -89,6 +86,10 @@ public class RavenwoodAwareTestRunnerHook {
System.setProperty("android.junit.runner",
"androidx.test.internal.runner.junit4.AndroidJUnit4ClassRunner");
System.setProperty(RAVENWOOD_VERSION_JAVA_SYSPROP, "1");
+
+ // Do the basic set up for the android sysprops.
+ RavenwoodRuntimeEnvironmentController.setSystemProperties(
+ RavenwoodSystemProperties.DEFAULT_VALUES);
}
/**
@@ -96,7 +97,29 @@ public class RavenwoodAwareTestRunnerHook {
*/
public static void onClassSkipped(Description description) {
Log.i(TAG, "onClassSkipped: description=" + description);
- getStats().onClassSkipped(description);
+ RavenwoodTestStats.getInstance().onClassSkipped(description);
+ }
+
+ /**
+ * Called before the inner runner starts.
+ */
+ public static void onBeforeInnerRunnerStart(
+ RavenwoodAwareTestRunner runner, Description description) throws Throwable {
+ Log.v(TAG, "onBeforeInnerRunnerStart: description=" + description);
+
+ // Prepare the environment before the inner runner starts.
+ RavenwoodRunnerState.forRunner(runner).enterTestClass(description);
+ }
+
+ /**
+ * Called after the inner runner finished.
+ */
+ public static void onAfterInnerRunnerFinished(
+ RavenwoodAwareTestRunner runner, Description description) throws Throwable {
+ Log.v(TAG, "onAfterInnerRunnerFinished: description=" + description);
+
+ RavenwoodTestStats.getInstance().onClassFinished(description);
+ RavenwoodRunnerState.forRunner(runner).exitTestClass();
}
/**
@@ -105,20 +128,23 @@ public class RavenwoodAwareTestRunnerHook {
* Return false if it should be skipped.
*/
public static boolean onBefore(RavenwoodAwareTestRunner runner, Description description,
- Scope scope, Order order) {
+ Scope scope, Order order) throws Throwable {
Log.v(TAG, "onBefore: description=" + description + ", " + scope + ", " + order);
- if (scope == Scope.Class && order == Order.First) {
- // Keep track of the current class.
- sCurrentClassDescription = description;
+ if (scope == Scope.Instance && order == Order.Outer) {
+ // Start of a test method.
+ RavenwoodRunnerState.forRunner(runner).enterTestMethod(description);
}
+ final var classDescription = RavenwoodRunnerState.forRunner(runner).getClassDescription();
+
// Class-level annotations are checked by the runner already, so we only check
// method-level annotations here.
- if (scope == Scope.Instance && order == Order.First) {
+ if (scope == Scope.Instance && order == Order.Outer) {
if (!RavenwoodEnablementChecker.shouldEnableOnRavenwood(
description, true)) {
- getStats().onTestFinished(sCurrentClassDescription, description, Result.Skipped);
+ RavenwoodTestStats.getInstance().onTestFinished(
+ classDescription, description, Result.Skipped);
return false;
}
}
@@ -134,17 +160,18 @@ public class RavenwoodAwareTestRunnerHook {
Scope scope, Order order, Throwable th) {
Log.v(TAG, "onAfter: description=" + description + ", " + scope + ", " + order + ", " + th);
- if (scope == Scope.Instance && order == Order.First) {
- getStats().onTestFinished(sCurrentClassDescription, description,
- th == null ? Result.Passed : Result.Failed);
+ final var classDescription = RavenwoodRunnerState.forRunner(runner).getClassDescription();
- } else if (scope == Scope.Class && order == Order.Last) {
- getStats().onClassFinished(sCurrentClassDescription);
+ if (scope == Scope.Instance && order == Order.Outer) {
+ // End of a test method.
+ RavenwoodRunnerState.forRunner(runner).exitTestMethod();
+ RavenwoodTestStats.getInstance().onTestFinished(classDescription, description,
+ th == null ? Result.Passed : Result.Failed);
}
// If RUN_DISABLED_TESTS is set, and the method did _not_ throw, make it an error.
if (RavenwoodRule.private$ravenwood().isRunningDisabledTests()
- && scope == Scope.Instance && order == Order.First) {
+ && scope == Scope.Instance && order == Order.Outer) {
boolean isTestEnabled = RavenwoodEnablementChecker.shouldEnableOnRavenwood(
description, false);
@@ -179,4 +206,25 @@ public class RavenwoodAwareTestRunnerHook {
public static boolean shouldRunClassOnRavenwood(Class<?> clazz) {
return RavenwoodEnablementChecker.shouldRunClassOnRavenwood(clazz, true);
}
-}
+
+ /**
+ * Called by RavenwoodRule.
+ */
+ public static void onRavenwoodRuleEnter(RavenwoodAwareTestRunner runner,
+ Description description, RavenwoodRule rule) throws Throwable {
+ Log.v(TAG, "onRavenwoodRuleEnter: description=" + description);
+
+ RavenwoodRunnerState.forRunner(runner).enterRavenwoodRule(rule);
+ }
+
+
+ /**
+ * Called by RavenwoodRule.
+ */
+ public static void onRavenwoodRuleExit(RavenwoodAwareTestRunner runner,
+ Description description, RavenwoodRule rule) throws Throwable {
+ Log.v(TAG, "onRavenwoodRuleExit: description=" + description);
+
+ RavenwoodRunnerState.forRunner(runner).exitRavenwoodRule(rule);
+ }
+} \ No newline at end of file
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRunnerState.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRunnerState.java
new file mode 100644
index 000000000000..d73afd4c391b
--- /dev/null
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRunnerState.java
@@ -0,0 +1,252 @@
+/*
+ * Copyright (C) 2024 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 android.platform.test.ravenwood;
+
+import static com.android.ravenwood.common.RavenwoodCommonUtils.ensureIsPublicMember;
+
+import static org.junit.Assert.fail;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+
+import com.android.internal.annotations.GuardedBy;
+import com.android.ravenwood.common.RavenwoodRuntimeException;
+
+import org.junit.ClassRule;
+import org.junit.Rule;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+
+import java.io.IOException;
+import java.lang.reflect.Field;
+import java.util.WeakHashMap;
+
+/**
+ * Used to store various states associated with the current test runner.
+ *
+ * This class could be added to {@link RavenwoodAwareTestRunner} as a field, but we don't
+ * want to put it in junit-src/ (for one, that'll cause all the downstream dependencies to be
+ * rebuilt when this file is updated), so we manage it separately using a Map from each
+ * {@link RavenwoodAwareTestRunner} instance to a {@link RavenwoodRunnerState}.
+ *
+ * All members must be called from the runner's main thread.
+ */
+public final class RavenwoodRunnerState {
+ private static final String TAG = "RavenwoodRunnerState";
+
+ @GuardedBy("sStates")
+ private static final WeakHashMap<RavenwoodAwareTestRunner, RavenwoodRunnerState> sStates =
+ new WeakHashMap<>();
+
+ /**
+ * Get the instance for a given runner.
+ */
+ public static RavenwoodRunnerState forRunner(@NonNull RavenwoodAwareTestRunner runner) {
+ synchronized (sStates) {
+ var ret = sStates.get(runner);
+ if (ret == null) {
+ ret = new RavenwoodRunnerState(runner);
+ sStates.put(runner, ret);
+ }
+ return ret;
+ }
+ }
+
+ private final RavenwoodAwareTestRunner mRunner;
+
+ private RavenwoodRunnerState(RavenwoodAwareTestRunner runner) {
+ mRunner = runner;
+ }
+
+ private Description mClassDescription;
+ private Description mMethodDescription;
+
+ private RavenwoodConfig mCurrentConfig;
+ private RavenwoodRule mCurrentRule;
+
+ public Description getClassDescription() {
+ return mClassDescription;
+ }
+
+ public void enterTestClass(Description classDescription) throws IOException {
+ mClassDescription = classDescription;
+
+ mCurrentConfig = extractConfiguration(mRunner.getTestClass().getJavaClass());
+
+ if (mCurrentConfig != null) {
+ RavenwoodRuntimeEnvironmentController.init(mCurrentConfig);
+ }
+ }
+
+ public void exitTestClass() {
+ if (mCurrentConfig != null) {
+ try {
+ RavenwoodRuntimeEnvironmentController.reset();
+ } finally {
+ mClassDescription = null;
+ }
+ }
+ }
+
+ public void enterTestMethod(Description description) {
+ mMethodDescription = description;
+ }
+
+ public void exitTestMethod() {
+ mMethodDescription = null;
+ }
+
+ public void enterRavenwoodRule(RavenwoodRule rule) throws IOException {
+ if (mCurrentConfig != null) {
+ fail("RavenwoodConfiguration and RavenwoodRule cannot be used in the same class."
+ + " Suggest migrating to RavenwoodConfiguration.");
+ }
+ if (mCurrentRule != null) {
+ fail("Multiple nesting RavenwoodRule's are detected in the same class,"
+ + " which is not supported.");
+ }
+ mCurrentRule = rule;
+ RavenwoodRuntimeEnvironmentController.init(rule.getConfiguration());
+ }
+
+ public void exitRavenwoodRule(RavenwoodRule rule) {
+ if (mCurrentRule != rule) {
+ return; // This happens if the rule did _not_ take effect somehow.
+ }
+
+ try {
+ RavenwoodRuntimeEnvironmentController.reset();
+ } finally {
+ mCurrentRule = null;
+ }
+ }
+
+ /**
+ * @return a configuration from a test class, if any.
+ */
+ @Nullable
+ private static RavenwoodConfig extractConfiguration(Class<?> testClass) {
+ final boolean hasRavenwoodRule = hasRavenwoodRule(testClass);
+
+ var field = findConfigurationField(testClass);
+ if (field == null) {
+ return null;
+ }
+ if (hasRavenwoodRule) {
+ fail("RavenwoodConfiguration and RavenwoodRule cannot be used in the same class."
+ + " Suggest migrating to RavenwoodConfiguration.");
+ }
+
+ try {
+ return (RavenwoodConfig) field.get(null);
+ } catch (IllegalAccessException e) {
+ throw new RavenwoodRuntimeException("Failed to fetch from the configuration field", e);
+ }
+ }
+
+ /**
+ * @return true if the current target class (or its super classes) has any @Rule / @ClassRule
+ * fields of type RavenwoodRule.
+ *
+ * Note, this check won't detect cases where a Rule is of type
+ * {@link TestRule} and still be a {@link RavenwoodRule}. But that'll be detected at runtime
+ * as a failure, in {@link #enterRavenwoodRule}.
+ */
+ private static boolean hasRavenwoodRule(Class<?> testClass) {
+ for (var field : testClass.getDeclaredFields()) {
+ if (!field.isAnnotationPresent(Rule.class)
+ && field.isAnnotationPresent(ClassRule.class)) {
+ continue;
+ }
+ if (field.getType().equals(RavenwoodRule.class)) {
+ return true;
+ }
+ }
+ // JUnit supports rules as methods, so we need to check them too.
+ for (var method : testClass.getDeclaredMethods()) {
+ if (!method.isAnnotationPresent(Rule.class)
+ && method.isAnnotationPresent(ClassRule.class)) {
+ continue;
+ }
+ if (method.getReturnType().equals(RavenwoodRule.class)) {
+ return true;
+ }
+ }
+ // Look into the super class.
+ if (!testClass.getSuperclass().equals(Object.class)) {
+ return hasRavenwoodRule(testClass.getSuperclass());
+ }
+ return false;
+ }
+
+ /**
+ * Find and return a field with @RavenwoodConfiguration.Config, which must be of type
+ * RavenwoodConfiguration.
+ */
+ @Nullable
+ private static Field findConfigurationField(Class<?> testClass) {
+ Field foundField = null;
+
+ for (var field : testClass.getDeclaredFields()) {
+ final var hasAnot = field.isAnnotationPresent(RavenwoodConfig.Config.class);
+ final var isType = field.getType().equals(RavenwoodConfig.class);
+
+ if (hasAnot) {
+ if (isType) {
+ // Good, use this field.
+ if (foundField != null) {
+ fail(String.format(
+ "Class %s has multiple fields with %s",
+ testClass.getCanonicalName(),
+ "@RavenwoodConfiguration.Config"));
+ }
+ // Make sure it's static public
+ ensureIsPublicMember(field, true);
+
+ foundField = field;
+ } else {
+ fail(String.format(
+ "Field %s.%s has %s but type is not %s",
+ testClass.getCanonicalName(),
+ field.getName(),
+ "@RavenwoodConfiguration.Config",
+ "RavenwoodConfiguration"));
+ return null; // unreachable
+ }
+ } else {
+ if (isType) {
+ fail(String.format(
+ "Field %s.%s does not have %s but type is %s",
+ testClass.getCanonicalName(),
+ field.getName(),
+ "@RavenwoodConfiguration.Config",
+ "RavenwoodConfiguration"));
+ return null; // unreachable
+ } else {
+ // Unrelated field, ignore.
+ continue;
+ }
+ }
+ }
+ if (foundField != null) {
+ return foundField;
+ }
+ if (!testClass.getSuperclass().equals(Object.class)) {
+ return findConfigurationField(testClass.getSuperclass());
+ }
+ return null;
+ }
+}
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java
index 0059360a0a29..03c9001366e9 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodRuntimeEnvironmentController.java
@@ -18,6 +18,7 @@ package android.platform.test.ravenwood;
import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_EMPTY_RESOURCES_APK;
import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_RESOURCE_APK;
+import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERBOSE_LOGGING;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
@@ -26,6 +27,7 @@ import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.ResourcesManager;
import android.content.res.Resources;
+import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.HandlerThread;
@@ -36,6 +38,8 @@ import android.view.DisplayAdjustments;
import androidx.test.platform.app.InstrumentationRegistry;
+import com.android.ravenwood.common.RavenwoodRuntimeException;
+import com.android.ravenwood.common.SneakyThrow;
import com.android.server.LocalServices;
import org.junit.runner.Description;
@@ -52,14 +56,25 @@ import java.util.concurrent.TimeUnit;
import java.util.concurrent.atomic.AtomicReference;
import java.util.function.Supplier;
-public class RavenwoodRuleImpl {
+/**
+ * Responsible for initializing and de-initializing the environment, according to a
+ * {@link RavenwoodConfig}.
+ */
+public class RavenwoodRuntimeEnvironmentController {
+ private static final String TAG = "RavenwoodRuntimeEnvironmentController";
+
+ private RavenwoodRuntimeEnvironmentController() {
+ }
+
private static final String MAIN_THREAD_NAME = "RavenwoodMain";
/**
* When enabled, attempt to dump all thread stacks just before we hit the
* overall Tradefed timeout, to aid in debugging deadlocks.
*/
- private static final boolean ENABLE_TIMEOUT_STACKS = false;
+ private static final boolean ENABLE_TIMEOUT_STACKS =
+ "1".equals(System.getenv("RAVENWOOD_ENABLE_TIMEOUT_STACKS"));
+
private static final int TIMEOUT_MILLIS = 9_000;
private static final ScheduledExecutorService sTimeoutExecutor =
@@ -67,10 +82,13 @@ public class RavenwoodRuleImpl {
private static ScheduledFuture<?> sPendingTimeout;
+ private static long sOriginalIdentityToken = -1;
+
/**
* When enabled, attempt to detect uncaught exceptions from background threads.
*/
- private static final boolean ENABLE_UNCAUGHT_EXCEPTION_DETECTION = false;
+ private static final boolean ENABLE_UNCAUGHT_EXCEPTION_DETECTION =
+ "1".equals(System.getenv("RAVENWOOD_ENABLE_UNCAUGHT_EXCEPTION_DETECTION"));
/**
* When set, an unhandled exception was discovered (typically on a background thread), and we
@@ -85,23 +103,59 @@ public class RavenwoodRuleImpl {
sPendingUncaughtException.compareAndSet(null, throwable);
};
- public static void init(RavenwoodRule rule) throws IOException {
+ // TODO: expose packCallingIdentity function in libbinder and use it directly
+ // See: packCallingIdentity in frameworks/native/libs/binder/IPCThreadState.cpp
+ private static long packBinderIdentityToken(
+ boolean hasExplicitIdentity, int callingUid, int callingPid) {
+ long res = ((long) callingUid << 32) | callingPid;
+ if (hasExplicitIdentity) {
+ res |= (0x1 << 30);
+ } else {
+ res &= ~(0x1 << 30);
+ }
+ return res;
+ }
+
+ private static RavenwoodConfig sConfig;
+
+ /**
+ * Initialize the environment.
+ */
+ public static void init(RavenwoodConfig config) throws IOException {
+ if (RAVENWOOD_VERBOSE_LOGGING) {
+ Log.i(TAG, "init() called here", new RuntimeException("STACKTRACE"));
+ }
+ try {
+ initInner(config);
+ } catch (Exception th) {
+ Log.e(TAG, "init() failed", th);
+ reset();
+ SneakyThrow.sneakyThrow(th);
+ }
+ }
+
+ private static void initInner(RavenwoodConfig config) throws IOException {
+ if (sConfig != null) {
+ throw new RavenwoodRuntimeException("Internal error: init() called without reset()");
+ }
+ sConfig = config;
if (ENABLE_UNCAUGHT_EXCEPTION_DETECTION) {
maybeThrowPendingUncaughtException(false);
Thread.setDefaultUncaughtExceptionHandler(sUncaughtExceptionHandler);
}
- android.os.Process.init$ravenwood(rule.mUid, rule.mPid);
- android.os.Binder.init$ravenwood();
- setSystemProperties(rule.mSystemProperties);
+ android.os.Process.init$ravenwood(config.mUid, config.mPid);
+ sOriginalIdentityToken = Binder.clearCallingIdentity();
+ Binder.restoreCallingIdentity(packBinderIdentityToken(false, config.mUid, config.mPid));
+ setSystemProperties(config.mSystemProperties);
ServiceManager.init$ravenwood();
LocalServices.removeAllServicesForTest();
- ActivityManager.init$ravenwood(rule.mCurrentUser);
+ ActivityManager.init$ravenwood(config.mCurrentUser);
final HandlerThread main;
- if (rule.mProvideMainThread) {
+ if (config.mProvideMainThread) {
main = new HandlerThread(MAIN_THREAD_NAME);
main.start();
Looper.setMainLooperForTest(main.getLooper());
@@ -125,21 +179,22 @@ public class RavenwoodRuleImpl {
emptyPaths, emptyPaths, emptyPaths,
emptyPaths, null, null,
new DisplayAdjustments().getCompatibilityInfo(),
- RavenwoodRuleImpl.class.getClassLoader(), null);
+ RavenwoodRuntimeEnvironmentController.class.getClassLoader(), null);
assertNotNull(ret);
return ret;
};
- rule.mContext = new RavenwoodContext(rule.mPackageName, main, resourcesSupplier);
- rule.mInstrumentation = new Instrumentation();
- rule.mInstrumentation.basicInit(rule.mContext);
- InstrumentationRegistry.registerInstance(rule.mInstrumentation, Bundle.EMPTY);
+ config.mContext = new RavenwoodContext(config.mPackageName, main, resourcesSupplier);
+ config.mInstrumentation = new Instrumentation();
+ config.mInstrumentation.basicInit(config.mContext);
+ InstrumentationRegistry.registerInstance(config.mInstrumentation, Bundle.EMPTY);
- RavenwoodSystemServer.init(rule);
+ RavenwoodSystemServer.init(config);
if (ENABLE_TIMEOUT_STACKS) {
- sPendingTimeout = sTimeoutExecutor.schedule(RavenwoodRuleImpl::dumpStacks,
+ sPendingTimeout = sTimeoutExecutor.schedule(
+ RavenwoodRuntimeEnvironmentController::dumpStacks,
TIMEOUT_MILLIS, TimeUnit.MILLISECONDS);
}
@@ -148,21 +203,33 @@ public class RavenwoodRuleImpl {
Objects.requireNonNull(Build.VERSION.SDK);
}
- public static void reset(RavenwoodRule rule) {
+ /**
+ * De-initialize.
+ */
+ public static void reset() {
+ if (RAVENWOOD_VERBOSE_LOGGING) {
+ Log.i(TAG, "reset() called here", new RuntimeException("STACKTRACE"));
+ }
+ if (sConfig == null) {
+ throw new RavenwoodRuntimeException("Internal error: reset() already called");
+ }
+ var config = sConfig;
+ sConfig = null;
+
if (ENABLE_TIMEOUT_STACKS) {
sPendingTimeout.cancel(false);
}
- RavenwoodSystemServer.reset(rule);
+ RavenwoodSystemServer.reset(config);
InstrumentationRegistry.registerInstance(null, Bundle.EMPTY);
- rule.mInstrumentation = null;
- if (rule.mContext != null) {
- ((RavenwoodContext) rule.mContext).cleanUp();
+ config.mInstrumentation = null;
+ if (config.mContext != null) {
+ ((RavenwoodContext) config.mContext).cleanUp();
}
- rule.mContext = null;
+ config.mContext = null;
- if (rule.mProvideMainThread) {
+ if (config.mProvideMainThread) {
Looper.getMainLooper().quit();
Looper.clearMainLooperForTest();
}
@@ -173,7 +240,7 @@ public class RavenwoodRuleImpl {
ServiceManager.reset$ravenwood();
setSystemProperties(RavenwoodSystemProperties.DEFAULT_VALUES);
- android.os.Binder.reset$ravenwood();
+ Binder.restoreCallingIdentity(sOriginalIdentityToken);
android.os.Process.reset$ravenwood();
ResourcesManager.setInstance(null); // Better structure needed.
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java
index cd6b61df392f..f3a93c1dacad 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodSystemServer.java
@@ -61,19 +61,19 @@ public class RavenwoodSystemServer {
private static TimingsTraceAndSlog sTimings;
private static SystemServiceManager sServiceManager;
- public static void init(RavenwoodRule rule) {
+ public static void init(RavenwoodConfig config) {
// Avoid overhead if no services required
- if (rule.mServicesRequired.isEmpty()) return;
+ if (config.mServicesRequired.isEmpty()) return;
sStartedServices = new ArraySet<>();
sTimings = new TimingsTraceAndSlog();
- sServiceManager = new SystemServiceManager(rule.mContext);
+ sServiceManager = new SystemServiceManager(config.mContext);
sServiceManager.setStartInfo(false,
SystemClock.elapsedRealtime(),
SystemClock.uptimeMillis());
LocalServices.addService(SystemServiceManager.class, sServiceManager);
- startServices(rule.mServicesRequired);
+ startServices(config.mServicesRequired);
sServiceManager.sealStartedServices();
// TODO: expand to include additional boot phases when relevant
@@ -81,7 +81,7 @@ public class RavenwoodSystemServer {
sServiceManager.startBootPhase(sTimings, SystemService.PHASE_BOOT_COMPLETED);
}
- public static void reset(RavenwoodRule rule) {
+ public static void reset(RavenwoodConfig config) {
// TODO: consider introducing shutdown boot phases
LocalServices.removeServiceForTest(SystemServiceManager.class);
diff --git a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodTestStats.java b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodTestStats.java
index 631f68ff1dec..428eb57f20bf 100644
--- a/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodTestStats.java
+++ b/ravenwood/junit-impl-src/android/platform/test/ravenwood/RavenwoodTestStats.java
@@ -31,7 +31,7 @@ import java.util.HashMap;
import java.util.Map;
/**
- * Creats a "stats" CSV file containing the test results.
+ * Collect test result stats and write them into a CSV file containing the test results.
*
* The output file is created as `/tmp/Ravenwood-stats_[TEST-MODULE=NAME]_[TIMESTAMP].csv`.
* A symlink to the latest result will be created as
@@ -41,6 +41,21 @@ public class RavenwoodTestStats {
private static final String TAG = "RavenwoodTestStats";
private static final String HEADER = "Module,Class,ClassDesc,Passed,Failed,Skipped";
+ private static RavenwoodTestStats sInstance;
+
+ /**
+ * @return a singleton instance.
+ */
+ public static RavenwoodTestStats getInstance() {
+ if (sInstance == null) {
+ sInstance = new RavenwoodTestStats();
+ }
+ return sInstance;
+ }
+
+ /**
+ * Represents a test result.
+ */
public enum Result {
Passed,
Failed,
@@ -113,21 +128,34 @@ public class RavenwoodTestStats {
});
}
+ /**
+ * Call it when a test class is skipped.
+ */
public void onClassSkipped(Description classDescription) {
addResult(classDescription, Description.EMPTY, Result.Skipped);
onClassFinished(classDescription);
}
+ /**
+ * Call it when a test method is finished.
+ */
public void onTestFinished(Description classDescription, Description testDescription,
Result result) {
addResult(classDescription, testDescription, result);
}
+ /**
+ * Call it when a test class is finished.
+ */
public void onClassFinished(Description classDescription) {
int passed = 0;
int skipped = 0;
int failed = 0;
- for (var e : mStats.get(classDescription).values()) {
+ var stats = mStats.get(classDescription);
+ if (stats == null) {
+ return;
+ }
+ for (var e : stats.values()) {
switch (e) {
case Passed: passed++; break;
case Skipped: skipped++; break;
diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodAwareTestRunner.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodAwareTestRunner.java
index bfde9cb7099e..bc944d76018d 100644
--- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodAwareTestRunner.java
+++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodAwareTestRunner.java
@@ -15,20 +15,23 @@
*/
package android.platform.test.ravenwood;
+import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERBOSE_LOGGING;
import static com.android.ravenwood.common.RavenwoodCommonUtils.ensureIsPublicVoidMethod;
import static com.android.ravenwood.common.RavenwoodCommonUtils.isOnRavenwood;
import static java.lang.annotation.ElementType.METHOD;
import static java.lang.annotation.ElementType.TYPE;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.util.Log;
-import com.android.ravenwood.common.SneakyThrow;
-
import org.junit.Assume;
+import org.junit.AssumptionViolatedException;
import org.junit.internal.builders.AllDefaultPossibilitiesBuilder;
import org.junit.rules.TestRule;
import org.junit.runner.Description;
+import org.junit.runner.Result;
import org.junit.runner.Runner;
import org.junit.runner.manipulation.Filter;
import org.junit.runner.manipulation.Filterable;
@@ -39,8 +42,11 @@ import org.junit.runner.manipulation.Orderer;
import org.junit.runner.manipulation.Sortable;
import org.junit.runner.manipulation.Sorter;
import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunListener;
import org.junit.runner.notification.RunNotifier;
+import org.junit.runner.notification.StoppedByUserException;
import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.MultipleFailureException;
import org.junit.runners.model.RunnerBuilder;
import org.junit.runners.model.Statement;
import org.junit.runners.model.TestClass;
@@ -51,6 +57,9 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
import java.lang.reflect.InvocationTargetException;
+import java.util.ArrayList;
+import java.util.Stack;
+import java.util.function.BiConsumer;
/**
* A test runner used for Ravenwood.
@@ -61,7 +70,7 @@ import java.lang.reflect.InvocationTargetException;
* the inner runner gets a chance to run. This can be used to initialize stuff used by the
* inner runner.
* - Add hook points, which are handed by RavenwoodAwareTestRunnerHook, with help from
- * the four test rules such as {@link #sImplicitClassMinRule}, which are also injected by
+ * the four test rules such as {@link #sImplicitClassOuterRule}, which are also injected by
* the ravenizer tool.
*
* We use this runner to:
@@ -73,7 +82,7 @@ import java.lang.reflect.InvocationTargetException;
* it will basically just delegate to the inner wrapper, and won't do anything special.
* (no hooks, etc.)
*/
-public class RavenwoodAwareTestRunner extends Runner implements Filterable, Orderable {
+public final class RavenwoodAwareTestRunner extends Runner implements Filterable, Orderable {
public static final String TAG = "Ravenwood";
@Inherited
@@ -95,40 +104,61 @@ public class RavenwoodAwareTestRunner extends Runner implements Filterable, Orde
/** Scope of a hook. */
public enum Scope {
- Runner,
Class,
Instance,
}
/** Order of a hook. */
public enum Order {
- First,
- Last,
+ Outer,
+ Inner,
}
// The following four rule instances will be injected to tests by the Ravenizer tool.
+ private static class RavenwoodClassOuterRule implements TestRule {
+ @Override
+ public Statement apply(Statement base, Description description) {
+ return getCurrentRunner().wrapWithHooks(base, description, Scope.Class, Order.Outer);
+ }
+ }
- public static final TestRule sImplicitClassMinRule = (base, description) ->
- getCurrentRunner().updateStatement(base, description, Scope.Class, Order.First);
+ private static class RavenwoodClassInnerRule implements TestRule {
+ @Override
+ public Statement apply(Statement base, Description description) {
+ return getCurrentRunner().wrapWithHooks(base, description, Scope.Class, Order.Inner);
+ }
+ }
- public static final TestRule sImplicitClassMaxRule = (base, description) ->
- getCurrentRunner().updateStatement(base, description, Scope.Class, Order.Last);
+ private static class RavenwoodInstanceOuterRule implements TestRule {
+ @Override
+ public Statement apply(Statement base, Description description) {
+ return getCurrentRunner().wrapWithHooks(
+ base, description, Scope.Instance, Order.Outer);
+ }
+ }
- public static final TestRule sImplicitInstMinRule = (base, description) ->
- getCurrentRunner().updateStatement(base, description, Scope.Instance, Order.First);
+ private static class RavenwoodInstanceInnerRule implements TestRule {
+ @Override
+ public Statement apply(Statement base, Description description) {
+ return getCurrentRunner().wrapWithHooks(
+ base, description, Scope.Instance, Order.Inner);
+ }
+ }
- public static final TestRule sImplicitInstMaxRule = (base, description) ->
- getCurrentRunner().updateStatement(base, description, Scope.Instance, Order.Last);
+ public static final TestRule sImplicitClassOuterRule = new RavenwoodClassOuterRule();
+ public static final TestRule sImplicitClassInnerRule = new RavenwoodClassInnerRule();
+ public static final TestRule sImplicitInstOuterRule = new RavenwoodInstanceOuterRule();
+ public static final TestRule sImplicitInstInnerRule = new RavenwoodInstanceOuterRule();
- public static final String IMPLICIT_CLASS_MIN_RULE_NAME = "sImplicitClassMinRule";
- public static final String IMPLICIT_CLASS_MAX_RULE_NAME = "sImplicitClassMaxRule";
- public static final String IMPLICIT_INST_MIN_RULE_NAME = "sImplicitInstMinRule";
- public static final String IMPLICIT_INST_MAX_RULE_NAME = "sImplicitInstMaxRule";
+ public static final String IMPLICIT_CLASS_OUTER_RULE_NAME = "sImplicitClassOuterRule";
+ public static final String IMPLICIT_CLASS_INNER_RULE_NAME = "sImplicitClassInnerRule";
+ public static final String IMPLICIT_INST_OUTER_RULE_NAME = "sImplicitInstOuterRule";
+ public static final String IMPLICIT_INST_INNER_RULE_NAME = "sImplicitInstInnerRule";
/** Keeps track of the runner on the current thread. */
private static final ThreadLocal<RavenwoodAwareTestRunner> sCurrentRunner = new ThreadLocal<>();
- private static RavenwoodAwareTestRunner getCurrentRunner() {
+ static RavenwoodAwareTestRunner getCurrentRunner() {
var runner = sCurrentRunner.get();
if (runner == null) {
throw new RuntimeException("Current test runner not set!");
@@ -157,6 +187,8 @@ public class RavenwoodAwareTestRunner extends Runner implements Filterable, Orde
try {
mTestClass = new TestClass(testClass);
+ Log.v(TAG, "RavenwoodAwareTestRunner starting for " + testClass.getCanonicalName());
+
onRunnerInitializing();
/*
@@ -261,23 +293,46 @@ public class RavenwoodAwareTestRunner extends Runner implements Filterable, Orde
}
@Override
- public void run(RunNotifier notifier) {
+ public void run(RunNotifier realNotifier) {
+ final RavenwoodRunNotifier notifier = new RavenwoodRunNotifier(realNotifier);
+
if (mRealRunner instanceof ClassSkippingTestRunner) {
mRealRunner.run(notifier);
RavenwoodAwareTestRunnerHook.onClassSkipped(getDescription());
return;
}
+ Log.v(TAG, "Starting " + mTestClass.getJavaClass().getCanonicalName());
+ if (RAVENWOOD_VERBOSE_LOGGING) {
+ dumpDescription(getDescription());
+ }
+
if (maybeReportExceptionFromConstructor(notifier)) {
return;
}
sCurrentRunner.set(this);
try {
- runWithHooks(getDescription(), Scope.Runner, Order.First,
- () -> mRealRunner.run(notifier));
+ try {
+ RavenwoodAwareTestRunnerHook.onBeforeInnerRunnerStart(
+ this, getDescription());
+ } catch (Throwable th) {
+ notifier.reportBeforeTestFailure(getDescription(), th);
+ return;
+ }
+
+ // Delegate to the inner runner.
+ mRealRunner.run(notifier);
} finally {
sCurrentRunner.remove();
+
+ try {
+ RavenwoodAwareTestRunnerHook.onAfterInnerRunnerFinished(
+ this, getDescription());
+ } catch (Throwable th) {
+ notifier.reportAfterTestFailure(th);
+ return;
+ }
}
}
@@ -314,7 +369,7 @@ public class RavenwoodAwareTestRunner extends Runner implements Filterable, Orde
}
}
- private Statement updateStatement(Statement base, Description description, Scope scope,
+ private Statement wrapWithHooks(Statement base, Description description, Scope scope,
Order order) {
if (!isOnRavenwood()) {
return base;
@@ -327,7 +382,8 @@ public class RavenwoodAwareTestRunner extends Runner implements Filterable, Orde
};
}
- private void runWithHooks(Description description, Scope scope, Order order, Runnable r) {
+ private void runWithHooks(Description description, Scope scope, Order order, Runnable r)
+ throws Throwable {
runWithHooks(description, scope, order, new Statement() {
@Override
public void evaluate() throws Throwable {
@@ -336,7 +392,8 @@ public class RavenwoodAwareTestRunner extends Runner implements Filterable, Orde
});
}
- private void runWithHooks(Description description, Scope scope, Order order, Statement s) {
+ private void runWithHooks(Description description, Scope scope, Order order, Statement s)
+ throws Throwable {
if (isOnRavenwood()) {
Assume.assumeTrue(
RavenwoodAwareTestRunnerHook.onBefore(this, description, scope, order));
@@ -353,7 +410,7 @@ public class RavenwoodAwareTestRunner extends Runner implements Filterable, Orde
this, description, scope, order, t);
}
if (shouldThrow) {
- SneakyThrow.sneakyThrow(t);
+ throw t;
}
}
}
@@ -399,4 +456,254 @@ public class RavenwoodAwareTestRunner extends Runner implements Filterable, Orde
}
}
}
+
+ private void dumpDescription(Description desc) {
+ dumpDescription(desc, "[TestDescription]=", " ");
+ }
+
+ private void dumpDescription(Description desc, String header, String indent) {
+ Log.v(TAG, indent + header + desc);
+
+ var children = desc.getChildren();
+ var childrenIndent = " " + indent;
+ for (int i = 0; i < children.size(); i++) {
+ dumpDescription(children.get(i), "#" + i + ": ", childrenIndent);
+ }
+ }
+
+ /**
+ * A run notifier that wraps another notifier and provides the following features:
+ * - Handle a failure that happened before testStarted and testEnded (typically that means
+ * it's from @BeforeClass or @AfterClass, or a @ClassRule) and deliver it as if
+ * individual tests in the class reported it. This is for b/364395552.
+ *
+ * - Logging.
+ */
+ private class RavenwoodRunNotifier extends RunNotifier {
+ private final RunNotifier mRealNotifier;
+
+ private final Stack<Description> mSuiteStack = new Stack<>();
+ private Description mCurrentSuite = null;
+ private final ArrayList<Throwable> mOutOfTestFailures = new ArrayList<>();
+
+ private boolean mBeforeTest = true;
+ private boolean mAfterTest = false;
+
+ private RavenwoodRunNotifier(RunNotifier realNotifier) {
+ mRealNotifier = realNotifier;
+ }
+
+ private boolean isInTest() {
+ return !mBeforeTest && !mAfterTest;
+ }
+
+ @Override
+ public void addListener(RunListener listener) {
+ mRealNotifier.addListener(listener);
+ }
+
+ @Override
+ public void removeListener(RunListener listener) {
+ mRealNotifier.removeListener(listener);
+ }
+
+ @Override
+ public void addFirstListener(RunListener listener) {
+ mRealNotifier.addFirstListener(listener);
+ }
+
+ @Override
+ public void fireTestRunStarted(Description description) {
+ Log.i(TAG, "testRunStarted: " + description);
+ mRealNotifier.fireTestRunStarted(description);
+ }
+
+ @Override
+ public void fireTestRunFinished(Result result) {
+ Log.i(TAG, "testRunFinished: "
+ + result.getRunCount() + ","
+ + result.getFailureCount() + ","
+ + result.getAssumptionFailureCount() + ","
+ + result.getIgnoreCount());
+ mRealNotifier.fireTestRunFinished(result);
+ }
+
+ @Override
+ public void fireTestSuiteStarted(Description description) {
+ Log.i(TAG, "testSuiteStarted: " + description);
+ mRealNotifier.fireTestSuiteStarted(description);
+
+ mBeforeTest = true;
+ mAfterTest = false;
+
+ // Keep track of the current suite, needed if the outer test is a Suite,
+ // in which case its children are test classes. (not test methods)
+ mCurrentSuite = description;
+ mSuiteStack.push(description);
+
+ mOutOfTestFailures.clear();
+ }
+
+ @Override
+ public void fireTestSuiteFinished(Description description) {
+ Log.i(TAG, "testSuiteFinished: " + description);
+ mRealNotifier.fireTestSuiteFinished(description);
+
+ maybeHandleOutOfTestFailures();
+
+ mBeforeTest = true;
+ mAfterTest = false;
+
+ // Restore the upper suite.
+ mSuiteStack.pop();
+ mCurrentSuite = mSuiteStack.size() == 0 ? null : mSuiteStack.peek();
+ }
+
+ @Override
+ public void fireTestStarted(Description description) throws StoppedByUserException {
+ Log.i(TAG, "testStarted: " + description);
+ mRealNotifier.fireTestStarted(description);
+
+ mAfterTest = false;
+ mBeforeTest = false;
+ }
+
+ @Override
+ public void fireTestFailure(Failure failure) {
+ Log.i(TAG, "testFailure: " + failure);
+
+ if (isInTest()) {
+ mRealNotifier.fireTestFailure(failure);
+ } else {
+ mOutOfTestFailures.add(failure.getException());
+ }
+ }
+
+ @Override
+ public void fireTestAssumptionFailed(Failure failure) {
+ Log.i(TAG, "testAssumptionFailed: " + failure);
+
+ if (isInTest()) {
+ mRealNotifier.fireTestAssumptionFailed(failure);
+ } else {
+ mOutOfTestFailures.add(failure.getException());
+ }
+ }
+
+ @Override
+ public void fireTestIgnored(Description description) {
+ Log.i(TAG, "testIgnored: " + description);
+ mRealNotifier.fireTestIgnored(description);
+ }
+
+ @Override
+ public void fireTestFinished(Description description) {
+ Log.i(TAG, "testFinished: " + description);
+ mRealNotifier.fireTestFinished(description);
+
+ mAfterTest = true;
+ }
+
+ @Override
+ public void pleaseStop() {
+ Log.w(TAG, "pleaseStop:");
+ mRealNotifier.pleaseStop();
+ }
+
+ /**
+ * At the end of each Suite, we handle failures happened out of test methods.
+ * (typically in @BeforeClass or @AfterClasses)
+ *
+ * This is to work around b/364395552.
+ */
+ private boolean maybeHandleOutOfTestFailures() {
+ if (mOutOfTestFailures.size() == 0) {
+ return false;
+ }
+ Throwable th;
+ if (mOutOfTestFailures.size() == 1) {
+ th = mOutOfTestFailures.get(0);
+ } else {
+ th = new MultipleFailureException(mOutOfTestFailures);
+ }
+ if (mBeforeTest) {
+ reportBeforeTestFailure(mCurrentSuite, th);
+ return true;
+ }
+ if (mAfterTest) {
+ reportAfterTestFailure(th);
+ return true;
+ }
+ return false;
+ }
+
+ public void reportBeforeTestFailure(Description suiteDesc, Throwable th) {
+ // If a failure happens befere running any tests, we'll need to pretend
+ // as if each test in the suite reported the failure, to work around b/364395552.
+ for (var child : suiteDesc.getChildren()) {
+ if (child.isSuite()) {
+ // If the chiil is still a "parent" -- a test class or a test suite
+ // -- propagate to its children.
+ mRealNotifier.fireTestSuiteStarted(child);
+ reportBeforeTestFailure(child, th);
+ mRealNotifier.fireTestSuiteFinished(child);
+ } else {
+ mRealNotifier.fireTestStarted(child);
+ Failure f = new Failure(child, th);
+ if (th instanceof AssumptionViolatedException) {
+ mRealNotifier.fireTestAssumptionFailed(f);
+ } else {
+ mRealNotifier.fireTestFailure(f);
+ }
+ mRealNotifier.fireTestFinished(child);
+ }
+ }
+ }
+
+ public void reportAfterTestFailure(Throwable th) {
+ // Unfortunately, there's no good way to report it, so kill the own process.
+ onCriticalError(
+ "Failures detected in @AfterClass, which would be swallowed by tradefed",
+ th);
+ }
+ }
+
+ private static volatile BiConsumer<String, Throwable> sCriticalErrorHanler;
+
+ private void onCriticalError(@NonNull String message, @Nullable Throwable th) {
+ Log.e(TAG, "Critical error! " + message, th);
+ var handler = sCriticalErrorHanler;
+ if (handler == null) {
+ handler = sDefaultCriticalErrorHandler;
+ }
+ handler.accept(message, th);
+ }
+
+ private static BiConsumer<String, Throwable> sDefaultCriticalErrorHandler = (message, th) -> {
+ Log.e(TAG, "Ravenwood cannot continue. Killing self process.", th);
+ System.exit(1);
+ };
+
+ /**
+ * Contains Ravenwood private APIs.
+ */
+ public static class RavenwoodPrivate {
+ private RavenwoodPrivate() {
+ }
+
+ /**
+ * Set a listener for onCriticalError(), for testing. If a listener is set, we won't call
+ * System.exit().
+ */
+ public void setCriticalErrorHandler(
+ @Nullable BiConsumer<String, Throwable> handler) {
+ sCriticalErrorHanler = handler;
+ }
+ }
+
+ private static final RavenwoodPrivate sRavenwoodPrivate = new RavenwoodPrivate();
+
+ public static RavenwoodPrivate private$ravenwood() {
+ return sRavenwoodPrivate;
+ }
}
diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java
new file mode 100644
index 000000000000..04e0bedc8aab
--- /dev/null
+++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodConfig.java
@@ -0,0 +1,184 @@
+/*
+ * Copyright (C) 2024 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 android.platform.test.ravenwood;
+
+import static android.os.Process.FIRST_APPLICATION_UID;
+import static android.os.Process.SYSTEM_UID;
+import static android.os.UserHandle.SYSTEM;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.app.Instrumentation;
+import android.content.Context;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.atomic.AtomicInteger;
+
+/**
+ * Represents how to configure the ravenwood environment for a test class.
+ *
+ * If a ravenwood test class has a public static field with the {@link Config} annotation,
+ * Ravenwood will extract the config from it and initializes the environment. The type of the
+ * field must be of {@link RavenwoodConfig}.
+ */
+public final class RavenwoodConfig {
+ /**
+ * Use this to mark a field as the configuration.
+ * @hide
+ */
+ @Target({ElementType.FIELD})
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Config {
+ }
+
+ private static final int NOBODY_UID = 9999;
+
+ private static final AtomicInteger sNextPid = new AtomicInteger(100);
+
+ int mCurrentUser = SYSTEM.getIdentifier();
+
+ /**
+ * Unless the test author requests differently, run as "nobody", and give each collection of
+ * tests its own unique PID.
+ */
+ int mUid = NOBODY_UID;
+ int mPid = sNextPid.getAndIncrement();
+
+ String mPackageName;
+
+ boolean mProvideMainThread = false;
+
+ final RavenwoodSystemProperties mSystemProperties = new RavenwoodSystemProperties();
+
+ final List<Class<?>> mServicesRequired = new ArrayList<>();
+
+ volatile Context mContext;
+ volatile Instrumentation mInstrumentation;
+
+ private RavenwoodConfig() {
+ }
+
+ /**
+ * Return if the current process is running on a Ravenwood test environment.
+ */
+ public static boolean isOnRavenwood() {
+ return RavenwoodRule.isOnRavenwood();
+ }
+
+ public static class Builder {
+ private final RavenwoodConfig mConfig = new RavenwoodConfig();
+
+ public Builder() {
+ }
+
+ /**
+ * Configure the identity of this process to be the system UID for the duration of the
+ * test. Has no effect on non-Ravenwood environments.
+ */
+ public Builder setProcessSystem() {
+ mConfig.mUid = SYSTEM_UID;
+ return this;
+ }
+
+ /**
+ * Configure the identity of this process to be an app UID for the duration of the
+ * test. Has no effect on non-Ravenwood environments.
+ */
+ public Builder setProcessApp() {
+ mConfig.mUid = FIRST_APPLICATION_UID;
+ return this;
+ }
+
+ /**
+ * Configure the identity of this process to be the given package name for the duration
+ * of the test. Has no effect on non-Ravenwood environments.
+ */
+ public Builder setPackageName(@NonNull String packageName) {
+ mConfig.mPackageName = Objects.requireNonNull(packageName);
+ return this;
+ }
+
+ /**
+ * Configure a "main" thread to be available for the duration of the test, as defined
+ * by {@code Looper.getMainLooper()}. Has no effect on non-Ravenwood environments.
+ */
+ public Builder setProvideMainThread(boolean provideMainThread) {
+ mConfig.mProvideMainThread = provideMainThread;
+ return this;
+ }
+
+ /**
+ * Configure the given system property as immutable for the duration of the test.
+ * Read access to the key is allowed, and write access will fail. When {@code value} is
+ * {@code null}, the value is left as undefined.
+ *
+ * All properties in the {@code debug.*} namespace are automatically mutable, with no
+ * developer action required.
+ *
+ * Has no effect on non-Ravenwood environments.
+ */
+ public Builder setSystemPropertyImmutable(@NonNull String key,
+ @Nullable Object value) {
+ mConfig.mSystemProperties.setValue(key, value);
+ mConfig.mSystemProperties.setAccessReadOnly(key);
+ return this;
+ }
+
+ /**
+ * Configure the given system property as mutable for the duration of the test.
+ * Both read and write access to the key is allowed, and its value will be reset between
+ * each test. When {@code value} is {@code null}, the value is left as undefined.
+ *
+ * All properties in the {@code debug.*} namespace are automatically mutable, with no
+ * developer action required.
+ *
+ * Has no effect on non-Ravenwood environments.
+ */
+ public Builder setSystemPropertyMutable(@NonNull String key,
+ @Nullable Object value) {
+ mConfig.mSystemProperties.setValue(key, value);
+ mConfig.mSystemProperties.setAccessReadWrite(key);
+ return this;
+ }
+
+ /**
+ * Configure the set of system services that are required for this test to operate.
+ *
+ * For example, passing {@code android.hardware.SerialManager.class} as an argument will
+ * ensure that the underlying service is created, initialized, and ready to use for the
+ * duration of the test. The {@code SerialManager} instance can be obtained via
+ * {@code RavenwoodRule.getContext()} and {@code Context.getSystemService()}, and
+ * {@code SerialManagerInternal} can be obtained via {@code LocalServices.getService()}.
+ */
+ public Builder setServicesRequired(@NonNull Class<?>... services) {
+ mConfig.mServicesRequired.clear();
+ for (Class<?> service : services) {
+ mConfig.mServicesRequired.add(service);
+ }
+ return this;
+ }
+
+ public RavenwoodConfig build() {
+ return mConfig;
+ }
+ }
+}
diff --git a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
index d569896421eb..7847e7cb5463 100644
--- a/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
+++ b/ravenwood/junit-src/android/platform/test/ravenwood/RavenwoodRule.java
@@ -16,17 +16,13 @@
package android.platform.test.ravenwood;
-import static android.os.Process.FIRST_APPLICATION_UID;
-import static android.os.Process.SYSTEM_UID;
-import static android.os.UserHandle.SYSTEM;
-
import static com.android.ravenwood.common.RavenwoodCommonUtils.log;
+import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Instrumentation;
import android.content.Context;
import android.platform.test.annotations.DisabledOnRavenwood;
-import android.platform.test.annotations.EnabledOnRavenwood;
import com.android.ravenwood.common.RavenwoodCommonUtils;
@@ -34,26 +30,17 @@ import org.junit.rules.TestRule;
import org.junit.runner.Description;
import org.junit.runners.model.Statement;
-import java.util.ArrayList;
-import java.util.List;
import java.util.Objects;
-import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
/**
- * {@code @Rule} that configures the Ravenwood test environment. This rule has no effect when
- * tests are run on non-Ravenwood test environments.
- *
- * This rule initializes and resets the Ravenwood environment between each test method to offer a
- * hermetic testing environment.
- *
- * By default, all tests are executed on Ravenwood, but annotations such as
- * {@link DisabledOnRavenwood} and {@link EnabledOnRavenwood} can be used at both the method
- * and class level to "ignore" tests that may not be ready. When needed, a
- * {@link RavenwoodClassRule} can be used in addition to a {@link RavenwoodRule} to ignore tests
- * before a test class is fully initialized.
+ * @deprecated Use {@link RavenwoodConfig} to configure the ravenwood environment instead.
+ * A {@link RavenwoodRule} is no longer needed for {@link DisabledOnRavenwood}. To get the
+ * {@link Context} and {@link Instrumentation}, use
+ * {@link androidx.test.platform.app.InstrumentationRegistry} instead.
*/
-public class RavenwoodRule implements TestRule {
+@Deprecated
+public final class RavenwoodRule implements TestRule {
private static final String TAG = "RavenwoodRule";
static final boolean IS_ON_RAVENWOOD = RavenwoodCommonUtils.isOnRavenwood();
@@ -105,35 +92,19 @@ public class RavenwoodRule implements TestRule {
}
}
- private static final int NOBODY_UID = 9999;
-
- private static final AtomicInteger sNextPid = new AtomicInteger(100);
-
- int mCurrentUser = SYSTEM.getIdentifier();
-
- /**
- * Unless the test author requests differently, run as "nobody", and give each collection of
- * tests its own unique PID.
- */
- int mUid = NOBODY_UID;
- int mPid = sNextPid.getAndIncrement();
-
- String mPackageName;
-
- boolean mProvideMainThread = false;
-
- final RavenwoodSystemProperties mSystemProperties = new RavenwoodSystemProperties();
-
- final List<Class<?>> mServicesRequired = new ArrayList<>();
-
- volatile Context mContext;
- volatile Instrumentation mInstrumentation;
+ private final RavenwoodConfig mConfiguration;
public RavenwoodRule() {
+ mConfiguration = new RavenwoodConfig.Builder().build();
+ }
+
+ private RavenwoodRule(RavenwoodConfig config) {
+ mConfiguration = config;
}
public static class Builder {
- private RavenwoodRule mRule = new RavenwoodRule();
+ private final RavenwoodConfig.Builder mBuilder =
+ new RavenwoodConfig.Builder();
public Builder() {
}
@@ -143,7 +114,7 @@ public class RavenwoodRule implements TestRule {
* test. Has no effect on non-Ravenwood environments.
*/
public Builder setProcessSystem() {
- mRule.mUid = SYSTEM_UID;
+ mBuilder.setProcessSystem();
return this;
}
@@ -152,7 +123,7 @@ public class RavenwoodRule implements TestRule {
* test. Has no effect on non-Ravenwood environments.
*/
public Builder setProcessApp() {
- mRule.mUid = FIRST_APPLICATION_UID;
+ mBuilder.setProcessApp();
return this;
}
@@ -160,8 +131,8 @@ public class RavenwoodRule implements TestRule {
* Configure the identity of this process to be the given package name for the duration
* of the test. Has no effect on non-Ravenwood environments.
*/
- public Builder setPackageName(/* @NonNull */ String packageName) {
- mRule.mPackageName = Objects.requireNonNull(packageName);
+ public Builder setPackageName(@NonNull String packageName) {
+ mBuilder.setPackageName(packageName);
return this;
}
@@ -170,7 +141,7 @@ public class RavenwoodRule implements TestRule {
* by {@code Looper.getMainLooper()}. Has no effect on non-Ravenwood environments.
*/
public Builder setProvideMainThread(boolean provideMainThread) {
- mRule.mProvideMainThread = provideMainThread;
+ mBuilder.setProvideMainThread(provideMainThread);
return this;
}
@@ -184,10 +155,8 @@ public class RavenwoodRule implements TestRule {
*
* Has no effect on non-Ravenwood environments.
*/
- public Builder setSystemPropertyImmutable(/* @NonNull */ String key,
- /* @Nullable */ Object value) {
- mRule.mSystemProperties.setValue(key, value);
- mRule.mSystemProperties.setAccessReadOnly(key);
+ public Builder setSystemPropertyImmutable(@NonNull String key, @Nullable Object value) {
+ mBuilder.setSystemPropertyImmutable(key, value);
return this;
}
@@ -201,10 +170,8 @@ public class RavenwoodRule implements TestRule {
*
* Has no effect on non-Ravenwood environments.
*/
- public Builder setSystemPropertyMutable(/* @NonNull */ String key,
- /* @Nullable */ Object value) {
- mRule.mSystemProperties.setValue(key, value);
- mRule.mSystemProperties.setAccessReadWrite(key);
+ public Builder setSystemPropertyMutable(@NonNull String key, @Nullable Object value) {
+ mBuilder.setSystemPropertyMutable(key, value);
return this;
}
@@ -217,16 +184,13 @@ public class RavenwoodRule implements TestRule {
* {@code RavenwoodRule.getContext()} and {@code Context.getSystemService()}, and
* {@code SerialManagerInternal} can be obtained via {@code LocalServices.getService()}.
*/
- public Builder setServicesRequired(Class<?>... services) {
- mRule.mServicesRequired.clear();
- for (Class<?> service : services) {
- mRule.mServicesRequired.add(service);
- }
+ public Builder setServicesRequired(@NonNull Class<?>... services) {
+ mBuilder.setServicesRequired(services);
return this;
}
public RavenwoodRule build() {
- return mRule;
+ return new RavenwoodRule(mBuilder.build());
}
}
@@ -246,41 +210,44 @@ public class RavenwoodRule implements TestRule {
}
/**
- * Return a {@code Context} available for usage during the currently running test case.
- *
- * Each test should obtain needed information or references via this method;
- * references must not be stored beyond the scope of a test case.
+ * @deprecated Use
+ * {@code androidx.test.platform.app.InstrumentationRegistry.getInstrumentation().getContext()}
+ * instead.
*/
+ @Deprecated
public Context getContext() {
- return Objects.requireNonNull(mContext,
+ return Objects.requireNonNull(mConfiguration.mContext,
"Context is only available during @Test execution");
}
/**
- * Return a {@code Instrumentation} available for usage during the currently running test case.
- *
- * Each test should obtain needed information or references via this method;
- * references must not be stored beyond the scope of a test case.
+ * @deprecated Use
+ * {@code androidx.test.platform.app.InstrumentationRegistry.getInstrumentation()}
+ * instead.
*/
+ @Deprecated
public Instrumentation getInstrumentation() {
- return Objects.requireNonNull(mInstrumentation,
+ return Objects.requireNonNull(mConfiguration.mInstrumentation,
"Instrumentation is only available during @Test execution");
}
-
@Override
public Statement apply(Statement base, Description description) {
- // TODO: Here, we're calling init() / reset() once for each rule.
- // That means if a test class has multiple rules -- even if they refer to the same
- // rule instance -- we're calling them multiple times. We need to fix it.
+ if (!RavenwoodConfig.isOnRavenwood()) {
+ return base;
+ }
return new Statement() {
@Override
public void evaluate() throws Throwable {
- RavenwoodRuleImpl.init(RavenwoodRule.this);
+ RavenwoodAwareTestRunnerHook.onRavenwoodRuleEnter(
+ RavenwoodAwareTestRunner.getCurrentRunner(), description,
+ RavenwoodRule.this);
try {
base.evaluate();
} finally {
- RavenwoodRuleImpl.reset(RavenwoodRule.this);
+ RavenwoodAwareTestRunnerHook.onRavenwoodRuleExit(
+ RavenwoodAwareTestRunner.getCurrentRunner(), description,
+ RavenwoodRule.this);
}
}
};
@@ -339,4 +306,8 @@ public class RavenwoodRule implements TestRule {
public static RavenwoodPrivate private$ravenwood() {
return sRavenwoodPrivate;
}
+
+ RavenwoodConfig getConfiguration() {
+ return mConfiguration;
+ }
}
diff --git a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java
index 1e4889ce0678..0178b934a649 100644
--- a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java
+++ b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodAwareTestRunnerHook.java
@@ -19,7 +19,6 @@ import android.platform.test.ravenwood.RavenwoodAwareTestRunner.Order;
import android.platform.test.ravenwood.RavenwoodAwareTestRunner.Scope;
import org.junit.runner.Description;
-import org.junit.runner.Runner;
import org.junit.runners.model.TestClass;
/**
@@ -38,7 +37,7 @@ public class RavenwoodAwareTestRunnerHook {
/**
* Called when a runner starts, before the inner runner gets a chance to run.
*/
- public static void onRunnerInitializing(Runner runner, TestClass testClass) {
+ public static void onRunnerInitializing(RavenwoodAwareTestRunner runner, TestClass testClass) {
}
/**
@@ -48,15 +47,38 @@ public class RavenwoodAwareTestRunnerHook {
}
/**
+ * Called before the inner runner starts.
+ */
+ public static void onBeforeInnerRunnerStart(
+ RavenwoodAwareTestRunner runner, Description description) throws Throwable {
+ }
+
+ /**
+ * Called after the inner runner finished.
+ */
+ public static void onAfterInnerRunnerFinished(
+ RavenwoodAwareTestRunner runner, Description description) throws Throwable {
+ }
+
+ /**
* Called before a test / class.
*
* Return false if it should be skipped.
*/
public static boolean onBefore(RavenwoodAwareTestRunner runner, Description description,
- Scope scope, Order order) {
+ Scope scope, Order order) throws Throwable {
return true;
}
+ public static void onRavenwoodRuleEnter(RavenwoodAwareTestRunner runner,
+ Description description, RavenwoodRule rule) throws Throwable {
+ }
+
+ public static void onRavenwoodRuleExit(RavenwoodAwareTestRunner runner,
+ Description description, RavenwoodRule rule) throws Throwable {
+ }
+
+
/**
* Called after a test / class.
*
diff --git a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java b/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
deleted file mode 100644
index a470626dcbe7..000000000000
--- a/ravenwood/junit-stub-src/android/platform/test/ravenwood/RavenwoodRuleImpl.java
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * 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 android.platform.test.ravenwood;
-
-import org.junit.runner.Description;
-
-public class RavenwoodRuleImpl {
- public static void init(RavenwoodRule rule) {
- // No-op when running on a real device
- }
-
- public static void reset(RavenwoodRule rule) {
- // No-op when running on a real device
- }
-
- public static void logTestRunner(String label, Description description) {
- // No-op when running on a real device
- }
-
- public static long realCurrentTimeMillis() {
- return System.currentTimeMillis();
- }
-}
diff --git a/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java b/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java
index 7b5bc5aeb7b6..96746c679020 100644
--- a/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java
+++ b/ravenwood/runtime-common-src/com/android/ravenwood/common/RavenwoodCommonUtils.java
@@ -15,12 +15,18 @@
*/
package com.android.ravenwood.common;
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+
import com.android.ravenwood.common.divergence.RavenwoodDivergence;
import java.io.File;
import java.io.FileDescriptor;
import java.io.FileInputStream;
import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.io.StringWriter;
+import java.lang.reflect.Member;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.Arrays;
@@ -33,6 +39,14 @@ public class RavenwoodCommonUtils {
private static final Object sLock = new Object();
+ /**
+ * If set to "1", we enable the verbose logging.
+ *
+ * (See also InitLogging() in http://ac/system/libbase/logging.cpp)
+ */
+ public static final boolean RAVENWOOD_VERBOSE_LOGGING = "1".equals(System.getenv(
+ "RAVENWOOD_VERBOSE"));
+
/** Name of `libravenwood_runtime` */
private static final String RAVENWOOD_NATIVE_RUNTIME_NAME = "ravenwood_runtime";
@@ -265,4 +279,24 @@ public class RavenwoodCommonUtils {
method.getDeclaringClass().getName(), method.getName(),
(isStatic ? "static " : "")));
}
+
+ public static void ensureIsPublicMember(Member member, boolean isStatic) {
+ var ok = Modifier.isPublic(member.getModifiers())
+ && (Modifier.isStatic(member.getModifiers()) == isStatic);
+ if (ok) {
+ return; // okay
+ }
+ throw new AssertionError(String.format(
+ "%s.%s expected to be public %s",
+ member.getDeclaringClass().getName(), member.getName(),
+ (isStatic ? "static" : "")));
+ }
+
+ @NonNull
+ public static String getStackTraceString(@Nullable Throwable th) {
+ StringWriter stringWriter = new StringWriter();
+ PrintWriter writer = new PrintWriter(stringWriter);
+ th.printStackTrace(writer);
+ return stringWriter.toString();
+ }
}
diff --git a/ravenwood/runtime-helper-src/framework/android/os/Parcel_host.java b/ravenwood/runtime-helper-src/framework/android/os/Parcel_host.java
deleted file mode 100644
index 720f1d227326..000000000000
--- a/ravenwood/runtime-helper-src/framework/android/os/Parcel_host.java
+++ /dev/null
@@ -1,530 +0,0 @@
-/*
- * 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 android.os;
-
-import android.system.ErrnoException;
-import android.system.Os;
-import android.util.Log;
-
-import java.io.FileDescriptor;
-import java.nio.ByteBuffer;
-import java.nio.charset.StandardCharsets;
-import java.util.Arrays;
-import java.util.Map;
-import java.util.concurrent.ConcurrentHashMap;
-import java.util.concurrent.atomic.AtomicLong;
-
-/**
- * Tentative, partial implementation of the Parcel native methods, using Java's
- * {@code byte[]}.
- * (We don't use a {@link ByteBuffer} because there's enough semantics differences between Parcel
- * and {@link ByteBuffer}, and it didn't work out.
- * e.g. Parcel seems to allow moving the data position to be beyond its size? Which
- * {@link ByteBuffer} wouldn't allow...)
- */
-public class Parcel_host {
- private static final String TAG = "Parcel";
-
- private Parcel_host() {
- }
-
- private static final AtomicLong sNextId = new AtomicLong(1);
-
- private static final Map<Long, Parcel_host> sInstances = new ConcurrentHashMap<>();
-
- private boolean mDeleted = false;
-
- private byte[] mBuffer;
- private int mSize;
- private int mPos;
-
- private boolean mSensitive;
- private boolean mAllowFds;
-
- // TODO Use the actual value from Parcel.java.
- private static final int OK = 0;
-
- private final Map<Integer, FileDescriptor> mFdMap = new ConcurrentHashMap<>();
-
- private static final int FD_PLACEHOLDER = 0xDEADBEEF;
- private static final int FD_PAYLOAD_SIZE = 8;
-
- private void validate() {
- if (mDeleted) {
- // TODO: Put more info
- throw new RuntimeException("Parcel already destroyed");
- }
- }
-
- private static Parcel_host getInstance(long id) {
- Parcel_host p = sInstances.get(id);
- if (p == null) {
- // TODO: Put more info
- throw new RuntimeException("Parcel doesn't exist with id=" + id);
- }
- p.validate();
- return p;
- }
-
- /** Native method substitution */
- public static long nativeCreate() {
- final long id = sNextId.getAndIncrement();
- final Parcel_host p = new Parcel_host();
- sInstances.put(id, p);
- p.init();
- return id;
- }
-
- private void init() {
- mBuffer = new byte[0];
- mSize = 0;
- mPos = 0;
- mSensitive = false;
- mAllowFds = true;
- mFdMap.clear();
- }
-
- private void updateSize() {
- if (mSize < mPos) {
- mSize = mPos;
- }
- }
-
- /** Native method substitution */
- public static void nativeDestroy(long nativePtr) {
- getInstance(nativePtr).mDeleted = true;
- sInstances.remove(nativePtr);
- }
-
- /** Native method substitution */
- public static void nativeFreeBuffer(long nativePtr) {
- getInstance(nativePtr).freeBuffer();
- }
-
- /** Native method substitution */
- private void freeBuffer() {
- init();
- }
-
- private int getCapacity() {
- return mBuffer.length;
- }
-
- private void ensureMoreCapacity(int size) {
- ensureCapacity(mPos + size);
- }
-
- private void ensureCapacity(int targetSize) {
- if (targetSize <= getCapacity()) {
- return;
- }
- var newSize = getCapacity() * 2;
- if (newSize < targetSize) {
- newSize = targetSize;
- }
- forceSetCapacity(newSize);
- }
-
- private void forceSetCapacity(int newSize) {
- var newBuf = new byte[newSize];
-
- // Copy
- System.arraycopy(mBuffer, 0, newBuf, 0, Math.min(newSize, getCapacity()));
-
- this.mBuffer = newBuf;
- }
-
- private void ensureDataAvailable(int requestSize) {
- if (mSize - mPos < requestSize) {
- throw new RuntimeException(String.format(
- "Pacel data underflow. size=%d, pos=%d, request=%d", mSize, mPos, requestSize));
- }
- }
-
- /** Native method substitution */
- public static void nativeMarkSensitive(long nativePtr) {
- getInstance(nativePtr).mSensitive = true;
- }
-
- /** Native method substitution */
- public static int nativeDataSize(long nativePtr) {
- return getInstance(nativePtr).mSize;
- }
-
- /** Native method substitution */
- public static int nativeDataAvail(long nativePtr) {
- var p = getInstance(nativePtr);
- return p.mSize - p.mPos;
- }
-
- /** Native method substitution */
- public static int nativeDataPosition(long nativePtr) {
- return getInstance(nativePtr).mPos;
- }
-
- /** Native method substitution */
- public static int nativeDataCapacity(long nativePtr) {
- return getInstance(nativePtr).mBuffer.length;
- }
-
- /** Native method substitution */
- public static void nativeSetDataSize(long nativePtr, int size) {
- var p = getInstance(nativePtr);
- p.ensureCapacity(size);
- getInstance(nativePtr).mSize = size;
- }
-
- /** Native method substitution */
- public static void nativeSetDataPosition(long nativePtr, int pos) {
- var p = getInstance(nativePtr);
- // TODO: Should this change the size or the capacity??
- p.mPos = pos;
- }
-
- /** Native method substitution */
- public static void nativeSetDataCapacity(long nativePtr, int size) {
- if (size < 0) {
- throw new IllegalArgumentException("size < 0: size=" + size);
- }
- var p = getInstance(nativePtr);
- if (p.getCapacity() < size) {
- p.forceSetCapacity(size);
- }
- }
-
- /** Native method substitution */
- public static boolean nativePushAllowFds(long nativePtr, boolean allowFds) {
- var p = getInstance(nativePtr);
- var prev = p.mAllowFds;
- p.mAllowFds = allowFds;
- return prev;
- }
-
- /** Native method substitution */
- public static void nativeRestoreAllowFds(long nativePtr, boolean lastValue) {
- getInstance(nativePtr).mAllowFds = lastValue;
- }
-
- /** Native method substitution */
- public static void nativeWriteByteArray(long nativePtr, byte[] b, int offset, int len) {
- nativeWriteBlob(nativePtr, b, offset, len);
- }
-
- /** Native method substitution */
- public static void nativeWriteBlob(long nativePtr, byte[] b, int offset, int len) {
- var p = getInstance(nativePtr);
-
- if (b == null) {
- nativeWriteInt(nativePtr, -1);
- } else {
- final var alignedSize = align4(len);
-
- nativeWriteInt(nativePtr, len);
-
- p.ensureMoreCapacity(alignedSize);
-
- System.arraycopy(b, offset, p.mBuffer, p.mPos, len);
- p.mPos += alignedSize;
- p.updateSize();
- }
- }
-
- /** Native method substitution */
- public static int nativeWriteInt(long nativePtr, int value) {
- var p = getInstance(nativePtr);
- p.ensureMoreCapacity(Integer.BYTES);
-
- p.mBuffer[p.mPos++] = (byte) ((value >> 24) & 0xff);
- p.mBuffer[p.mPos++] = (byte) ((value >> 16) & 0xff);
- p.mBuffer[p.mPos++] = (byte) ((value >> 8) & 0xff);
- p.mBuffer[p.mPos++] = (byte) ((value >> 0) & 0xff);
-
- p.updateSize();
-
- return OK;
- }
-
- /** Native method substitution */
- public static int nativeWriteLong(long nativePtr, long value) {
- nativeWriteInt(nativePtr, (int) (value >>> 32));
- nativeWriteInt(nativePtr, (int) (value));
- return OK;
- }
-
- /** Native method substitution */
- public static int nativeWriteFloat(long nativePtr, float val) {
- return nativeWriteInt(nativePtr, Float.floatToIntBits(val));
- }
-
- /** Native method substitution */
- public static int nativeWriteDouble(long nativePtr, double val) {
- return nativeWriteLong(nativePtr, Double.doubleToLongBits(val));
- }
-
- private static int align4(int val) {
- return ((val + 3) / 4) * 4;
- }
-
- /** Native method substitution */
- public static void nativeWriteString8(long nativePtr, String val) {
- if (val == null) {
- nativeWriteBlob(nativePtr, null, 0, 0);
- } else {
- var bytes = val.getBytes(StandardCharsets.UTF_8);
- nativeWriteBlob(nativePtr, bytes, 0, bytes.length);
- }
- }
-
- /** Native method substitution */
- public static void nativeWriteString16(long nativePtr, String val) {
- // Just reuse String8
- nativeWriteString8(nativePtr, val);
- }
-
- /** Native method substitution */
- public static byte[] nativeCreateByteArray(long nativePtr) {
- return nativeReadBlob(nativePtr);
- }
-
- /** Native method substitution */
- public static boolean nativeReadByteArray(long nativePtr, byte[] dest, int destLen) {
- if (dest == null) {
- return false;
- }
- var data = nativeReadBlob(nativePtr);
- if (data == null) {
- System.err.println("Percel has NULL, which is unexpected."); // TODO: Is this correct?
- return false;
- }
- // TODO: Make sure the check logic is correct.
- if (data.length != destLen) {
- System.err.println("Byte array size mismatch: expected="
- + data.length + " given=" + destLen);
- return false;
- }
- System.arraycopy(data, 0, dest, 0, data.length);
- return true;
- }
-
- /** Native method substitution */
- public static byte[] nativeReadBlob(long nativePtr) {
- var p = getInstance(nativePtr);
- if (p.mSize - p.mPos < 4) {
- // Match native impl that returns "null" when not enough data
- return null;
- }
- final var size = nativeReadInt(nativePtr);
- if (size == -1) {
- return null;
- }
- try {
- p.ensureDataAvailable(align4(size));
- } catch (Exception e) {
- System.err.println(e.toString());
- return null;
- }
-
- var bytes = new byte[size];
- System.arraycopy(p.mBuffer, p.mPos, bytes, 0, size);
-
- p.mPos += align4(size);
-
- return bytes;
- }
-
- /** Native method substitution */
- public static int nativeReadInt(long nativePtr) {
- var p = getInstance(nativePtr);
-
- if (p.mSize - p.mPos < 4) {
- // Match native impl that returns "0" when not enough data
- return 0;
- }
-
- var ret = (((p.mBuffer[p.mPos++] & 0xff) << 24)
- | ((p.mBuffer[p.mPos++] & 0xff) << 16)
- | ((p.mBuffer[p.mPos++] & 0xff) << 8)
- | ((p.mBuffer[p.mPos++] & 0xff) << 0));
-
- return ret;
- }
-
- /** Native method substitution */
- public static long nativeReadLong(long nativePtr) {
- return (((long) nativeReadInt(nativePtr)) << 32)
- | (((long) nativeReadInt(nativePtr)) & 0xffff_ffffL);
- }
-
- /** Native method substitution */
- public static float nativeReadFloat(long nativePtr) {
- return Float.intBitsToFloat(nativeReadInt(nativePtr));
- }
-
- /** Native method substitution */
- public static double nativeReadDouble(long nativePtr) {
- return Double.longBitsToDouble(nativeReadLong(nativePtr));
- }
-
- /** Native method substitution */
- public static String nativeReadString8(long nativePtr) {
- final var bytes = nativeReadBlob(nativePtr);
- if (bytes == null) {
- return null;
- }
- return new String(bytes, StandardCharsets.UTF_8);
- }
- public static String nativeReadString16(long nativePtr) {
- return nativeReadString8(nativePtr);
- }
-
- /** Native method substitution */
- public static byte[] nativeMarshall(long nativePtr) {
- var p = getInstance(nativePtr);
- return Arrays.copyOf(p.mBuffer, p.mSize);
- }
-
- /** Native method substitution */
- public static void nativeUnmarshall(
- long nativePtr, byte[] data, int offset, int length) {
- var p = getInstance(nativePtr);
- p.ensureMoreCapacity(length);
- System.arraycopy(data, offset, p.mBuffer, p.mPos, length);
- p.mPos += length;
- p.updateSize();
- }
-
- /** Native method substitution */
- public static int nativeCompareData(long thisNativePtr, long otherNativePtr) {
- var a = getInstance(thisNativePtr);
- var b = getInstance(otherNativePtr);
- if ((a.mSize == b.mSize) && Arrays.equals(a.mBuffer, b.mBuffer)) {
- return 0;
- } else {
- return -1;
- }
- }
-
- /** Native method substitution */
- public static boolean nativeCompareDataInRange(
- long ptrA, int offsetA, long ptrB, int offsetB, int length) {
- var a = getInstance(ptrA);
- var b = getInstance(ptrB);
- if (offsetA < 0 || offsetA + length > a.mSize) {
- throw new IllegalArgumentException();
- }
- if (offsetB < 0 || offsetB + length > b.mSize) {
- throw new IllegalArgumentException();
- }
- return Arrays.equals(Arrays.copyOfRange(a.mBuffer, offsetA, offsetA + length),
- Arrays.copyOfRange(b.mBuffer, offsetB, offsetB + length));
- }
-
- /** Native method substitution */
- public static void nativeAppendFrom(
- long thisNativePtr, long otherNativePtr, int srcOffset, int length) {
- var dst = getInstance(thisNativePtr);
- var src = getInstance(otherNativePtr);
-
- dst.ensureMoreCapacity(length);
-
- System.arraycopy(src.mBuffer, srcOffset, dst.mBuffer, dst.mPos, length);
- dst.mPos += length; // TODO: 4 byte align?
- dst.updateSize();
-
- // TODO: Update the other's position?
- }
-
- /** Native method substitution */
- public static boolean nativeHasBinders(long nativePtr) {
- // Assume false for now, because we don't support adding binders.
- return false;
- }
-
- /** Native method substitution */
- public static boolean nativeHasBindersInRange(
- long nativePtr, int offset, int length) {
- // Assume false for now, because we don't support writing FDs yet.
- return false;
- }
-
- /** Native method substitution */
- public static void nativeWriteFileDescriptor(long nativePtr, java.io.FileDescriptor val) {
- var p = getInstance(nativePtr);
-
- if (!p.mAllowFds) {
- // Simulate the FDS_NOT_ALLOWED case in frameworks/base/core/jni/android_util_Binder.cpp
- throw new RuntimeException("Not allowed to write file descriptors here");
- }
-
- FileDescriptor dup = null;
- try {
- dup = Os.dup(val);
- } catch (ErrnoException e) {
- throw new RuntimeException(e);
- }
- p.mFdMap.put(p.mPos, dup);
-
- // Parcel.cpp writes two int32s for a FD.
- // Make sure FD_PAYLOAD_SIZE is in sync with this code.
- nativeWriteInt(nativePtr, FD_PLACEHOLDER);
- nativeWriteInt(nativePtr, FD_PLACEHOLDER);
- }
-
- /** Native method substitution */
- public static java.io.FileDescriptor nativeReadFileDescriptor(long nativePtr) {
- var p = getInstance(nativePtr);
-
- var pos = p.mPos;
- var fd = p.mFdMap.get(pos);
-
- if (fd == null) {
- Log.w(TAG, "nativeReadFileDescriptor: Not a FD at pos #" + pos);
- return null;
- }
- nativeReadInt(nativePtr);
- nativeReadInt(nativePtr);
- return fd;
- }
-
- /** Native method substitution */
- public static boolean nativeHasFileDescriptors(long nativePtr) {
- var p = getInstance(nativePtr);
- return p.mFdMap.size() > 0;
- }
-
- /** Native method substitution */
- public static boolean nativeHasFileDescriptorsInRange(long nativePtr, int offset, int length) {
- var p = getInstance(nativePtr);
-
- // Original code: hasFileDescriptorsInRange() in frameworks/native/libs/binder/Parcel.cpp
- if (offset < 0 || length < 0) {
- throw new IllegalArgumentException("Negative value not allowed: offset=" + offset
- + " length=" + length);
- }
- long limit = (long) offset + (long) length;
- if (limit > p.mSize) {
- throw new IllegalArgumentException("Out of range: offset=" + offset
- + " length=" + length + " dataSize=" + p.mSize);
- }
-
- for (var pos : p.mFdMap.keySet()) {
- if (offset <= pos && (pos + FD_PAYLOAD_SIZE - 1) < (offset + length)) {
- return true;
- }
- }
- return false;
- }
-}
diff --git a/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java b/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java
index 3bf116da19b8..e12ff240c4d9 100644
--- a/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java
+++ b/ravenwood/runtime-helper-src/framework/com/android/internal/ravenwood/RavenwoodEnvironment_host.java
@@ -15,21 +15,10 @@
*/
package com.android.internal.ravenwood;
-import android.os.SystemProperties_host;
-import android.platform.test.ravenwood.RavenwoodSystemProperties;
-import android.util.Log;
-
import com.android.ravenwood.common.JvmWorkaround;
import com.android.ravenwood.common.RavenwoodCommonUtils;
public class RavenwoodEnvironment_host {
- private static final String TAG = RavenwoodEnvironment.TAG;
-
- private static final Object sInitializeLock = new Object();
-
- // @GuardedBy("sInitializeLock")
- private static boolean sInitialized;
-
private RavenwoodEnvironment_host() {
}
@@ -37,27 +26,8 @@ public class RavenwoodEnvironment_host {
* Called from {@link RavenwoodEnvironment#ensureRavenwoodInitialized()}.
*/
public static void ensureRavenwoodInitialized() {
-
- // TODO Unify it with the initialization code in RavenwoodAwareTestRunnerHook.
-
- synchronized (sInitializeLock) {
- if (sInitialized) {
- return;
- }
- Log.i(TAG, "Initializing Ravenwood environment");
-
- // Set the default values.
- var sysProps = RavenwoodSystemProperties.DEFAULT_VALUES;
-
- // We have a method that does it in RavenwoodRuleImpl, but we can't use that class
- // here, So just inline it.
- SystemProperties_host.initializeIfNeeded(
- sysProps.getValues(),
- sysProps.getKeyReadablePredicate(),
- sysProps.getKeyWritablePredicate());
-
- sInitialized = true;
- }
+ // Initialization is now done by RavenwoodAwareTestRunner.
+ // Should we remove it?
}
/**
diff --git a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java
index c519204d0586..790bb1c2373b 100644
--- a/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java
+++ b/ravenwood/runtime-helper-src/framework/com/android/platform/test/ravenwood/runtimehelper/ClassLoadHook.java
@@ -15,6 +15,8 @@
*/
package com.android.platform.test.ravenwood.runtimehelper;
+import static com.android.ravenwood.common.RavenwoodCommonUtils.RAVENWOOD_VERBOSE_LOGGING;
+
import android.system.ErrnoException;
import android.system.Os;
@@ -40,14 +42,6 @@ public class ClassLoadHook {
private static final boolean SKIP_LOADING_LIBANDROID = "1".equals(System.getenv(
"RAVENWOOD_SKIP_LOADING_LIBANDROID"));
- /**
- * If set to 1, and if $ANDROID_LOG_TAGS isn't set, we enable the verbose logging.
- *
- * (See also InitLogging() in http://ac/system/libbase/logging.cpp)
- */
- private static final boolean RAVENWOOD_VERBOSE_LOGGING = "1".equals(System.getenv(
- "RAVENWOOD_VERBOSE"));
-
public static final String CORE_NATIVE_CLASSES = "core_native_classes";
public static final String ICU_DATA_PATH = "icu.data.path";
public static final String KEYBOARD_PATHS = "keyboard_paths";
@@ -172,6 +166,7 @@ public class ClassLoadHook {
private static final Class<?>[] sLibandroidClasses = {
android.util.Log.class,
android.os.Parcel.class,
+ android.os.Binder.class,
android.content.res.ApkAssets.class,
android.content.res.AssetManager.class,
android.content.res.StringBlock.class,
diff --git a/ravenwood/tests/coretest/Android.bp b/ravenwood/tests/coretest/Android.bp
new file mode 100644
index 000000000000..d94475c00240
--- /dev/null
+++ b/ravenwood/tests/coretest/Android.bp
@@ -0,0 +1,25 @@
+package {
+ // See: http://go/android-license-faq
+ // A large-scale-change added 'default_applicable_licenses' to import
+ // all of the 'license_kinds' from "frameworks_base_license"
+ // to get the below license kinds:
+ // SPDX-license-identifier-Apache-2.0
+ default_applicable_licenses: ["frameworks_base_license"],
+}
+
+android_ravenwood_test {
+ name: "RavenwoodCoreTest",
+
+ static_libs: [
+ "androidx.annotation_annotation",
+ "androidx.test.ext.junit",
+ "androidx.test.rules",
+ "junit-params",
+ "platform-parametric-runner-lib",
+ "truth",
+ ],
+ srcs: [
+ "test/**/*.java",
+ ],
+ auto_gen_config: true,
+}
diff --git a/ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerCallbackTest.java b/ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerCallbackTest.java
new file mode 100644
index 000000000000..6d8fb983504b
--- /dev/null
+++ b/ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerCallbackTest.java
@@ -0,0 +1,356 @@
+/*
+ * Copyright (C) 2024 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.ravenwoodtest.runnercallbacktests;
+
+import static org.junit.Assume.assumeTrue;
+
+import android.platform.test.annotations.NoRavenizer;
+import android.platform.test.ravenwood.RavenwoodAwareTestRunner;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+
+import org.junit.AfterClass;
+import org.junit.Assume;
+import org.junit.BeforeClass;
+import org.junit.ClassRule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.runner.Description;
+import org.junit.runner.RunWith;
+import org.junit.runners.BlockJUnit4ClassRunner;
+import org.junit.runners.model.Statement;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import platform.test.runner.parameterized.ParameterizedAndroidJunit4;
+import platform.test.runner.parameterized.Parameters;
+
+
+/**
+ * Tests to make sure {@link RavenwoodAwareTestRunner} produces expected callbacks in various
+ * error situations in places such as @BeforeClass / @AfterClass / Constructors, which are
+ * out of test method bodies.
+ */
+@NoRavenizer // This class shouldn't be executed with RavenwoodAwareTestRunner.
+public class RavenwoodRunnerCallbackTest extends RavenwoodRunnerTestBase {
+
+ /**
+ * Throws an exception in @AfterClass. This should produce a critical error.
+ */
+ @RunWith(BlockJUnit4ClassRunner.class)
+ // CHECKSTYLE:OFF Generated code
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$AfterClassFailureTest
+ testStarted: test1(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$AfterClassFailureTest)
+ testFinished: test1(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$AfterClassFailureTest)
+ testStarted: test2(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$AfterClassFailureTest)
+ testFinished: test2(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$AfterClassFailureTest)
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$AfterClassFailureTest
+ criticalError: Failures detected in @AfterClass, which would be swallowed by tradefed: FAILURE
+ testSuiteFinished: classes
+ testRunFinished: 2,0,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class AfterClassFailureTest {
+ public AfterClassFailureTest() {
+ }
+
+ @AfterClass
+ public static void afterClass() {
+ throw new RuntimeException("FAILURE");
+ }
+
+ @Test
+ public void test1() {
+ }
+
+ @Test
+ public void test2() {
+ }
+
+ }
+
+ /**
+ * Assumption failure in @BeforeClass.
+ */
+ @RunWith(ParameterizedAndroidJunit4.class)
+ // Because the test uses ParameterizedAndroidJunit4 with two parameters,
+ // the whole class is executed twice.
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassAssumptionFailureTest
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassAssumptionFailureTest
+ testSuiteStarted: [0]
+ testStarted: test1[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassAssumptionFailureTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test1[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassAssumptionFailureTest)
+ testStarted: test2[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassAssumptionFailureTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test2[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassAssumptionFailureTest)
+ testSuiteFinished: [0]
+ testSuiteStarted: [1]
+ testStarted: test1[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassAssumptionFailureTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test1[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassAssumptionFailureTest)
+ testStarted: test2[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassAssumptionFailureTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test2[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassAssumptionFailureTest)
+ testSuiteFinished: [1]
+ testSuiteFinished: classes
+ testRunFinished: 4,0,4,0
+ """)
+ // CHECKSTYLE:ON
+ public static class BeforeClassAssumptionFailureTest {
+ public BeforeClassAssumptionFailureTest(String param) {
+ }
+
+ @BeforeClass
+ public static void beforeClass() {
+ Assume.assumeTrue(false);
+ }
+
+ @Parameters
+ public static List<String> getParams() {
+ var params = new ArrayList<String>();
+ params.add("foo");
+ params.add("bar");
+ return params;
+ }
+
+ @Test
+ public void test1() {
+ }
+
+ @Test
+ public void test2() {
+ }
+ }
+
+ /**
+ * General exception in @BeforeClass.
+ */
+ @RunWith(ParameterizedAndroidJunit4.class)
+ // Because the test uses ParameterizedAndroidJunit4 with two parameters,
+ // the whole class is executed twice.
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassExceptionTest
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassExceptionTest
+ testSuiteStarted: [0]
+ testStarted: test1[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassExceptionTest)
+ testFailure: FAILURE
+ testFinished: test1[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassExceptionTest)
+ testStarted: test2[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassExceptionTest)
+ testFailure: FAILURE
+ testFinished: test2[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassExceptionTest)
+ testSuiteFinished: [0]
+ testSuiteStarted: [1]
+ testStarted: test1[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassExceptionTest)
+ testFailure: FAILURE
+ testFinished: test1[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassExceptionTest)
+ testStarted: test2[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassExceptionTest)
+ testFailure: FAILURE
+ testFinished: test2[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$BeforeClassExceptionTest)
+ testSuiteFinished: [1]
+ testSuiteFinished: classes
+ testRunFinished: 4,4,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class BeforeClassExceptionTest {
+ public BeforeClassExceptionTest(String param) {
+ }
+
+ @BeforeClass
+ public static void beforeClass() {
+ throw new RuntimeException("FAILURE");
+ }
+
+ @Parameters
+ public static List<String> getParams() {
+ var params = new ArrayList<String>();
+ params.add("foo");
+ params.add("bar");
+ return params;
+ }
+
+ @Test
+ public void test1() {
+ }
+
+ @Test
+ public void test2() {
+ }
+ }
+
+ /**
+ * Assumption failure from a @ClassRule.
+ */
+ @RunWith(ParameterizedAndroidJunit4.class)
+ // Because the test uses ParameterizedAndroidJunit4 with two parameters,
+ // the whole class is executed twice.
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleAssumptionFailureTest
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleAssumptionFailureTest
+ testSuiteStarted: [0]
+ testStarted: test1[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleAssumptionFailureTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test1[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleAssumptionFailureTest)
+ testStarted: test2[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleAssumptionFailureTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test2[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleAssumptionFailureTest)
+ testSuiteFinished: [0]
+ testSuiteStarted: [1]
+ testStarted: test1[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleAssumptionFailureTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test1[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleAssumptionFailureTest)
+ testStarted: test2[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleAssumptionFailureTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test2[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleAssumptionFailureTest)
+ testSuiteFinished: [1]
+ testSuiteFinished: classes
+ testRunFinished: 4,0,4,0
+ """)
+ // CHECKSTYLE:ON
+ public static class ClassRuleAssumptionFailureTest {
+ @ClassRule
+ public static final TestRule sClassRule = new TestRule() {
+ @Override
+ public Statement apply(Statement base, Description description) {
+ assumeTrue(false);
+ return null; // unreachable
+ }
+ };
+
+ public ClassRuleAssumptionFailureTest(String param) {
+ }
+
+ @Parameters
+ public static List<String> getParams() {
+ var params = new ArrayList<String>();
+ params.add("foo");
+ params.add("bar");
+ return params;
+ }
+
+ @Test
+ public void test1() {
+ }
+
+ @Test
+ public void test2() {
+ }
+ }
+
+ /**
+ * General exception from a @ClassRule.
+ */
+ @RunWith(ParameterizedAndroidJunit4.class)
+ // Because the test uses ParameterizedAndroidJunit4 with two parameters,
+ // the whole class is executed twice.
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleExceptionTest
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleExceptionTest
+ testSuiteStarted: [0]
+ testStarted: test1[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleExceptionTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test1[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleExceptionTest)
+ testStarted: test2[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleExceptionTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test2[0](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleExceptionTest)
+ testSuiteFinished: [0]
+ testSuiteStarted: [1]
+ testStarted: test1[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleExceptionTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test1[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleExceptionTest)
+ testStarted: test2[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleExceptionTest)
+ testAssumptionFailure: got: <false>, expected: is <true>
+ testFinished: test2[1](com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ClassRuleExceptionTest)
+ testSuiteFinished: [1]
+ testSuiteFinished: classes
+ testRunFinished: 4,0,4,0
+ """)
+ // CHECKSTYLE:ON
+ public static class ClassRuleExceptionTest {
+ @ClassRule
+ public static final TestRule sClassRule = new TestRule() {
+ @Override
+ public Statement apply(Statement base, Description description) {
+ assumeTrue(false);
+ return null; // unreachable
+ }
+ };
+
+ public ClassRuleExceptionTest(String param) {
+ }
+
+ @Parameters
+ public static List<String> getParams() {
+ var params = new ArrayList<String>();
+ params.add("foo");
+ params.add("bar");
+ return params;
+ }
+
+ @Test
+ public void test1() {
+ }
+
+ @Test
+ public void test2() {
+ }
+ }
+
+ /**
+ * General exception from a @ClassRule.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testStarted: Constructor(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ExceptionFromInnerRunnerConstructorTest)
+ testFailure: Exception detected in constructor
+ testFinished: Constructor(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerCallbackTest$ExceptionFromInnerRunnerConstructorTest)
+ testSuiteFinished: classes
+ testRunFinished: 1,1,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class ExceptionFromInnerRunnerConstructorTest {
+ public ExceptionFromInnerRunnerConstructorTest(String arg1, String arg2) {
+ }
+
+ @Test
+ public void test1() {
+ }
+
+ @Test
+ public void test2() {
+ }
+ }
+}
diff --git a/ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerConfigValidationTest.java b/ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerConfigValidationTest.java
new file mode 100644
index 000000000000..6ee443fac874
--- /dev/null
+++ b/ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerConfigValidationTest.java
@@ -0,0 +1,452 @@
+/*
+ * Copyright (C) 2024 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.ravenwoodtest.runnercallbacktests;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import android.platform.test.annotations.NoRavenizer;
+import android.platform.test.ravenwood.RavenwoodConfig;
+import android.platform.test.ravenwood.RavenwoodRule;
+
+import androidx.test.ext.junit.runners.AndroidJUnit4;
+import androidx.test.platform.app.InstrumentationRegistry;
+
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.rules.TestRule;
+import org.junit.runner.RunWith;
+
+
+/**
+ * Test for @Config field extraction and validation.
+ */
+@NoRavenizer // This class shouldn't be executed with RavenwoodAwareTestRunner.
+public class RavenwoodRunnerConfigValidationTest extends RavenwoodRunnerTestBase {
+ public abstract static class ConfigInBaseClass {
+ static String PACKAGE_NAME = "com.ConfigInBaseClass";
+
+ @RavenwoodConfig.Config
+ public static RavenwoodConfig sConfig = new RavenwoodConfig.Builder()
+ .setPackageName(PACKAGE_NAME).build();
+ }
+
+ /**
+ * Make sure a config in the base class is detected.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigInBaseClassTest
+ testStarted: test(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigInBaseClassTest)
+ testFinished: test(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigInBaseClassTest)
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigInBaseClassTest
+ testSuiteFinished: classes
+ testRunFinished: 1,0,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class ConfigInBaseClassTest extends ConfigInBaseClass {
+ @Test
+ public void test() {
+ assertThat(InstrumentationRegistry.getInstrumentation().getContext().getPackageName())
+ .isEqualTo(PACKAGE_NAME);
+ }
+ }
+
+ /**
+ * Make sure a config in the base class is detected.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigOverridingTest
+ testStarted: test(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigOverridingTest)
+ testFinished: test(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigOverridingTest)
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigOverridingTest
+ testSuiteFinished: classes
+ testRunFinished: 1,0,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class ConfigOverridingTest extends ConfigInBaseClass {
+ static String PACKAGE_NAME_OVERRIDE = "com.ConfigOverridingTest";
+
+ @RavenwoodConfig.Config
+ public static RavenwoodConfig sConfig = new RavenwoodConfig.Builder()
+ .setPackageName(PACKAGE_NAME_OVERRIDE).build();
+
+ @Test
+ public void test() {
+ assertThat(InstrumentationRegistry.getInstrumentation().getContext().getPackageName())
+ .isEqualTo(PACKAGE_NAME_OVERRIDE);
+ }
+ }
+
+ /**
+ * Test to make sure that if a test has a config error, the failure would be reported from
+ * each test method.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testStarted: testMethod1(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ErrorMustBeReportedFromEachTest)
+ testFailure: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ErrorMustBeReportedFromEachTest.sConfig expected to be public static
+ testFinished: testMethod1(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ErrorMustBeReportedFromEachTest)
+ testStarted: testMethod2(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ErrorMustBeReportedFromEachTest)
+ testFailure: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ErrorMustBeReportedFromEachTest.sConfig expected to be public static
+ testFinished: testMethod2(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ErrorMustBeReportedFromEachTest)
+ testStarted: testMethod3(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ErrorMustBeReportedFromEachTest)
+ testFailure: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ErrorMustBeReportedFromEachTest.sConfig expected to be public static
+ testFinished: testMethod3(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ErrorMustBeReportedFromEachTest)
+ testSuiteFinished: classes
+ testRunFinished: 3,3,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class ErrorMustBeReportedFromEachTest {
+ @RavenwoodConfig.Config
+ private static RavenwoodConfig sConfig = // Invalid because it's private.
+ new RavenwoodConfig.Builder().build();
+
+ @Test
+ public void testMethod1() {
+ }
+
+ @Test
+ public void testMethod2() {
+ }
+
+ @Test
+ public void testMethod3() {
+ }
+ }
+
+ /**
+ * Invalid because there are two @Config's.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testStarted: testConfig(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$DuplicateConfigTest)
+ testFailure: Class com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest.DuplicateConfigTest has multiple fields with @RavenwoodConfiguration.Config
+ testFinished: testConfig(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$DuplicateConfigTest)
+ testSuiteFinished: classes
+ testRunFinished: 1,1,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class DuplicateConfigTest {
+
+ @RavenwoodConfig.Config
+ public static RavenwoodConfig sConfig1 =
+ new RavenwoodConfig.Builder().build();
+
+ @RavenwoodConfig.Config
+ public static RavenwoodConfig sConfig2 =
+ new RavenwoodConfig.Builder().build();
+
+ @Test
+ public void testConfig() {
+ }
+ }
+
+ /**
+ * @Config's must be static.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testStarted: testConfig(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$NonStaticConfigTest)
+ testFailure: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$NonStaticConfigTest.sConfig expected to be public static
+ testFinished: testConfig(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$NonStaticConfigTest)
+ testSuiteFinished: classes
+ testRunFinished: 1,1,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class NonStaticConfigTest {
+
+ @RavenwoodConfig.Config
+ public RavenwoodConfig sConfig =
+ new RavenwoodConfig.Builder().build();
+
+ @Test
+ public void testConfig() {
+ }
+ }
+
+ /**
+ * @Config's must be public.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testStarted: testConfig(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$NonPublicConfigTest)
+ testFailure: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$NonPublicConfigTest.sConfig expected to be public static
+ testFinished: testConfig(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$NonPublicConfigTest)
+ testSuiteFinished: classes
+ testRunFinished: 1,1,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class NonPublicConfigTest {
+
+ @RavenwoodConfig.Config
+ RavenwoodConfig sConfig =
+ new RavenwoodConfig.Builder().build();
+
+ @Test
+ public void testConfig() {
+ }
+ }
+
+ /**
+ * @Config's must be of type RavenwoodConfiguration.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testStarted: testConfig(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$WrongTypeConfigTest)
+ testFailure: Field com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest.WrongTypeConfigTest.sConfig has @RavenwoodConfiguration.Config but type is not RavenwoodConfiguration
+ testFinished: testConfig(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$WrongTypeConfigTest)
+ testSuiteFinished: classes
+ testRunFinished: 1,1,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class WrongTypeConfigTest {
+
+ @RavenwoodConfig.Config
+ public Object sConfig =
+ new RavenwoodConfig.Builder().build();
+
+ @Test
+ public void testConfig() {
+ }
+
+ }
+
+ /**
+ * Config can't be used with a (instance) Rule.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testStarted: testConfig(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$WithInstanceRuleTest)
+ testFailure: RavenwoodConfiguration and RavenwoodRule cannot be used in the same class. Suggest migrating to RavenwoodConfiguration.
+ testFinished: testConfig(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$WithInstanceRuleTest)
+ testSuiteFinished: classes
+ testRunFinished: 1,1,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class WithInstanceRuleTest {
+
+ @RavenwoodConfig.Config
+ public static RavenwoodConfig sConfig =
+ new RavenwoodConfig.Builder().build();
+
+ @Rule
+ public RavenwoodRule mRule = new RavenwoodRule.Builder().build();
+
+ @Test
+ public void testConfig() {
+ }
+ }
+
+ /**
+ * Config can't be used with a (static) Rule.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testStarted: Constructor(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$WithStaticRuleTest)
+ testFailure: Exception detected in constructor
+ testFinished: Constructor(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$WithStaticRuleTest)
+ testSuiteFinished: classes
+ testRunFinished: 1,1,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class WithStaticRuleTest {
+
+ @RavenwoodConfig.Config
+ public static RavenwoodConfig sConfig =
+ new RavenwoodConfig.Builder().build();
+
+ @Rule
+ public static RavenwoodRule sRule = new RavenwoodRule.Builder().build();
+
+ @Test
+ public void testConfig() {
+ }
+ }
+
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$DuplicateRulesTest
+ testStarted: testMultipleRulesNotAllowed(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$DuplicateRulesTest)
+ testFailure: Multiple nesting RavenwoodRule's are detected in the same class, which is not supported.
+ testFinished: testMultipleRulesNotAllowed(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$DuplicateRulesTest)
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$DuplicateRulesTest
+ testSuiteFinished: classes
+ testRunFinished: 1,1,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class DuplicateRulesTest {
+
+ @Rule
+ public final RavenwoodRule mRavenwood1 = new RavenwoodRule();
+
+ @Rule
+ public final RavenwoodRule mRavenwood2 = new RavenwoodRule();
+
+ @Test
+ public void testMultipleRulesNotAllowed() {
+ }
+ }
+
+ public static class RuleInBaseClass {
+ static String PACKAGE_NAME = "com.RuleInBaseClass";
+ @Rule
+ public final RavenwoodRule mRavenwood1 = new RavenwoodRule.Builder()
+ .setPackageName(PACKAGE_NAME).build();
+ }
+
+ /**
+ * Make sure that RavenwoodRule in a base class takes effect.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$RuleInBaseClassSuccessTest
+ testStarted: testRuleInBaseClass(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$RuleInBaseClassSuccessTest)
+ testFinished: testRuleInBaseClass(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$RuleInBaseClassSuccessTest)
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$RuleInBaseClassSuccessTest
+ testSuiteFinished: classes
+ testRunFinished: 1,0,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class RuleInBaseClassSuccessTest extends RuleInBaseClass {
+
+ @Test
+ public void testRuleInBaseClass() {
+ assertThat(InstrumentationRegistry.getInstrumentation().getContext().getPackageName())
+ .isEqualTo(PACKAGE_NAME);
+ }
+ }
+
+ /**
+ * Make sure that having a config and a rule in a base class should fail.
+ * RavenwoodRule.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testStarted: test(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigWithRuleInBaseClassTest)
+ testFailure: RavenwoodConfiguration and RavenwoodRule cannot be used in the same class. Suggest migrating to RavenwoodConfiguration.
+ testFinished: test(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigWithRuleInBaseClassTest)
+ testSuiteFinished: classes
+ testRunFinished: 1,1,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class ConfigWithRuleInBaseClassTest extends RuleInBaseClass {
+ @RavenwoodConfig.Config
+ public static RavenwoodConfig sConfig = new RavenwoodConfig.Builder().build();
+
+ @Test
+ public void test() {
+ }
+ }
+
+ /**
+ * Same as {@link RuleInBaseClass}, but the type of the rule field is not {@link RavenwoodRule}.
+ */
+ public abstract static class RuleWithDifferentTypeInBaseClass {
+ static String PACKAGE_NAME = "com.RuleWithDifferentTypeInBaseClass";
+ @Rule
+ public final TestRule mRavenwood1 = new RavenwoodRule.Builder()
+ .setPackageName(PACKAGE_NAME).build();
+ }
+
+ /**
+ * Make sure that RavenwoodRule in a base class takes effect, even if the field type is not
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$RuleWithDifferentTypeInBaseClassSuccessTest
+ testStarted: testRuleInBaseClass(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$RuleWithDifferentTypeInBaseClassSuccessTest)
+ testFinished: testRuleInBaseClass(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$RuleWithDifferentTypeInBaseClassSuccessTest)
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$RuleWithDifferentTypeInBaseClassSuccessTest
+ testSuiteFinished: classes
+ testRunFinished: 1,0,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class RuleWithDifferentTypeInBaseClassSuccessTest extends RuleWithDifferentTypeInBaseClass {
+
+ @Test
+ public void testRuleInBaseClass() {
+ assertThat(InstrumentationRegistry.getInstrumentation().getContext().getPackageName())
+ .isEqualTo(PACKAGE_NAME);
+ }
+ }
+
+ /**
+ * Make sure that having a config and a rule in a base class should fail, even if the field type is not
+ * RavenwoodRule.
+ */
+ @RunWith(AndroidJUnit4.class)
+ // CHECKSTYLE:OFF
+ @Expected("""
+ testRunStarted: classes
+ testSuiteStarted: classes
+ testSuiteStarted: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigWithRuleWithDifferentTypeInBaseClassTest
+ testStarted: test(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigWithRuleWithDifferentTypeInBaseClassTest)
+ testFailure: RavenwoodConfiguration and RavenwoodRule cannot be used in the same class. Suggest migrating to RavenwoodConfiguration.
+ testFinished: test(com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigWithRuleWithDifferentTypeInBaseClassTest)
+ testSuiteFinished: com.android.ravenwoodtest.runnercallbacktests.RavenwoodRunnerConfigValidationTest$ConfigWithRuleWithDifferentTypeInBaseClassTest
+ testSuiteFinished: classes
+ testRunFinished: 1,1,0,0
+ """)
+ // CHECKSTYLE:ON
+ public static class ConfigWithRuleWithDifferentTypeInBaseClassTest extends RuleWithDifferentTypeInBaseClass {
+ @RavenwoodConfig.Config
+ public static RavenwoodConfig sConfig = new RavenwoodConfig.Builder().build();
+
+ @Test
+ public void test() {
+ }
+ }
+}
diff --git a/ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerTestBase.java b/ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerTestBase.java
new file mode 100644
index 000000000000..9a6934bf17c5
--- /dev/null
+++ b/ravenwood/tests/coretest/test/com/android/ravenwoodtest/runnercallbacktests/RavenwoodRunnerTestBase.java
@@ -0,0 +1,220 @@
+/*
+ * Copyright (C) 2024 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.ravenwoodtest.runnercallbacktests;
+
+import static com.google.common.truth.Truth.assertThat;
+import static com.google.common.truth.Truth.assertWithMessage;
+
+import android.platform.test.annotations.NoRavenizer;
+import android.platform.test.ravenwood.RavenwoodAwareTestRunner;
+import android.util.Log;
+
+import junitparams.JUnitParamsRunner;
+import junitparams.Parameters;
+import org.junit.Test;
+import org.junit.runner.Description;
+import org.junit.runner.JUnitCore;
+import org.junit.runner.Result;
+import org.junit.runner.RunWith;
+import org.junit.runner.notification.Failure;
+import org.junit.runner.notification.RunListener;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.function.BiConsumer;
+
+
+/**
+ * Base class for tests to make sure {@link RavenwoodAwareTestRunner} produces expected callbacks
+ * in various situations. (most of them are error situations.)
+ *
+ * Subclasses must contain test classes as static inner classes with an {@link Expected} annotation.
+ * This class finds them using reflections and run them one by one directly using {@link JUnitCore},
+ * and check the callbacks.
+ *
+ * Subclasses do no need to have any test methods.
+ *
+ * The {@link Expected} annotation must contain the expected result as a string.
+ *
+ * This test abuses the fact that atest + tradefed + junit won't run nested classes automatically.
+ * (So atest won't show any results directly from the nested classes.)
+ *
+ * The actual test method is {@link #doTest}, which is executed for each target test class, using
+ * junit-params.
+ */
+@RunWith(JUnitParamsRunner.class)
+@NoRavenizer // This class shouldn't be executed with RavenwoodAwareTestRunner.
+public abstract class RavenwoodRunnerTestBase {
+ private static final String TAG = "RavenwoodRunnerTestBase";
+
+ /**
+ * Annotation to specify the expected result for a class.
+ */
+ @Target({ElementType.TYPE})
+ @Retention(RetentionPolicy.RUNTIME)
+ public @interface Expected {
+ String value();
+ }
+
+ /**
+ * Take a multiline string, strip all of them, remove empty lines, and return it.
+ */
+ private static String stripMultiLines(String resultString) {
+ var list = new ArrayList<String>();
+ for (var line : resultString.split("\n")) {
+ var s = line.strip();
+ if (s.length() > 0) {
+ list.add(s);
+ }
+ }
+ return String.join("\n", list);
+ }
+
+ /**
+ * Extract the expected result from @Expected.
+ */
+ private String getExpectedResult(Class<?> testClazz) {
+ var expect = testClazz.getAnnotation(Expected.class);
+ return stripMultiLines(expect.value());
+ }
+
+ /**
+ * List all the nested classrs with an {@link Expected} annotation in a given class.
+ */
+ public Class<?>[] getTestClasses() {
+ var thisClass = this.getClass();
+ var ret = Arrays.stream(thisClass.getNestMembers())
+ .filter((c) -> c.getAnnotation(Expected.class) != null)
+ .toArray(Class[]::new);
+
+ assertThat(ret.length).isGreaterThan(0);
+
+ return ret;
+ }
+
+ /**
+ * This is the actual test method. We use junit-params to run this method for each target
+ * test class, which are returned by {@link #getTestClasses}.
+ *
+ * It runs each test class, and compare the result collected with
+ * {@link ResultCollectingListener} to expected results (as strings).
+ */
+ @Test
+ @Parameters(method = "getTestClasses")
+ public void doTest(Class<?> testClazz) {
+ doTest(testClazz, getExpectedResult(testClazz));
+ }
+
+ /**
+ * Run a given test class, and compare the result collected with
+ * {@link ResultCollectingListener} to expected results (as a string).
+ */
+ private void doTest(Class<?> testClazz, String expectedResult) {
+ Log.i(TAG, "Running test for " + testClazz);
+ var junitCore = new JUnitCore();
+
+ // Create a listener.
+ var listener = new ResultCollectingListener();
+ junitCore.addListener(listener);
+
+ // Set a listener to critical errors. This will also prevent
+ // {@link RavenwoodAwareTestRunner} from calling System.exit() when there's
+ // a critical error.
+ RavenwoodAwareTestRunner.private$ravenwood().setCriticalErrorHandler(
+ listener.sCriticalErrorListener);
+
+ try {
+ // Run the test class.
+ junitCore.run(testClazz);
+ } finally {
+ // Clear the critical error listener.
+ RavenwoodAwareTestRunner.private$ravenwood().setCriticalErrorHandler(null);
+ }
+
+ // Check the result.
+ assertWithMessage("Failure in test class: " + testClazz.getCanonicalName() + "]")
+ .that(listener.getResult())
+ .isEqualTo(expectedResult);
+ }
+
+ /**
+ * A JUnit RunListener that collects all the callbacks as a single string.
+ */
+ private static class ResultCollectingListener extends RunListener {
+ private final ArrayList<String> mResult = new ArrayList<>();
+
+ public final BiConsumer<String, Throwable> sCriticalErrorListener = (message, th) -> {
+ mResult.add("criticalError: " + message + ": " + th.getMessage());
+ };
+
+ @Override
+ public void testRunStarted(Description description) throws Exception {
+ mResult.add("testRunStarted: " + description);
+ }
+
+ @Override
+ public void testRunFinished(Result result) throws Exception {
+ mResult.add("testRunFinished: "
+ + result.getRunCount() + ","
+ + result.getFailureCount() + ","
+ + result.getAssumptionFailureCount() + ","
+ + result.getIgnoreCount());
+ }
+
+ @Override
+ public void testSuiteStarted(Description description) throws Exception {
+ mResult.add("testSuiteStarted: " + description);
+ }
+
+ @Override
+ public void testSuiteFinished(Description description) throws Exception {
+ mResult.add("testSuiteFinished: " + description);
+ }
+
+ @Override
+ public void testStarted(Description description) throws Exception {
+ mResult.add("testStarted: " + description);
+ }
+
+ @Override
+ public void testFinished(Description description) throws Exception {
+ mResult.add("testFinished: " + description);
+ }
+
+ @Override
+ public void testFailure(Failure failure) throws Exception {
+ mResult.add("testFailure: " + failure.getException().getMessage());
+ }
+
+ @Override
+ public void testAssumptionFailure(Failure failure) {
+ mResult.add("testAssumptionFailure: " + failure.getException().getMessage());
+ }
+
+ @Override
+ public void testIgnored(Description description) throws Exception {
+ mResult.add("testIgnored: " + description);
+ }
+
+ public String getResult() {
+ return String.join("\n", mResult);
+ }
+ }
+}
diff --git a/ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/adapter/RunnerRewritingAdapter.kt b/ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/adapter/RunnerRewritingAdapter.kt
index eaef2cf6a956..bd9d96d81604 100644
--- a/ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/adapter/RunnerRewritingAdapter.kt
+++ b/ravenwood/tools/ravenizer/src/com/android/platform/test/ravenwood/ravenizer/adapter/RunnerRewritingAdapter.kt
@@ -302,7 +302,7 @@ class RunnerRewritingAdapter private constructor(
override fun visitCode() {
visitFieldInsn(Opcodes.GETSTATIC,
ravenwoodTestRunnerType.internlName,
- RavenwoodAwareTestRunner.IMPLICIT_CLASS_MIN_RULE_NAME,
+ RavenwoodAwareTestRunner.IMPLICIT_CLASS_OUTER_RULE_NAME,
testRuleType.desc
)
visitFieldInsn(Opcodes.PUTSTATIC,
@@ -313,7 +313,7 @@ class RunnerRewritingAdapter private constructor(
visitFieldInsn(Opcodes.GETSTATIC,
ravenwoodTestRunnerType.internlName,
- RavenwoodAwareTestRunner.IMPLICIT_CLASS_MAX_RULE_NAME,
+ RavenwoodAwareTestRunner.IMPLICIT_CLASS_INNER_RULE_NAME,
testRuleType.desc
)
visitFieldInsn(Opcodes.PUTSTATIC,
@@ -361,7 +361,7 @@ class RunnerRewritingAdapter private constructor(
visitVarInsn(ALOAD, 0)
visitFieldInsn(Opcodes.GETSTATIC,
ravenwoodTestRunnerType.internlName,
- RavenwoodAwareTestRunner.IMPLICIT_INST_MIN_RULE_NAME,
+ RavenwoodAwareTestRunner.IMPLICIT_INST_OUTER_RULE_NAME,
testRuleType.desc
)
visitFieldInsn(Opcodes.PUTFIELD,
@@ -373,7 +373,7 @@ class RunnerRewritingAdapter private constructor(
visitVarInsn(ALOAD, 0)
visitFieldInsn(Opcodes.GETSTATIC,
ravenwoodTestRunnerType.internlName,
- RavenwoodAwareTestRunner.IMPLICIT_INST_MAX_RULE_NAME,
+ RavenwoodAwareTestRunner.IMPLICIT_INST_INNER_RULE_NAME,
testRuleType.desc
)
visitFieldInsn(Opcodes.PUTFIELD,
diff --git a/services/accessibility/Android.bp b/services/accessibility/Android.bp
index 3d7ad0b94d1b..b97ff6217403 100644
--- a/services/accessibility/Android.bp
+++ b/services/accessibility/Android.bp
@@ -10,6 +10,7 @@ package {
filegroup {
name: "services.accessibility-sources",
srcs: ["java/**/*.java"],
+ exclude_srcs: ["java/**/a11ychecker/*.java"],
path: "java",
visibility: ["//frameworks/base/services"],
}
@@ -26,16 +27,13 @@ java_library_static {
},
srcs: [
":services.accessibility-sources",
- ":statslog-accessibility-java-gen",
"//frameworks/base/packages/SettingsLib/RestrictedLockUtils:SettingsLibRestrictedLockUtilsSrc",
],
libs: [
- "aatf",
"services.core",
"androidx.annotation_annotation",
],
static_libs: [
- "accessibility_protos_lite",
"com_android_server_accessibility_flags_lib",
"//frameworks/base/packages/SystemUI/aconfig:com_android_systemui_flags_lib",
],
@@ -70,12 +68,3 @@ java_aconfig_library {
name: "com_android_server_accessibility_flags_lib",
aconfig_declarations: "com_android_server_accessibility_flags",
}
-
-genrule {
- name: "statslog-accessibility-java-gen",
- tools: ["stats-log-api-gen"],
- cmd: "$(location stats-log-api-gen) --java $(out) --module accessibility" +
- " --javaPackage com.android.server.accessibility.a11ychecker" +
- " --javaClass AccessibilityCheckerStatsLog --minApiLevel 34",
- out: ["java/com/android/server/accessibility/a11ychecker/AccessibilityCheckerStatsLog.java"],
-}
diff --git a/services/accessibility/TEST_MAPPING b/services/accessibility/TEST_MAPPING
index 3f85a9005582..0bc25e2dd3c4 100644
--- a/services/accessibility/TEST_MAPPING
+++ b/services/accessibility/TEST_MAPPING
@@ -1,34 +1,19 @@
{
"presubmit": [
{
- "name": "CtsAccessibilityServiceTestCases",
- "options": [
- {
- "exclude-annotation": "androidx.test.filters.FlakyTest"
- }
- ]
+ "name": "CtsAccessibilityServiceTestCases"
},
{
- "name": "CtsAccessibilityTestCases",
- "options": [
- {
- "exclude-annotation": "androidx.test.filters.FlakyTest"
- }
- ]
+ "name": "CtsAccessibilityTestCases"
},
{
- "name": "CtsUiAutomationTestCases",
- "options": [
- {
- "exclude-annotation": "androidx.test.filters.FlakyTest"
- }
- ]
+ "name": "CtsUiAutomationTestCases"
},
{
- "name": "FrameworksServicesTests_accessibility_Presubmit"
+ "name": "FrameworksServicesTests_accessibility"
},
{
- "name": "FrameworksCoreTests_accessibility_NO_FLAKES"
+ "name": "FrameworksCoreTests_accessibility"
}
],
"postsubmit": [
@@ -45,12 +30,7 @@
"name": "CtsUiAutomationTestCases"
},
{
- "name": "FrameworksServicesTests",
- "options": [
- {
- "include-filter": "com.android.server.accessibility"
- }
- ]
+ "name": "FrameworksServicesTests_accessibility"
},
{
"name": "FrameworksCoreTests_accessibility"
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index b541345e1cb8..7580b697b516 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -58,6 +58,7 @@ import static com.android.internal.accessibility.common.ShortcutConstants.UserSh
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP;
+import static com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity.EXTRA_TYPE_TO_CHOOSE;
import static com.android.internal.accessibility.util.AccessibilityStatsLogUtils.logAccessibilityShortcutActivated;
import static com.android.internal.accessibility.util.AccessibilityUtils.isUserSetupCompleted;
import static com.android.internal.util.FunctionalUtils.ignoreRemoteException;
@@ -1616,7 +1617,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
/**
* Invoked remotely over AIDL by SysUi when the accessibility button within the system's
- * navigation area has been clicked.
+ * navigation area has been clicked, or a gesture shortcut input has been performed.
*
* @param displayId The logical display id.
* @param targetName The flattened {@link ComponentName} string or the class name of a system
@@ -1646,7 +1647,26 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
}
mMainHandler.sendMessage(obtainMessage(
AccessibilityManagerService::performAccessibilityShortcutInternal, this,
- displayId, SOFTWARE, targetName));
+ displayId, getShortcutTypeForGenericShortcutCalls(currentUserId), targetName));
+ }
+
+ /**
+ * AIDL-exposed method to show the dialog
+ * for choosing the target for the gesture or button shortcuts.
+ * The shortcut is determined by the current navigation mode.
+ *
+ * @param displayId The id for the display to show the dialog on.
+ */
+ @Override
+ @EnforcePermission(STATUS_BAR_SERVICE)
+ public void notifyAccessibilityButtonLongClicked(int displayId) {
+ notifyAccessibilityButtonLongClicked_enforcePermission();
+ int userId;
+ synchronized (mLock) {
+ userId = mCurrentUserId;
+ }
+ showAccessibilityTargetsSelection(displayId,
+ getShortcutTypeForGenericShortcutCalls(userId), userId);
}
/**
@@ -2344,16 +2364,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
}
}
- private void showAccessibilityTargetsSelection(int displayId,
- @UserShortcutType int shortcutType) {
+ private void showAccessibilityTargetsSelection(int displayId, int shortcutType,
+ int userId) {
final Intent intent = new Intent(AccessibilityManager.ACTION_CHOOSE_ACCESSIBILITY_BUTTON);
final String chooserClassName = (shortcutType == HARDWARE)
? AccessibilityShortcutChooserActivity.class.getName()
: AccessibilityButtonChooserActivity.class.getName();
intent.setClassName(CHOOSER_PACKAGE_NAME, chooserClassName);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_CLEAR_TASK);
+ intent.putExtra(EXTRA_TYPE_TO_CHOOSE, shortcutType);
final Bundle bundle = ActivityOptions.makeBasic().setLaunchDisplayId(displayId).toBundle();
- mContext.startActivityAsUser(intent, bundle, UserHandle.of(mCurrentUserId));
+ mMainHandler.post(() ->
+ mContext.startActivityAsUser(intent, bundle, UserHandle.of(userId)));
}
private void launchShortcutTargetActivity(int displayId, ComponentName name) {
@@ -4011,7 +4033,7 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
* Perform the accessibility shortcut action.
*
* @param shortcutType The shortcut type.
- * @param displayId The display id of the accessibility button.
+ * @param displayId The display id the shortcut is being performed from.
* @param targetName The flattened {@link ComponentName} string or the class name of a system
* class implementing a supported accessibility feature, or {@code null} if there's no
* specified target.
@@ -4031,7 +4053,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
if (targetName == null) {
// In case there are many targets assigned to the given shortcut.
if (shortcutTargets.size() > 1) {
- showAccessibilityTargetsSelection(displayId, shortcutType);
+ showAccessibilityTargetsSelection(
+ displayId, shortcutType, getCurrentUserState().mUserId);
return;
}
targetName = shortcutTargets.get(0);
@@ -6563,6 +6586,18 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
callback));
}
+ @VisibleForTesting
+ int getShortcutTypeForGenericShortcutCalls(int userId) {
+ int navigationMode = Settings.Secure.getIntForUser(
+ mContext.getContentResolver(),
+ Settings.Secure.NAVIGATION_MODE, -1, userId);
+ if (android.provider.Flags.a11yStandaloneGestureEnabled()) {
+ return (navigationMode == NAV_BAR_MODE_GESTURAL) ? GESTURE : SOFTWARE;
+ } else {
+ return SOFTWARE;
+ }
+ }
+
void attachAccessibilityOverlayToDisplayInternal(
int interactionId,
int displayId,
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java
index b18e6ba8444d..0bf7ec001d4d 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityUserState.java
@@ -57,6 +57,7 @@ import android.view.accessibility.IAccessibilityManagerClient;
import com.android.internal.R;
import com.android.internal.accessibility.AccessibilityShortcutController;
+import com.android.internal.accessibility.common.ShortcutConstants;
import com.android.internal.accessibility.util.ShortcutUtils;
import java.io.FileDescriptor;
@@ -707,11 +708,16 @@ class AccessibilityUserState {
}
/**
- * Returns true if navibar magnification or shortcut key magnification is enabled.
+ * Returns true if a magnification shortcut of any type is enabled.
*/
public boolean isShortcutMagnificationEnabledLocked() {
- return mAccessibilityShortcutKeyTargets.contains(MAGNIFICATION_CONTROLLER_NAME)
- || mAccessibilityButtonTargets.contains(MAGNIFICATION_CONTROLLER_NAME);
+ for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ if (getShortcutTargetsInternalLocked(shortcutType)
+ .contains(MAGNIFICATION_CONTROLLER_NAME)) {
+ return true;
+ }
+ }
+ return false;
}
/**
diff --git a/services/accessibility/java/com/android/server/accessibility/a11ychecker/Android.bp b/services/accessibility/java/com/android/server/accessibility/a11ychecker/Android.bp
new file mode 100644
index 000000000000..e9ed202f3a49
--- /dev/null
+++ b/services/accessibility/java/com/android/server/accessibility/a11ychecker/Android.bp
@@ -0,0 +1,31 @@
+package {
+ default_applicable_licenses: ["frameworks_base_license"],
+}
+
+// TODO(http://b/364326163): a11ychecker depends on aatf which currently can't be used in the system
+// server as it pulls in test deps. We moved a11ychecker sources from services.accessibility to an
+// isolated library while this is resolved.
+java_library_static {
+ name: "a11ychecker",
+ srcs: [
+ "*.java",
+ ":statslog-accessibility-java-gen",
+ ],
+ libs: [
+ "aatf",
+ "androidx.annotation_annotation",
+ ],
+ static_libs: [
+ "accessibility_protos_lite",
+ "com_android_server_accessibility_flags_lib",
+ ],
+}
+
+genrule {
+ name: "statslog-accessibility-java-gen",
+ tools: ["stats-log-api-gen"],
+ cmd: "$(location stats-log-api-gen) --java $(out) --module accessibility" +
+ " --javaPackage com.android.server.accessibility.a11ychecker" +
+ " --javaClass AccessibilityCheckerStatsLog --minApiLevel 34",
+ out: ["java/com/android/server/accessibility/a11ychecker/AccessibilityCheckerStatsLog.java"],
+}
diff --git a/services/appfunctions/TEST_MAPPING b/services/appfunctions/TEST_MAPPING
new file mode 100644
index 000000000000..91e82ec0e95b
--- /dev/null
+++ b/services/appfunctions/TEST_MAPPING
@@ -0,0 +1,10 @@
+{
+ "postsubmit": [
+ {
+ "name": "FrameworksAppFunctionsTests"
+ },
+ {
+ "name": "CtsAppFunctionTestCases"
+ }
+ ]
+} \ No newline at end of file
diff --git a/services/appfunctions/java/com/android/server/appfunctions/CallerValidatorImpl.java b/services/appfunctions/java/com/android/server/appfunctions/CallerValidatorImpl.java
index 35905edbcf24..618a5aedd9bb 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/CallerValidatorImpl.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/CallerValidatorImpl.java
@@ -79,17 +79,20 @@ class CallerValidatorImpl implements CallerValidator {
// TODO(b/360864791): Add and honor apps that opt-out from EXECUTE_APP_FUNCTIONS caller.
public boolean verifyCallerCanExecuteAppFunction(
@NonNull String callerPackageName, @NonNull String targetPackageName) {
+ if (callerPackageName.equals(targetPackageName)) {
+ return true;
+ }
+
int pid = Binder.getCallingPid();
int uid = Binder.getCallingUid();
- boolean hasExecutionPermission =
+ boolean hasTrustedExecutionPermission =
mContext.checkPermission(
Manifest.permission.EXECUTE_APP_FUNCTIONS_TRUSTED, pid, uid)
== PackageManager.PERMISSION_GRANTED;
- boolean hasTrustedExecutionPermission =
+ boolean hasExecutionPermission =
mContext.checkPermission(Manifest.permission.EXECUTE_APP_FUNCTIONS, pid, uid)
== PackageManager.PERMISSION_GRANTED;
- boolean isSamePackage = callerPackageName.equals(targetPackageName);
- return hasExecutionPermission || hasTrustedExecutionPermission || isSamePackage;
+ return hasExecutionPermission || hasTrustedExecutionPermission;
}
@Override
diff --git a/services/appfunctions/java/com/android/server/appfunctions/FutureAppSearchSession.java b/services/appfunctions/java/com/android/server/appfunctions/FutureAppSearchSession.java
index 094723814e17..39aa27ae794e 100644
--- a/services/appfunctions/java/com/android/server/appfunctions/FutureAppSearchSession.java
+++ b/services/appfunctions/java/com/android/server/appfunctions/FutureAppSearchSession.java
@@ -27,6 +27,7 @@ import android.app.appsearch.GenericDocument;
import android.app.appsearch.GetByDocumentIdRequest;
import android.app.appsearch.GetSchemaResponse;
import android.app.appsearch.PutDocumentsRequest;
+import android.app.appsearch.RemoveByDocumentIdRequest;
import android.app.appsearch.SearchResult;
import android.app.appsearch.SearchResults;
import android.app.appsearch.SearchSpec;
@@ -146,6 +147,22 @@ public class FutureAppSearchSession implements Closeable {
});
}
+ /** Removes documents from the AppSearchSession database. */
+ public AndroidFuture<AppSearchBatchResult<String, Void>> remove(
+ @NonNull RemoveByDocumentIdRequest removeRequest) {
+ return getSessionAsync()
+ .thenCompose(
+ session -> {
+ AndroidFuture<AppSearchBatchResult<String, Void>>
+ settableBatchResultFuture = new AndroidFuture<>();
+ session.remove(
+ removeRequest,
+ mExecutor,
+ new BatchResultCallbackAdapter<>(settableBatchResultFuture));
+ return settableBatchResultFuture;
+ });
+ }
+
/**
* Retrieves documents from the open AppSearchSession that match a given query string and type
* of search provided.
@@ -200,9 +217,7 @@ public class FutureAppSearchSession implements Closeable {
Objects.requireNonNull(namespace);
GetByDocumentIdRequest request =
- new GetByDocumentIdRequest.Builder(namespace)
- .addIds(documentId)
- .build();
+ new GetByDocumentIdRequest.Builder(namespace).addIds(documentId).build();
return getSessionAsync()
.thenCompose(
session -> {
diff --git a/services/appfunctions/java/com/android/server/appfunctions/MetadataSyncAdapter.java b/services/appfunctions/java/com/android/server/appfunctions/MetadataSyncAdapter.java
new file mode 100644
index 000000000000..01e10086a03a
--- /dev/null
+++ b/services/appfunctions/java/com/android/server/appfunctions/MetadataSyncAdapter.java
@@ -0,0 +1,191 @@
+/*
+ * Copyright (C) 2024 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.server.appfunctions;
+
+import android.annotation.NonNull;
+import android.annotation.WorkerThread;
+import android.app.appsearch.PropertyPath;
+import android.app.appsearch.SearchResult;
+import android.app.appsearch.SearchSpec;
+import android.util.ArrayMap;
+import android.util.ArraySet;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.server.appfunctions.FutureAppSearchSession.FutureSearchResults;
+
+import java.util.List;
+import java.util.Objects;
+import java.util.concurrent.ExecutionException;
+import java.util.concurrent.Executor;
+
+/**
+ * This class implements helper methods for synchronously interacting with AppSearch while
+ * synchronizing AppFunction runtime and static metadata.
+ */
+public class MetadataSyncAdapter {
+ private final FutureAppSearchSession mFutureAppSearchSession;
+ private final Executor mSyncExecutor;
+
+ public MetadataSyncAdapter(
+ @NonNull Executor syncExecutor,
+ @NonNull FutureAppSearchSession futureAppSearchSession) {
+ mSyncExecutor = Objects.requireNonNull(syncExecutor);
+ mFutureAppSearchSession = Objects.requireNonNull(futureAppSearchSession);
+ }
+
+ /**
+ * This method returns a map of package names to a set of function ids that are in the static
+ * metadata but not in the runtime metadata.
+ *
+ * @param staticPackageToFunctionMap A map of package names to a set of function ids from the
+ * static metadata.
+ * @param runtimePackageToFunctionMap A map of package names to a set of function ids from the
+ * runtime metadata.
+ * @return A map of package names to a set of function ids that are in the static metadata but
+ * not in the runtime metadata.
+ */
+ @NonNull
+ @VisibleForTesting
+ static ArrayMap<String, ArraySet<String>> getAddedFunctionsDiffMap(
+ @NonNull ArrayMap<String, ArraySet<String>> staticPackageToFunctionMap,
+ @NonNull ArrayMap<String, ArraySet<String>> runtimePackageToFunctionMap) {
+ Objects.requireNonNull(staticPackageToFunctionMap);
+ Objects.requireNonNull(runtimePackageToFunctionMap);
+
+ return getFunctionsDiffMap(staticPackageToFunctionMap, runtimePackageToFunctionMap);
+ }
+
+ /**
+ * This method returns a map of package names to a set of function ids that are in the runtime
+ * metadata but not in the static metadata.
+ *
+ * @param staticPackageToFunctionMap A map of package names to a set of function ids from the
+ * static metadata.
+ * @param runtimePackageToFunctionMap A map of package names to a set of function ids from the
+ * runtime metadata.
+ * @return A map of package names to a set of function ids that are in the runtime metadata but
+ * not in the static metadata.
+ */
+ @NonNull
+ @VisibleForTesting
+ static ArrayMap<String, ArraySet<String>> getRemovedFunctionsDiffMap(
+ @NonNull ArrayMap<String, ArraySet<String>> staticPackageToFunctionMap,
+ @NonNull ArrayMap<String, ArraySet<String>> runtimePackageToFunctionMap) {
+ Objects.requireNonNull(staticPackageToFunctionMap);
+ Objects.requireNonNull(runtimePackageToFunctionMap);
+
+ return getFunctionsDiffMap(runtimePackageToFunctionMap, staticPackageToFunctionMap);
+ }
+
+ @NonNull
+ private static ArrayMap<String, ArraySet<String>> getFunctionsDiffMap(
+ @NonNull ArrayMap<String, ArraySet<String>> packageToFunctionMapA,
+ @NonNull ArrayMap<String, ArraySet<String>> packageToFunctionMapB) {
+ Objects.requireNonNull(packageToFunctionMapA);
+ Objects.requireNonNull(packageToFunctionMapB);
+
+ ArrayMap<String, ArraySet<String>> diffMap = new ArrayMap<>();
+ for (String packageName : packageToFunctionMapA.keySet()) {
+ if (!packageToFunctionMapB.containsKey(packageName)) {
+ diffMap.put(packageName, packageToFunctionMapA.get(packageName));
+ continue;
+ }
+ ArraySet<String> diffFunctions = new ArraySet<>();
+ for (String functionId :
+ Objects.requireNonNull(packageToFunctionMapA.get(packageName))) {
+ if (!Objects.requireNonNull(packageToFunctionMapB.get(packageName))
+ .contains(functionId)) {
+ diffFunctions.add(functionId);
+ }
+ }
+ if (!diffFunctions.isEmpty()) {
+ diffMap.put(packageName, diffFunctions);
+ }
+ }
+ return diffMap;
+ }
+
+ /**
+ * This method returns a map of package names to a set of function ids from the AppFunction
+ * metadata.
+ *
+ * @param schemaType The name space of the AppFunction metadata.
+ * @return A map of package names to a set of function ids from the AppFunction metadata.
+ */
+ @NonNull
+ @VisibleForTesting
+ @WorkerThread
+ ArrayMap<String, ArraySet<String>> getPackageToFunctionIdMap(
+ @NonNull String schemaType,
+ @NonNull String propertyFunctionId,
+ @NonNull String propertyPackageName)
+ throws ExecutionException, InterruptedException {
+ Objects.requireNonNull(schemaType);
+ Objects.requireNonNull(propertyFunctionId);
+ Objects.requireNonNull(propertyPackageName);
+ ArrayMap<String, ArraySet<String>> packageToFunctionIds = new ArrayMap<>();
+
+ FutureSearchResults futureSearchResults =
+ mFutureAppSearchSession
+ .search(
+ "",
+ buildMetadataSearchSpec(
+ schemaType, propertyFunctionId, propertyPackageName))
+ .get();
+ List<SearchResult> searchResultsList = futureSearchResults.getNextPage().get();
+ // TODO(b/357551503): This could be expensive if we have more functions
+ while (!searchResultsList.isEmpty()) {
+ for (SearchResult searchResult : searchResultsList) {
+ String packageName =
+ searchResult.getGenericDocument().getPropertyString(propertyPackageName);
+ String functionId =
+ searchResult.getGenericDocument().getPropertyString(propertyFunctionId);
+ packageToFunctionIds
+ .computeIfAbsent(packageName, k -> new ArraySet<>())
+ .add(functionId);
+ }
+ searchResultsList = futureSearchResults.getNextPage().get();
+ }
+ return packageToFunctionIds;
+ }
+
+ /**
+ * This method returns a {@link SearchSpec} for searching the AppFunction metadata.
+ *
+ * @param schemaType The schema type of the AppFunction metadata.
+ * @param propertyFunctionId The property name of the function id in the AppFunction metadata.
+ * @param propertyPackageName The property name of the package name in the AppFunction metadata.
+ * @return A {@link SearchSpec} for searching the AppFunction metadata.
+ */
+ @NonNull
+ private static SearchSpec buildMetadataSearchSpec(
+ @NonNull String schemaType,
+ @NonNull String propertyFunctionId,
+ @NonNull String propertyPackageName) {
+ Objects.requireNonNull(schemaType);
+ Objects.requireNonNull(propertyFunctionId);
+ Objects.requireNonNull(propertyPackageName);
+ return new SearchSpec.Builder()
+ .addFilterSchemas(schemaType)
+ .addProjectionPaths(
+ schemaType,
+ List.of(
+ new PropertyPath(propertyFunctionId),
+ new PropertyPath(propertyPackageName)))
+ .build();
+ }
+}
diff --git a/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java b/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java
index 5044e93b293d..2c261fe668fb 100644
--- a/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java
+++ b/services/autofill/java/com/android/server/autofill/PresentationStatsEventLogger.java
@@ -842,9 +842,13 @@ public final class PresentationStatsEventLogger {
+ "event");
return;
}
+
PresentationStatsEventInternal event = mEventInternal.get();
+ boolean ignoreLogging = !event.mIsDatasetAvailable;
+
if (sVerbose) {
Slog.v(TAG, "(" + caller + ") "
+ + (ignoreLogging ? "IGNORING - following event won't be logged: " : "")
+ "Log AutofillPresentationEventReported:"
+ " requestId=" + event.mRequestId
+ " sessionId=" + mSessionId
@@ -907,7 +911,8 @@ public final class PresentationStatsEventLogger {
}
// TODO(b/234185326): Distinguish empty responses from other no presentation reasons.
- if (!event.mIsDatasetAvailable) {
+ if (ignoreLogging) {
+ Slog.w(TAG, "Empty dataset. Autofill ignoring log");
mEventInternal = Optional.empty();
return;
}
diff --git a/services/core/java/com/android/server/BatteryService.java b/services/core/java/com/android/server/BatteryService.java
index 1470e9a9d925..6657c1c1ba89 100644
--- a/services/core/java/com/android/server/BatteryService.java
+++ b/services/core/java/com/android/server/BatteryService.java
@@ -238,13 +238,16 @@ public final class BatteryService extends SystemService {
final SomeArgs args = (SomeArgs) msg.obj;
final Context context;
final Intent intent;
+ final boolean forceUpdate;
try {
context = (Context) args.arg1;
intent = (Intent) args.arg2;
+ forceUpdate = (Boolean) args.arg3;
} finally {
args.recycle();
}
- broadcastBatteryChangedIntent(context, intent, BATTERY_CHANGED_OPTIONS);
+ broadcastBatteryChangedIntent(context, intent, BATTERY_CHANGED_OPTIONS,
+ forceUpdate);
return true;
}
case MSG_BROADCAST_POWER_CONNECTION_CHANGED: {
@@ -798,7 +801,7 @@ public final class BatteryService extends SystemService {
// We are doing this after sending the above broadcasts, so anything processing
// them will get the new sequence number at that point. (See for example how testing
// of JobScheduler's BatteryController works.)
- sendBatteryChangedIntentLocked();
+ sendBatteryChangedIntentLocked(force);
if (mLastBatteryLevel != mHealthInfo.batteryLevel || mLastPlugType != mPlugType) {
sendBatteryLevelChangedIntentLocked();
}
@@ -829,7 +832,7 @@ public final class BatteryService extends SystemService {
}
}
- private void sendBatteryChangedIntentLocked() {
+ private void sendBatteryChangedIntentLocked(boolean forceUpdate) {
// Pack up the values and broadcast them to everyone
final Intent intent = new Intent(Intent.ACTION_BATTERY_CHANGED);
intent.addFlags(Intent.FLAG_RECEIVER_REGISTERED_ONLY
@@ -869,15 +872,17 @@ public final class BatteryService extends SystemService {
final SomeArgs args = SomeArgs.obtain();
args.arg1 = mContext;
args.arg2 = intent;
+ args.arg3 = forceUpdate;
mHandler.obtainMessage(MSG_BROADCAST_BATTERY_CHANGED, args).sendToTarget();
} else {
mHandler.post(() -> broadcastBatteryChangedIntent(mContext,
- intent, BATTERY_CHANGED_OPTIONS));
+ intent, BATTERY_CHANGED_OPTIONS, forceUpdate));
}
}
private static void broadcastBatteryChangedIntent(Context context, Intent intent,
- Bundle options) {
+ Bundle options, boolean forceUpdate) {
+ traceBatteryChangedBroadcastEvent(intent, forceUpdate);
// TODO (293959093): It is important that SystemUI receives this broadcast as soon as
// possible. Ideally, it should be using binder callbacks but until then, dispatch this
// as a foreground broadcast to SystemUI.
@@ -895,6 +900,53 @@ public final class BatteryService extends SystemService {
AppOpsManager.OP_NONE, options, UserHandle.USER_ALL);
}
+ private static void traceBatteryChangedBroadcastEvent(Intent intent, boolean forceUpdate) {
+ if (!com.android.server.flags.Flags.traceBatteryChangedBroadcastEvent()) {
+ return;
+ }
+ if (!Trace.isTagEnabled(Trace.TRACE_TAG_SYSTEM_SERVER)) return;
+
+ final StringBuilder builder = new StringBuilder();
+ builder.append("broadcastBatteryChanged; ");
+ builder.append("force="); builder.append(forceUpdate);
+ builder.append(",seq="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_SEQUENCE, -1));
+ builder.append(",s="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_STATUS, -1));
+ builder.append(",h="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_HEALTH, -1));
+ builder.append(",p="); builder.append(intent.getBooleanExtra(
+ BatteryManager.EXTRA_PRESENT, false));
+ builder.append(",l="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_LEVEL, -1));
+ builder.append(",bl="); builder.append(intent.getBooleanExtra(
+ BatteryManager.EXTRA_BATTERY_LOW, false));
+ builder.append(",sc="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_SCALE, -1));
+ builder.append(",pt="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_PLUGGED, -1));
+ builder.append(",v="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_VOLTAGE, -1));
+ builder.append(",t="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_TEMPERATURE, -1));
+ builder.append(",tech="); builder.append(intent.getStringExtra(
+ BatteryManager.EXTRA_TECHNOLOGY));
+ builder.append(",invc="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_INVALID_CHARGER, -1));
+ builder.append(",mcc="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_MAX_CHARGING_CURRENT, -1));
+ builder.append(",mcv="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_MAX_CHARGING_VOLTAGE, -1));
+ builder.append(",chc="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_CHARGE_COUNTER, -1));
+ builder.append(",cc="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_CYCLE_COUNT, -1));
+ builder.append(",chs="); builder.append(intent.getIntExtra(
+ BatteryManager.EXTRA_CHARGING_STATUS, -1));
+
+ Trace.instant(Trace.TRACE_TAG_SYSTEM_SERVER, builder.toString());
+ }
+
private void sendBatteryLevelChangedIntentLocked() {
Bundle event = new Bundle();
long now = SystemClock.elapsedRealtime();
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java
index 955b75d8bba0..3f4902db70f5 100644
--- a/services/core/java/com/android/server/am/BatteryStatsService.java
+++ b/services/core/java/com/android/server/am/BatteryStatsService.java
@@ -1122,7 +1122,11 @@ public final class BatteryStatsService extends IBatteryStats.Stub
throw new UnsupportedOperationException("Unknown tagId=" + atomTag);
}
final byte[] statsProto = bus.getStatsProto();
-
+ try {
+ bus.close();
+ } catch (IOException e) {
+ Slog.w(TAG, "Failure close BatteryUsageStats", e);
+ }
data.add(FrameworkStatsLog.buildStatsEvent(atomTag, statsProto));
return StatsManager.PULL_SUCCESS;
diff --git a/services/core/java/com/android/server/am/CachedAppOptimizer.java b/services/core/java/com/android/server/am/CachedAppOptimizer.java
index 8f52f67ff7e0..416c11090515 100644
--- a/services/core/java/com/android/server/am/CachedAppOptimizer.java
+++ b/services/core/java/com/android/server/am/CachedAppOptimizer.java
@@ -86,7 +86,6 @@ import com.android.server.ServiceThread;
import dalvik.annotation.optimization.NeverCompile;
-import java.io.FileReader;
import java.io.IOException;
import java.io.PrintWriter;
import java.lang.annotation.Retention;
@@ -2318,6 +2317,7 @@ public final class CachedAppOptimizer {
Slog.d(TAG_AM, "Skipping freeze because process is marked "
+ "should not be frozen");
}
+ reportProcessFreezableChangedLocked(proc);
return;
}
diff --git a/services/core/java/com/android/server/am/OomAdjuster.java b/services/core/java/com/android/server/am/OomAdjuster.java
index 3f54cfc03114..f0cc09f7c232 100644
--- a/services/core/java/com/android/server/am/OomAdjuster.java
+++ b/services/core/java/com/android/server/am/OomAdjuster.java
@@ -1923,7 +1923,6 @@ public class OomAdjuster {
int procState;
int capability = cycleReEval ? getInitialCapability(app) : 0;
- boolean foregroundActivities = false;
boolean hasVisibleActivities = false;
if (app == topApp && PROCESS_STATE_CUR_TOP == PROCESS_STATE_TOP) {
// The last app on the list is the foreground app.
@@ -1937,7 +1936,6 @@ public class OomAdjuster {
schedGroup = SCHED_GROUP_DEFAULT;
state.setAdjType("intermediate-top-activity");
}
- foregroundActivities = true;
hasVisibleActivities = true;
procState = PROCESS_STATE_TOP;
if (DEBUG_OOM_ADJ_REASON || logUid == appUid) {
@@ -1988,7 +1986,6 @@ public class OomAdjuster {
adj = FOREGROUND_APP_ADJ;
schedGroup = SCHED_GROUP_BACKGROUND;
state.setAdjType("top-sleeping");
- foregroundActivities = true;
procState = PROCESS_STATE_CUR_TOP;
if (DEBUG_OOM_ADJ_REASON || logUid == appUid) {
reportOomAdjMessageLocked(TAG_OOM_ADJ, "Making top (sleeping): " + app);
@@ -2008,7 +2005,8 @@ public class OomAdjuster {
}
}
- // Examine all activities if not already foreground.
+ // Examine all non-top activities.
+ boolean foregroundActivities = app == topApp;
if (!foregroundActivities && state.getCachedHasActivities()) {
state.computeOomAdjFromActivitiesIfNecessary(mTmpComputeOomAdjWindowCallback,
adj, foregroundActivities, hasVisibleActivities, procState, schedGroup,
@@ -2532,25 +2530,6 @@ public class OomAdjuster {
}
}
- state.setCurRawAdj(adj);
- adj = psr.modifyRawOomAdj(adj);
- if (adj > state.getMaxAdj()) {
- adj = state.getMaxAdj();
- if (adj <= PERCEPTIBLE_LOW_APP_ADJ) {
- schedGroup = SCHED_GROUP_DEFAULT;
- }
- }
-
- // Put bound foreground services in a special sched group for additional
- // restrictions on screen off
- if (procState >= PROCESS_STATE_BOUND_FOREGROUND_SERVICE
- && mService.mWakefulness.get() != PowerManagerInternal.WAKEFULNESS_AWAKE
- && !state.shouldScheduleLikeTopApp()) {
- if (schedGroup > SCHED_GROUP_RESTRICTED) {
- schedGroup = SCHED_GROUP_RESTRICTED;
- }
- }
-
// apply capability from FGS.
if (psr.hasForegroundServices()) {
capability |= capabilityFromFGS;
diff --git a/services/core/java/com/android/server/am/ProcessList.java b/services/core/java/com/android/server/am/ProcessList.java
index 5b4e57350c40..4898f1095c58 100644
--- a/services/core/java/com/android/server/am/ProcessList.java
+++ b/services/core/java/com/android/server/am/ProcessList.java
@@ -2390,8 +2390,8 @@ public final class ProcessList {
}
String volumeUuid = packageState.getVolumeUuid();
long inode = packageState.getUserStateOrDefault(userId).getCeDataInode();
- if (inode == 0) {
- Slog.w(TAG, packageName + " inode == 0 (b/152760674)");
+ if (inode <= 0) {
+ Slog.w(TAG, packageName + " inode == 0 or app uninstalled with keep-data");
return null;
}
result.put(packageName, Pair.create(volumeUuid, inode));
@@ -3397,12 +3397,16 @@ public final class ProcessList {
final boolean wasStopped = info.isStopped();
// Check if we should mark the processrecord for first launch after force-stopping
if (wasStopped) {
- boolean wasEverLaunched;
+ boolean wasEverLaunched = false;
if (android.app.Flags.useAppInfoNotLaunched()) {
wasEverLaunched = !info.isNotLaunched();
} else {
- wasEverLaunched = mService.getPackageManagerInternal()
- .wasPackageEverLaunched(r.getApplicationInfo().packageName, r.userId);
+ try {
+ wasEverLaunched = mService.getPackageManagerInternal()
+ .wasPackageEverLaunched(r.getApplicationInfo().packageName, r.userId);
+ } catch (IllegalArgumentException e) {
+ // Package doesn't have state yet, assume not launched
+ }
}
// Check if the hosting record is for an activity or not. Since the stopped
// state tracking is handled differently to avoid WM calling back into AM,
@@ -4121,19 +4125,6 @@ public final class ProcessList {
return false;
}
- private static int procStateToImportance(int procState, int memAdj,
- ActivityManager.RunningAppProcessInfo currApp,
- int clientTargetSdk) {
- int imp = ActivityManager.RunningAppProcessInfo.procStateToImportanceForTargetSdk(
- procState, clientTargetSdk);
- if (imp == ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND) {
- currApp.lru = memAdj;
- } else {
- currApp.lru = 0;
- }
- return imp;
- }
-
@GuardedBy(anyOf = {"mService", "mProcLock"})
void fillInProcMemInfoLOSP(ProcessRecord app,
ActivityManager.RunningAppProcessInfo outInfo,
@@ -4151,14 +4142,20 @@ public final class ProcessList {
}
outInfo.lastTrimLevel = app.mProfile.getTrimMemoryLevel();
final ProcessStateRecord state = app.mState;
- int adj = state.getCurAdj();
- int procState = state.getCurProcState();
- outInfo.importance = procStateToImportance(procState, adj, outInfo,
- clientTargetSdk);
+ final int procState = state.getCurProcState();
+ outInfo.importance = ActivityManager.RunningAppProcessInfo
+ .procStateToImportanceForTargetSdk(procState, clientTargetSdk);
+ if (outInfo.importance == ActivityManager.RunningAppProcessInfo.IMPORTANCE_BACKGROUND) {
+ outInfo.lru = state.getCurAdj();
+ } else {
+ outInfo.lru = 0;
+ }
outInfo.importanceReasonCode = state.getAdjTypeCode();
outInfo.processState = procState;
outInfo.isFocused = (app == mService.getTopApp());
outInfo.lastActivityTime = app.getLastActivityTime();
+ // Note: ActivityManager$RunningAppProcessInfo.copyTo() must be updated if what gets
+ // "filled into" outInfo in this method changes.
}
@GuardedBy(anyOf = {"mService", "mProcLock"})
diff --git a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java
index 99c3ecaba2e0..439bca0ea36a 100644
--- a/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java
+++ b/services/core/java/com/android/server/am/SettingsToPropertiesMapper.java
@@ -453,7 +453,9 @@ public class SettingsToPropertiesMapper {
proto.write(StorageRequestMessage.FlagOverrideMessage.PACKAGE_NAME, packageName);
proto.write(StorageRequestMessage.FlagOverrideMessage.FLAG_NAME, flagName);
proto.write(StorageRequestMessage.FlagOverrideMessage.FLAG_VALUE, flagValue);
- proto.write(StorageRequestMessage.FlagOverrideMessage.IS_LOCAL, isLocal);
+ proto.write(StorageRequestMessage.FlagOverrideMessage.OVERRIDE_TYPE, isLocal
+ ? StorageRequestMessage.LOCAL_ON_REBOOT
+ : StorageRequestMessage.SERVER_ON_REBOOT);
proto.end(msgToken);
proto.end(msgsToken);
}
diff --git a/services/core/java/com/android/server/biometrics/AuthService.java b/services/core/java/com/android/server/biometrics/AuthService.java
index 2a1687209aad..5d850896d5de 100644
--- a/services/core/java/com/android/server/biometrics/AuthService.java
+++ b/services/core/java/com/android/server/biometrics/AuthService.java
@@ -50,7 +50,6 @@ import android.hardware.biometrics.PromptInfo;
import android.hardware.biometrics.SensorLocationInternal;
import android.hardware.biometrics.SensorPropertiesInternal;
import android.hardware.biometrics.face.IFace;
-import android.hardware.biometrics.fingerprint.IFingerprint;
import android.hardware.face.FaceSensorConfigurations;
import android.hardware.face.FaceSensorProperties;
import android.hardware.face.FaceSensorPropertiesInternal;
@@ -74,6 +73,7 @@ import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
import com.android.server.SystemService;
+import com.android.server.biometrics.sensors.fingerprint.FingerprintService;
import com.android.server.companion.virtual.VirtualDeviceManagerInternal;
import java.util.ArrayList;
@@ -203,7 +203,7 @@ public class AuthService extends SystemService {
*/
@VisibleForTesting
public String[] getFingerprintAidlInstances() {
- return ServiceManager.getDeclaredInstances(IFingerprint.DESCRIPTOR);
+ return FingerprintService.getDeclaredInstances();
}
/**
@@ -850,10 +850,28 @@ public class AuthService extends SystemService {
return;
}
+ boolean tempResetLockoutRequiresChallenge = false;
+
+ if (hidlConfigStrings != null && hidlConfigStrings.length > 0) {
+ for (String configString : hidlConfigStrings) {
+ try {
+ SensorConfig sensor = new SensorConfig(configString);
+ switch (sensor.modality) {
+ case BiometricAuthenticator.TYPE_FACE:
+ tempResetLockoutRequiresChallenge = true;
+ break;
+ }
+ } catch (Exception e) {
+ Slog.e(TAG, "Error parsing configString: " + configString, e);
+ }
+ }
+ }
+
+ final boolean resetLockoutRequiresChallenge = tempResetLockoutRequiresChallenge;
+
handlerProvider.getFaceHandler().post(() -> {
final FaceSensorConfigurations mFaceSensorConfigurations =
- new FaceSensorConfigurations(hidlConfigStrings != null
- && hidlConfigStrings.length > 0);
+ new FaceSensorConfigurations(resetLockoutRequiresChallenge);
if (hidlConfigStrings != null && hidlConfigStrings.length > 0) {
mFaceSensorConfigurations.addHidlConfigs(hidlConfigStrings, context);
diff --git a/services/core/java/com/android/server/biometrics/PreAuthInfo.java b/services/core/java/com/android/server/biometrics/PreAuthInfo.java
index ac3c02823d0a..b2c616ae5b3c 100644
--- a/services/core/java/com/android/server/biometrics/PreAuthInfo.java
+++ b/services/core/java/com/android/server/biometrics/PreAuthInfo.java
@@ -316,6 +316,7 @@ class PreAuthInfo {
Pair<BiometricSensor, Integer> sensorNotEnrolled = null;
Pair<BiometricSensor, Integer> sensorLockout = null;
Pair<BiometricSensor, Integer> hardwareNotDetected = null;
+ Pair<BiometricSensor, Integer> biometricAppNotAllowed = null;
for (Pair<BiometricSensor, Integer> pair : ineligibleSensors) {
final int status = pair.second;
if (status == BIOMETRIC_LOCKOUT_TIMED || status == BIOMETRIC_LOCKOUT_PERMANENT) {
@@ -327,6 +328,9 @@ class PreAuthInfo {
if (status == BIOMETRIC_HARDWARE_NOT_DETECTED) {
hardwareNotDetected = pair;
}
+ if (status == BIOMETRIC_NOT_ENABLED_FOR_APPS) {
+ biometricAppNotAllowed = pair;
+ }
}
// If there is a sensor locked out, prioritize lockout over other sensor's error.
@@ -339,6 +343,10 @@ class PreAuthInfo {
return hardwareNotDetected;
}
+ if (Flags.mandatoryBiometrics() && biometricAppNotAllowed != null) {
+ return biometricAppNotAllowed;
+ }
+
// If the caller requested STRONG, and the device contains both STRONG and non-STRONG
// sensors, prioritize BIOMETRIC_NOT_ENROLLED over the weak sensor's
// BIOMETRIC_INSUFFICIENT_STRENGTH error.
diff --git a/services/core/java/com/android/server/biometrics/Utils.java b/services/core/java/com/android/server/biometrics/Utils.java
index 871121472938..407ef1e41aa6 100644
--- a/services/core/java/com/android/server/biometrics/Utils.java
+++ b/services/core/java/com/android/server/biometrics/Utils.java
@@ -321,6 +321,9 @@ public class Utils {
case BiometricConstants.BIOMETRIC_ERROR_MANDATORY_NOT_ACTIVE:
biometricManagerCode = BiometricManager.BIOMETRIC_ERROR_MANDATORY_NOT_ACTIVE;
break;
+ case BiometricConstants.BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS:
+ biometricManagerCode = BiometricManager.BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS;
+ break;
default:
Slog.e(BiometricService.TAG, "Unhandled result code: " + biometricConstantsCode);
biometricManagerCode = BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE;
@@ -384,9 +387,12 @@ public class Utils {
return BiometricConstants.BIOMETRIC_ERROR_SENSOR_PRIVACY_ENABLED;
case MANDATORY_BIOMETRIC_UNAVAILABLE_ERROR:
return BiometricConstants.BIOMETRIC_ERROR_MANDATORY_NOT_ACTIVE;
+ case BIOMETRIC_NOT_ENABLED_FOR_APPS:
+ if (Flags.mandatoryBiometrics()) {
+ return BiometricConstants.BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS;
+ }
case BIOMETRIC_DISABLED_BY_DEVICE_POLICY:
case BIOMETRIC_HARDWARE_NOT_DETECTED:
- case BIOMETRIC_NOT_ENABLED_FOR_APPS:
default:
return BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE;
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/FingerprintService.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/FingerprintService.java
index 60cfd5a5a6ae..2f6ba0b852ee 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/FingerprintService.java
@@ -26,6 +26,7 @@ import static android.hardware.biometrics.BiometricFingerprintConstants.FINGERPR
import static android.hardware.biometrics.BiometricFingerprintConstants.FINGERPRINT_ERROR_USER_CANCELED;
import static android.hardware.biometrics.BiometricFingerprintConstants.FINGERPRINT_ERROR_VENDOR;
import static android.hardware.biometrics.SensorProperties.STRENGTH_STRONG;
+import static android.hardware.fingerprint.FingerprintSensorConfigurations.getIFingerprint;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -78,6 +79,7 @@ import android.util.proto.ProtoOutputStream;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.ArrayUtils;
import com.android.internal.util.DumpUtils;
import com.android.internal.widget.LockPatternUtils;
import com.android.server.SystemService;
@@ -1015,7 +1017,7 @@ public class FingerprintService extends SystemService {
this(context, BiometricContext.getInstance(context),
() -> IBiometricService.Stub.asInterface(
ServiceManager.getService(Context.BIOMETRIC_SERVICE)),
- () -> ServiceManager.getDeclaredInstances(IFingerprint.DESCRIPTOR),
+ () -> getDeclaredInstances(),
null /* fingerprintProvider */,
null /* fingerprintProviderFunction */);
}
@@ -1039,8 +1041,7 @@ public class FingerprintService extends SystemService {
mFingerprintProvider = fingerprintProvider != null ? fingerprintProvider :
(name) -> {
final String fqName = IFingerprint.DESCRIPTOR + "/" + name;
- final IFingerprint fp = IFingerprint.Stub.asInterface(
- Binder.allowBlocking(ServiceManager.waitForDeclaredService(fqName)));
+ final IFingerprint fp = getIFingerprint(fqName);
if (fp != null) {
try {
return new FingerprintProvider(getContext(),
@@ -1129,6 +1130,24 @@ public class FingerprintService extends SystemService {
publishBinderService(Context.FINGERPRINT_SERVICE, mServiceWrapper);
}
+ /**
+ * Get all fingerprint hal instances declared in manifest
+ * @return instance names
+ */
+ public static String[] getDeclaredInstances() {
+ String[] a = ServiceManager.getDeclaredInstances(IFingerprint.DESCRIPTOR);
+ Slog.i(TAG, "Before:getDeclaredInstances: IFingerprint instance found, a.length="
+ + a.length);
+ if (!ArrayUtils.contains(a, "virtual")) {
+ // Now, the virtual hal is registered with IVirtualHal interface and it is also
+ // moved from vendor to system_ext partition without a device manifest. So
+ // if the old vhal is not declared, add here.
+ a = ArrayUtils.appendElement(String.class, a, "virtual");
+ }
+ Slog.i(TAG, "After:getDeclaredInstances: a.length=" + a.length);
+ return a;
+ }
+
@NonNull
private List<Fingerprint> getEnrolledFingerprintsDeprecated(int userId, String opPackageName) {
final Pair<Integer, ServiceProvider> provider = mRegistry.getSingleProvider();
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/BiometricTestSessionImpl.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/BiometricTestSessionImpl.java
index caa2c1c34ff7..fd3d9963c5e3 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/BiometricTestSessionImpl.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/BiometricTestSessionImpl.java
@@ -20,9 +20,9 @@ import android.annotation.NonNull;
import android.content.Context;
import android.hardware.biometrics.ITestSession;
import android.hardware.biometrics.ITestSessionCallback;
-import android.hardware.biometrics.fingerprint.AcquiredInfoAndVendorCode;
-import android.hardware.biometrics.fingerprint.EnrollmentProgressStep;
-import android.hardware.biometrics.fingerprint.NextEnrollment;
+import android.hardware.biometrics.fingerprint.virtualhal.AcquiredInfoAndVendorCode;
+import android.hardware.biometrics.fingerprint.virtualhal.EnrollmentProgressStep;
+import android.hardware.biometrics.fingerprint.virtualhal.NextEnrollment;
import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintEnrollOptions;
import android.hardware.fingerprint.FingerprintManager;
@@ -300,4 +300,4 @@ class BiometricTestSessionImpl extends ITestSession.Stub {
super.getSensorId_enforcePermission();
return mSensorId;
}
-} \ No newline at end of file
+}
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java
index 9edaa4e6d818..8195efe6a56a 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/FingerprintProvider.java
@@ -17,6 +17,8 @@
package com.android.server.biometrics.sensors.fingerprint.aidl;
import static android.hardware.fingerprint.FingerprintManager.SENSOR_ID_ANY;
+import static android.hardware.fingerprint.FingerprintSensorConfigurations.getIFingerprint;
+import static android.hardware.fingerprint.FingerprintSensorConfigurations.remapFqName;
import android.annotation.NonNull;
import android.annotation.Nullable;
@@ -34,9 +36,9 @@ import android.hardware.biometrics.ITestSession;
import android.hardware.biometrics.ITestSessionCallback;
import android.hardware.biometrics.SensorLocationInternal;
import android.hardware.biometrics.fingerprint.IFingerprint;
-import android.hardware.biometrics.fingerprint.IVirtualHal;
import android.hardware.biometrics.fingerprint.PointerContext;
import android.hardware.biometrics.fingerprint.SensorProps;
+import android.hardware.biometrics.fingerprint.virtualhal.IVirtualHal;
import android.hardware.fingerprint.Fingerprint;
import android.hardware.fingerprint.FingerprintAuthenticateOptions;
import android.hardware.fingerprint.FingerprintEnrollOptions;
@@ -291,7 +293,8 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
if (mTestHalEnabled) {
return true;
}
- return (ServiceManager.checkService(IFingerprint.DESCRIPTOR + "/" + mHalInstanceName)
+ return (ServiceManager.checkService(
+ remapFqName(IFingerprint.DESCRIPTOR + "/" + mHalInstanceName))
!= null);
}
@@ -330,10 +333,7 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
Slog.d(getTag(), "Daemon was null, reconnecting");
- mDaemon = IFingerprint.Stub.asInterface(
- Binder.allowBlocking(
- ServiceManager.waitForDeclaredService(
- IFingerprint.DESCRIPTOR + "/" + mHalInstanceNameCurrent)));
+ mDaemon = getIFingerprint(IFingerprint.DESCRIPTOR + "/" + mHalInstanceNameCurrent);
if (mDaemon == null) {
Slog.e(getTag(), "Unable to get daemon");
return null;
@@ -905,8 +905,8 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
void setTestHalEnabled(boolean enabled) {
final boolean changed = enabled != mTestHalEnabled;
mTestHalEnabled = enabled;
- Slog.i(getTag(), "setTestHalEnabled(): useVhalForTesting=" + Flags.useVhalForTesting()
- + "mTestHalEnabled=" + mTestHalEnabled + " changed=" + changed);
+ Slog.i(getTag(), "setTestHalEnabled(): useVhalForTestingFlags=" + Flags.useVhalForTesting()
+ + " mTestHalEnabled=" + mTestHalEnabled + " changed=" + changed);
if (changed && useVhalForTesting()) {
getHalInstance();
}
@@ -999,12 +999,13 @@ public class FingerprintProvider implements IBinder.DeathRecipient, ServiceProvi
*/
public IVirtualHal getVhal() throws RemoteException {
if (mVhal == null && useVhalForTesting()) {
- mVhal = IVirtualHal.Stub.asInterface(mDaemon.asBinder().getExtension());
- if (mVhal == null) {
- Slog.e(getTag(), "Unable to get fingerprint virtualhal interface");
- }
+ mVhal = IVirtualHal.Stub.asInterface(
+ Binder.allowBlocking(
+ ServiceManager.waitForService(
+ IVirtualHal.DESCRIPTOR + "/"
+ + mHalInstanceNameCurrent)));
+ Slog.d(getTag(), "getVhal " + mHalInstanceNameCurrent);
}
-
return mVhal;
}
diff --git a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/Sensor.java b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/Sensor.java
index d12d7b2dc89a..25d1fe7d32ba 100644
--- a/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/Sensor.java
+++ b/services/core/java/com/android/server/biometrics/sensors/fingerprint/aidl/Sensor.java
@@ -16,6 +16,8 @@
package com.android.server.biometrics.sensors.fingerprint.aidl;
+import static android.hardware.fingerprint.FingerprintSensorConfigurations.remapFqName;
+
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.content.Context;
@@ -356,8 +358,8 @@ public class Sensor {
if (mTestHalEnabled) {
return true;
}
- return (ServiceManager.checkService(IFingerprint.DESCRIPTOR + "/" + halInstance)
- != null);
+ return (ServiceManager.checkService(
+ remapFqName(IFingerprint.DESCRIPTOR + "/" + halInstance)) != null);
}
@NonNull protected BiometricContext getBiometricContext() {
diff --git a/services/core/java/com/android/server/broadcastradio/BroadcastRadioService.java b/services/core/java/com/android/server/broadcastradio/BroadcastRadioService.java
index 028b9b0bcbc0..fcbcb0262c95 100644
--- a/services/core/java/com/android/server/broadcastradio/BroadcastRadioService.java
+++ b/services/core/java/com/android/server/broadcastradio/BroadcastRadioService.java
@@ -32,8 +32,9 @@ public final class BroadcastRadioService extends SystemService {
public BroadcastRadioService(Context context) {
super(context);
ArrayList<String> serviceNameList = IRadioServiceAidlImpl.getServicesNames();
- mServiceImpl = serviceNameList.isEmpty() ? new IRadioServiceHidlImpl(this)
- : new IRadioServiceAidlImpl(this, serviceNameList);
+ RadioServiceUserController userController = new RadioServiceUserControllerImpl();
+ mServiceImpl = serviceNameList.isEmpty() ? new IRadioServiceHidlImpl(this, userController)
+ : new IRadioServiceAidlImpl(this, serviceNameList, userController);
}
@Override
diff --git a/services/core/java/com/android/server/broadcastradio/IRadioServiceAidlImpl.java b/services/core/java/com/android/server/broadcastradio/IRadioServiceAidlImpl.java
index 16514fa813dc..332958d39a8c 100644
--- a/services/core/java/com/android/server/broadcastradio/IRadioServiceAidlImpl.java
+++ b/services/core/java/com/android/server/broadcastradio/IRadioServiceAidlImpl.java
@@ -69,8 +69,9 @@ final class IRadioServiceAidlImpl extends IRadioService.Stub {
return serviceList;
}
- IRadioServiceAidlImpl(BroadcastRadioService service, ArrayList<String> serviceList) {
- this(service, new BroadcastRadioServiceImpl(serviceList));
+ IRadioServiceAidlImpl(BroadcastRadioService service, List<String> serviceList,
+ RadioServiceUserController userController) {
+ this(service, new BroadcastRadioServiceImpl(serviceList, userController));
Slogf.i(TAG, "Initialize BroadcastRadioServiceAidl(%s)", service);
}
diff --git a/services/core/java/com/android/server/broadcastradio/IRadioServiceHidlImpl.java b/services/core/java/com/android/server/broadcastradio/IRadioServiceHidlImpl.java
index ab083429a200..67d3c95f3a23 100644
--- a/services/core/java/com/android/server/broadcastradio/IRadioServiceHidlImpl.java
+++ b/services/core/java/com/android/server/broadcastradio/IRadioServiceHidlImpl.java
@@ -59,13 +59,16 @@ final class IRadioServiceHidlImpl extends IRadioService.Stub {
@GuardedBy("mLock")
private final List<RadioManager.ModuleProperties> mV1Modules;
- IRadioServiceHidlImpl(BroadcastRadioService service) {
+ IRadioServiceHidlImpl(BroadcastRadioService service,
+ RadioServiceUserController userController) {
mService = Objects.requireNonNull(service, "broadcast radio service cannot be null");
- mHal1Client = new com.android.server.broadcastradio.hal1.BroadcastRadioService();
+ Objects.requireNonNull(userController, "user controller cannot be null");
+ mHal1Client = new com.android.server.broadcastradio.hal1.BroadcastRadioService(
+ userController);
mV1Modules = mHal1Client.loadModules();
OptionalInt max = mV1Modules.stream().mapToInt(RadioManager.ModuleProperties::getId).max();
mHal2Client = new com.android.server.broadcastradio.hal2.BroadcastRadioService(
- max.isPresent() ? max.getAsInt() + 1 : 0);
+ max.isPresent() ? max.getAsInt() + 1 : 0, userController);
}
@VisibleForTesting
diff --git a/services/core/java/com/android/server/broadcastradio/RadioServiceUserController.java b/services/core/java/com/android/server/broadcastradio/RadioServiceUserController.java
index c705ebe686f2..c15ccf193563 100644
--- a/services/core/java/com/android/server/broadcastradio/RadioServiceUserController.java
+++ b/services/core/java/com/android/server/broadcastradio/RadioServiceUserController.java
@@ -16,19 +16,11 @@
package com.android.server.broadcastradio;
-import android.app.ActivityManager;
-import android.os.Binder;
-import android.os.UserHandle;
-
/**
- * Controller to handle users in {@link com.android.server.broadcastradio.BroadcastRadioService}
+ * Controller interface to handle users in
+ * {@link com.android.server.broadcastradio.BroadcastRadioService}
*/
-public final class RadioServiceUserController {
-
- private RadioServiceUserController() {
- throw new UnsupportedOperationException(
- "RadioServiceUserController class is noninstantiable");
- }
+public interface RadioServiceUserController {
/**
* Check if the user calling the method in Broadcast Radio Service is the current user or the
@@ -37,26 +29,20 @@ public final class RadioServiceUserController {
* @return {@code true} if the user calling this method is the current user of system user,
* {@code false} otherwise.
*/
- public static boolean isCurrentOrSystemUser() {
- int callingUser = Binder.getCallingUserHandle().getIdentifier();
- return callingUser == getCurrentUser() || callingUser == UserHandle.USER_SYSTEM;
- }
+ boolean isCurrentOrSystemUser();
/**
* Get current foreground user for Broadcast Radio Service
*
* @return foreground user id.
*/
- public static int getCurrentUser() {
- int userId = UserHandle.USER_NULL;
- final long identity = Binder.clearCallingIdentity();
- try {
- userId = ActivityManager.getCurrentUser();
- } catch (RuntimeException e) {
- // Activity manager not running, nothing we can do assume user 0.
- } finally {
- Binder.restoreCallingIdentity(identity);
- }
- return userId;
- }
-}
+ int getCurrentUser();
+
+ /**
+ * Get id of the user handle assigned to the process that sent the binder transaction that is
+ * being processed
+ *
+ * @return Id of the user handle
+ */
+ int getCallingUserId();
+} \ No newline at end of file
diff --git a/services/core/java/com/android/server/broadcastradio/RadioServiceUserControllerImpl.java b/services/core/java/com/android/server/broadcastradio/RadioServiceUserControllerImpl.java
new file mode 100644
index 000000000000..e305d208000c
--- /dev/null
+++ b/services/core/java/com/android/server/broadcastradio/RadioServiceUserControllerImpl.java
@@ -0,0 +1,62 @@
+/**
+ * Copyright (C) 2024 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.server.broadcastradio;
+
+import android.app.ActivityManager;
+import android.os.Binder;
+import android.os.UserHandle;
+
+/**
+ * Implementation for the controller to handle users in
+ * {@link com.android.server.broadcastradio.BroadcastRadioService}
+ */
+public final class RadioServiceUserControllerImpl implements RadioServiceUserController {
+
+ /**
+ * @see RadioServiceUserController#isCurrentOrSystemUser()
+ */
+ @Override
+ public boolean isCurrentOrSystemUser() {
+ int callingUser = getCallingUserId();
+ return callingUser == getCurrentUser() || callingUser == UserHandle.USER_SYSTEM;
+ }
+
+ /**
+ * @see RadioServiceUserController#getCurrentUser()
+ */
+ @Override
+ public int getCurrentUser() {
+ int userId = UserHandle.USER_NULL;
+ final long identity = Binder.clearCallingIdentity();
+ try {
+ userId = ActivityManager.getCurrentUser();
+ } catch (RuntimeException e) {
+ // Activity manager not running, nothing we can do assume user 0.
+ } finally {
+ Binder.restoreCallingIdentity(identity);
+ }
+ return userId;
+ }
+
+ /**
+ * @see RadioServiceUserController#getCallingUserId()
+ */
+ @Override
+ public int getCallingUserId() {
+ return Binder.getCallingUserHandle().getIdentifier();
+ }
+}
diff --git a/services/core/java/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImpl.java b/services/core/java/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImpl.java
index 7b504659c197..06024b57e45f 100644
--- a/services/core/java/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImpl.java
+++ b/services/core/java/com/android/server/broadcastradio/aidl/BroadcastRadioServiceImpl.java
@@ -51,6 +51,7 @@ public final class BroadcastRadioServiceImpl {
private static final boolean DEBUG = Log.isLoggable(TAG, Log.DEBUG);
private final Object mLock = new Object();
+ private final RadioServiceUserController mUserController;
@GuardedBy("mLock")
private int mNextModuleId;
@@ -77,7 +78,7 @@ public final class BroadcastRadioServiceImpl {
}
RadioModule radioModule =
- RadioModule.tryLoadingModule(moduleId, name, newBinder);
+ RadioModule.tryLoadingModule(moduleId, name, newBinder, mUserController);
if (radioModule == null) {
Slogf.w(TAG, "No module %s with id %d (HAL AIDL)", name, moduleId);
return;
@@ -141,9 +142,12 @@ public final class BroadcastRadioServiceImpl {
* BroadcastRadio HAL services
*
* @param serviceNameList list of names of AIDL BroadcastRadio HAL services
+ * @param userController User controller implementation
*/
- public BroadcastRadioServiceImpl(ArrayList<String> serviceNameList) {
+ public BroadcastRadioServiceImpl(List<String> serviceNameList,
+ RadioServiceUserController userController) {
mNextModuleId = 0;
+ mUserController = Objects.requireNonNull(userController, "User controller can not be null");
if (DEBUG) {
Slogf.d(TAG, "Initializing BroadcastRadioServiceImpl %s", IBroadcastRadio.DESCRIPTOR);
}
@@ -202,7 +206,7 @@ public final class BroadcastRadioServiceImpl {
if (DEBUG) {
Slogf.d(TAG, "Open AIDL radio session");
}
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.e(TAG, "Cannot open tuner on AIDL HAL client for non-current user");
throw new IllegalStateException("Cannot open session for non-current user");
}
diff --git a/services/core/java/com/android/server/broadcastradio/aidl/RadioModule.java b/services/core/java/com/android/server/broadcastradio/aidl/RadioModule.java
index a176a3275ee9..20ee49e25dc2 100644
--- a/services/core/java/com/android/server/broadcastradio/aidl/RadioModule.java
+++ b/services/core/java/com/android/server/broadcastradio/aidl/RadioModule.java
@@ -62,6 +62,7 @@ final class RadioModule {
private final Handler mHandler;
private final RadioEventLogger mLogger;
private final RadioManager.ModuleProperties mProperties;
+ private final RadioServiceUserController mUserController;
/**
* Tracks antenna state reported by HAL (if any).
@@ -194,15 +195,18 @@ final class RadioModule {
};
@VisibleForTesting
- RadioModule(IBroadcastRadio service, RadioManager.ModuleProperties properties) {
+ RadioModule(IBroadcastRadio service, RadioManager.ModuleProperties properties,
+ RadioServiceUserController userController) {
mProperties = Objects.requireNonNull(properties, "properties cannot be null");
mService = Objects.requireNonNull(service, "service cannot be null");
mHandler = new Handler(Looper.getMainLooper());
+ mUserController = Objects.requireNonNull(userController, "User controller can not be null");
mLogger = new RadioEventLogger(TAG, RADIO_EVENT_LOGGER_QUEUE_SIZE);
}
@Nullable
- static RadioModule tryLoadingModule(int moduleId, String moduleName, IBinder serviceBinder) {
+ static RadioModule tryLoadingModule(int moduleId, String moduleName, IBinder serviceBinder,
+ RadioServiceUserController userController) {
try {
Slogf.i(TAG, "Try loading module for module id = %d, module name = %s",
moduleId, moduleName);
@@ -232,7 +236,7 @@ final class RadioModule {
RadioManager.ModuleProperties prop = ConversionUtils.propertiesFromHalProperties(
moduleId, moduleName, service.getProperties(), amfmConfig, dabConfig);
- return new RadioModule(service, prop);
+ return new RadioModule(service, prop, userController);
} catch (RemoteException ex) {
Slogf.e(TAG, ex, "Failed to load module %s", moduleName);
return null;
@@ -256,7 +260,7 @@ final class RadioModule {
RadioManager.ProgramInfo currentProgramInfo;
synchronized (mLock) {
boolean isFirstTunerSession = mAidlTunerSessions.isEmpty();
- tunerSession = new TunerSession(this, mService, userCb);
+ tunerSession = new TunerSession(this, mService, userCb, mUserController);
mAidlTunerSessions.add(tunerSession);
antennaConnected = mAntennaConnected;
currentProgramInfo = mCurrentProgramInfo;
@@ -440,7 +444,7 @@ final class RadioModule {
@GuardedBy("mLock")
private void fanoutAidlCallbackLocked(AidlCallbackRunnable runnable) {
- int currentUserId = RadioServiceUserController.getCurrentUser();
+ int currentUserId = mUserController.getCurrentUser();
List<TunerSession> deadSessions = null;
for (int i = 0; i < mAidlTunerSessions.size(); i++) {
if (mAidlTunerSessions.valueAt(i).mUserId != currentUserId
diff --git a/services/core/java/com/android/server/broadcastradio/aidl/TunerSession.java b/services/core/java/com/android/server/broadcastradio/aidl/TunerSession.java
index e90a1dda6cf5..f22661b72da1 100644
--- a/services/core/java/com/android/server/broadcastradio/aidl/TunerSession.java
+++ b/services/core/java/com/android/server/broadcastradio/aidl/TunerSession.java
@@ -52,6 +52,7 @@ final class TunerSession extends ITuner.Stub {
final android.hardware.radio.ITunerCallback mCallback;
private final int mUid;
private final IBroadcastRadio mService;
+ private final RadioServiceUserController mUserController;
@GuardedBy("mLock")
private boolean mIsClosed;
@@ -65,11 +66,13 @@ final class TunerSession extends ITuner.Stub {
private RadioManager.BandConfig mPlaceHolderConfig;
TunerSession(RadioModule radioModule, IBroadcastRadio service,
- android.hardware.radio.ITunerCallback callback) {
+ android.hardware.radio.ITunerCallback callback,
+ RadioServiceUserController userController) {
mModule = Objects.requireNonNull(radioModule, "radioModule cannot be null");
mService = Objects.requireNonNull(service, "service cannot be null");
- mUserId = Binder.getCallingUserHandle().getIdentifier();
mCallback = Objects.requireNonNull(callback, "callback cannot be null");
+ mUserController = Objects.requireNonNull(userController, "User controller can not be null");
+ mUserId = mUserController.getCallingUserId();
mUid = Binder.getCallingUid();
mLogger = new RadioEventLogger(TAG, TUNER_EVENT_LOGGER_QUEUE_SIZE);
}
@@ -126,7 +129,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void setConfiguration(RadioManager.BandConfig config) {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot set configuration for AIDL HAL client from non-current user");
return;
}
@@ -169,7 +172,7 @@ final class TunerSession extends ITuner.Stub {
public void step(boolean directionDown, boolean skipSubChannel) throws RemoteException {
mLogger.logRadioEvent("Step with direction %s, skipSubChannel? %s",
directionDown ? "down" : "up", skipSubChannel ? "yes" : "no");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot step on AIDL HAL client from non-current user");
return;
}
@@ -187,7 +190,7 @@ final class TunerSession extends ITuner.Stub {
public void seek(boolean directionDown, boolean skipSubChannel) throws RemoteException {
mLogger.logRadioEvent("Seek with direction %s, skipSubChannel? %s",
directionDown ? "down" : "up", skipSubChannel ? "yes" : "no");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot scan on AIDL HAL client from non-current user");
return;
}
@@ -204,7 +207,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void tune(ProgramSelector selector) throws RemoteException {
mLogger.logRadioEvent("Tune with selector %s", selector);
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot tune on AIDL HAL client from non-current user");
return;
}
@@ -226,7 +229,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void cancel() {
Slogf.i(TAG, "Cancel");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot cancel on AIDL HAL client from non-current user");
return;
}
@@ -255,7 +258,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public boolean startBackgroundScan() {
Slogf.w(TAG, "Explicit background scan trigger is not supported with HAL AIDL");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot start background scan on AIDL HAL client from non-current user");
return false;
}
@@ -268,7 +271,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void startProgramListUpdates(ProgramList.Filter filter) throws RemoteException {
mLogger.logRadioEvent("Start programList updates %s", filter);
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG,
"Cannot start program list updates on AIDL HAL client from non-current user");
return;
@@ -344,7 +347,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void stopProgramListUpdates() throws RemoteException {
mLogger.logRadioEvent("Stop programList updates");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG,
"Cannot stop program list updates on AIDL HAL client from non-current user");
return;
@@ -389,7 +392,7 @@ final class TunerSession extends ITuner.Stub {
public void setConfigFlag(int flag, boolean value) throws RemoteException {
mLogger.logRadioEvent("set ConfigFlag %s to %b ",
ConfigFlag.$.toString(flag), value);
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot set config flag for AIDL HAL client from non-current user");
return;
}
@@ -406,7 +409,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public Map<String, String> setParameters(Map<String, String> parameters) {
mLogger.logRadioEvent("Set parameters ");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot set parameters for AIDL HAL client from non-current user");
return new ArrayMap<>();
}
diff --git a/services/core/java/com/android/server/broadcastradio/hal1/BroadcastRadioService.java b/services/core/java/com/android/server/broadcastradio/hal1/BroadcastRadioService.java
index fb42c94b56f4..6a6a3ae44c8b 100644
--- a/services/core/java/com/android/server/broadcastradio/hal1/BroadcastRadioService.java
+++ b/services/core/java/com/android/server/broadcastradio/hal1/BroadcastRadioService.java
@@ -35,6 +35,7 @@ public class BroadcastRadioService {
* This field is used by native code, do not access or modify.
*/
private final long mNativeContext = nativeInit();
+ private final RadioServiceUserController mUserController;
private final Object mLock = new Object();
@@ -50,6 +51,10 @@ public class BroadcastRadioService {
private native Tuner nativeOpenTuner(long nativeContext, int moduleId,
RadioManager.BandConfig config, boolean withAudio, ITunerCallback callback);
+ public BroadcastRadioService(RadioServiceUserController userController) {
+ mUserController = Objects.requireNonNull(userController, "User controller can not be null");
+ }
+
public @NonNull List<RadioManager.ModuleProperties> loadModules() {
synchronized (mLock) {
return Objects.requireNonNull(nativeLoadModules(mNativeContext));
@@ -58,7 +63,7 @@ public class BroadcastRadioService {
public ITuner openTuner(int moduleId, RadioManager.BandConfig bandConfig,
boolean withAudio, ITunerCallback callback) {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.e(TAG, "Cannot open tuner on HAL 1.x client for non-current user");
throw new IllegalStateException("Cannot open tuner for non-current user");
}
diff --git a/services/core/java/com/android/server/broadcastradio/hal1/Tuner.java b/services/core/java/com/android/server/broadcastradio/hal1/Tuner.java
index 7cac4091c583..8e64600d2694 100644
--- a/services/core/java/com/android/server/broadcastradio/hal1/Tuner.java
+++ b/services/core/java/com/android/server/broadcastradio/hal1/Tuner.java
@@ -28,6 +28,7 @@ import android.os.IBinder;
import android.os.RemoteException;
import com.android.server.broadcastradio.RadioServiceUserController;
+import com.android.server.broadcastradio.RadioServiceUserControllerImpl;
import com.android.server.utils.Slogf;
import java.util.List;
@@ -51,6 +52,7 @@ class Tuner extends ITuner.Stub {
private boolean mIsMuted = false;
private int mRegion;
private final boolean mWithAudio;
+ private final RadioServiceUserController mUserController = new RadioServiceUserControllerImpl();
Tuner(@NonNull ITunerCallback clientCallback, int halRev,
int region, boolean withAudio, int band) {
@@ -127,7 +129,7 @@ class Tuner extends ITuner.Stub {
@Override
public void setConfiguration(RadioManager.BandConfig config) {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot set configuration for HAL 1.x client from non-current user");
return;
}
@@ -176,7 +178,7 @@ class Tuner extends ITuner.Stub {
@Override
public void step(boolean directionDown, boolean skipSubChannel) {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot step on HAL 1.x client from non-current user");
return;
}
@@ -189,7 +191,7 @@ class Tuner extends ITuner.Stub {
@Override
public void seek(boolean directionDown, boolean skipSubChannel) {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot seek on HAL 1.x client from non-current user");
return;
}
@@ -202,7 +204,7 @@ class Tuner extends ITuner.Stub {
@Override
public void tune(ProgramSelector selector) {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot tune on HAL 1.x client from non-current user");
return;
}
@@ -219,7 +221,7 @@ class Tuner extends ITuner.Stub {
@Override
public void cancel() {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot cancel on HAL 1.x client from non-current user");
return;
}
@@ -231,7 +233,7 @@ class Tuner extends ITuner.Stub {
@Override
public void cancelAnnouncement() {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot cancel announcement on HAL 1.x client from non-current user");
return;
}
@@ -260,7 +262,7 @@ class Tuner extends ITuner.Stub {
@Override
public boolean startBackgroundScan() {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG,
"Cannot start background scan on HAL 1.x client from non-current user");
return false;
@@ -285,7 +287,7 @@ class Tuner extends ITuner.Stub {
@Override
public void startProgramListUpdates(ProgramList.Filter filter) {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG,
"Cannot start program list updates on HAL 1.x client from non-current user");
return;
@@ -295,7 +297,7 @@ class Tuner extends ITuner.Stub {
@Override
public void stopProgramListUpdates() {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG,
"Cannot stop program list updates on HAL 1.x client from non-current user");
return;
@@ -321,7 +323,7 @@ class Tuner extends ITuner.Stub {
@Override
public void setConfigFlag(int flag, boolean value) {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot set config flag for HAL 1.x client from non-current user");
return;
}
diff --git a/services/core/java/com/android/server/broadcastradio/hal2/BroadcastRadioService.java b/services/core/java/com/android/server/broadcastradio/hal2/BroadcastRadioService.java
index a4efa2e330f8..3227afd82dbd 100644
--- a/services/core/java/com/android/server/broadcastradio/hal2/BroadcastRadioService.java
+++ b/services/core/java/com/android/server/broadcastradio/hal2/BroadcastRadioService.java
@@ -50,6 +50,8 @@ public final class BroadcastRadioService {
private final Object mLock = new Object();
+ private final RadioServiceUserController mUserController;
+
@GuardedBy("mLock")
private int mNextModuleId;
@@ -75,7 +77,8 @@ public final class BroadcastRadioService {
moduleId = mNextModuleId;
}
- RadioModule radioModule = RadioModule.tryLoadingModule(moduleId, serviceName);
+ RadioModule radioModule = RadioModule.tryLoadingModule(moduleId, serviceName,
+ mUserController);
if (radioModule == null) {
return;
}
@@ -123,8 +126,9 @@ public final class BroadcastRadioService {
}
};
- public BroadcastRadioService(int nextModuleId) {
+ public BroadcastRadioService(int nextModuleId, RadioServiceUserController userController) {
mNextModuleId = nextModuleId;
+ mUserController = Objects.requireNonNull(userController, "User controller can not be null");
try {
IServiceManager manager = IServiceManager.getService();
if (manager == null) {
@@ -138,8 +142,10 @@ public final class BroadcastRadioService {
}
@VisibleForTesting
- BroadcastRadioService(int nextModuleId, IServiceManager manager) {
+ BroadcastRadioService(int nextModuleId, IServiceManager manager,
+ RadioServiceUserController userController) {
mNextModuleId = nextModuleId;
+ mUserController = Objects.requireNonNull(userController, "User controller can not be null");
Objects.requireNonNull(manager, "Service manager cannot be null");
try {
manager.registerForNotifications(IBroadcastRadio.kInterfaceName, "", mServiceListener);
@@ -171,7 +177,7 @@ public final class BroadcastRadioService {
public ITuner openSession(int moduleId, @Nullable RadioManager.BandConfig legacyConfig,
boolean withAudio, @NonNull ITunerCallback callback) throws RemoteException {
Slogf.v(TAG, "Open HIDL 2.0 session with module id " + moduleId);
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.e(TAG, "Cannot open tuner on HAL 2.0 client for non-current user");
throw new IllegalStateException("Cannot open session for non-current user");
}
diff --git a/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java b/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java
index d3b244886a64..a0d6cc2c75b0 100644
--- a/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java
+++ b/services/core/java/com/android/server/broadcastradio/hal2/RadioModule.java
@@ -66,6 +66,7 @@ final class RadioModule {
private final Object mLock = new Object();
private final Handler mHandler;
private final RadioEventLogger mEventLogger;
+ private final RadioServiceUserController mUserController;
@GuardedBy("mLock")
private ITunerSession mHalTunerSession;
@@ -148,16 +149,18 @@ final class RadioModule {
private final Set<TunerSession> mAidlTunerSessions = new ArraySet<>();
@VisibleForTesting
- RadioModule(@NonNull IBroadcastRadio service,
- @NonNull RadioManager.ModuleProperties properties) {
+ RadioModule(IBroadcastRadio service, RadioManager.ModuleProperties properties,
+ RadioServiceUserController userController) {
mProperties = Objects.requireNonNull(properties);
mService = Objects.requireNonNull(service);
mHandler = new Handler(Looper.getMainLooper());
+ mUserController = Objects.requireNonNull(userController, "User controller can not be null");
mEventLogger = new RadioEventLogger(TAG, RADIO_EVENT_LOGGER_QUEUE_SIZE);
}
@Nullable
- static RadioModule tryLoadingModule(int idx, @NonNull String fqName) {
+ static RadioModule tryLoadingModule(int idx, String fqName,
+ RadioServiceUserController controller) {
try {
Slogf.i(TAG, "Try loading module for idx " + idx + ", fqName " + fqName);
IBroadcastRadio service = IBroadcastRadio.getService(fqName);
@@ -179,7 +182,7 @@ final class RadioModule {
RadioManager.ModuleProperties prop = Convert.propertiesFromHal(idx, fqName,
service.getProperties(), amfmConfig.value, dabConfig.value);
- return new RadioModule(service, prop);
+ return new RadioModule(service, prop, controller);
} catch (RemoteException ex) {
Slogf.e(TAG, "Failed to load module " + fqName, ex);
return null;
@@ -208,7 +211,8 @@ final class RadioModule {
});
mHalTunerSession = Objects.requireNonNull(hwSession.value);
}
- TunerSession tunerSession = new TunerSession(this, mHalTunerSession, userCb);
+ TunerSession tunerSession = new TunerSession(this, mHalTunerSession, userCb,
+ mUserController);
mAidlTunerSessions.add(tunerSession);
// Propagate state to new client. Note: These callbacks are invoked while holding mLock
@@ -375,7 +379,7 @@ final class RadioModule {
@GuardedBy("mLock")
private void fanoutAidlCallbackLocked(AidlCallbackRunnable runnable) {
- int currentUserId = RadioServiceUserController.getCurrentUser();
+ int currentUserId = mUserController.getCurrentUser();
List<TunerSession> deadSessions = null;
for (TunerSession tunerSession : mAidlTunerSessions) {
if (tunerSession.mUserId != currentUserId && tunerSession.mUserId
diff --git a/services/core/java/com/android/server/broadcastradio/hal2/TunerSession.java b/services/core/java/com/android/server/broadcastradio/hal2/TunerSession.java
index 80efacdb12ee..dc164b1e6eff 100644
--- a/services/core/java/com/android/server/broadcastradio/hal2/TunerSession.java
+++ b/services/core/java/com/android/server/broadcastradio/hal2/TunerSession.java
@@ -16,7 +16,6 @@
package com.android.server.broadcastradio.hal2;
-import android.annotation.NonNull;
import android.annotation.Nullable;
import android.graphics.Bitmap;
import android.hardware.broadcastradio.V2_0.ConfigFlag;
@@ -27,7 +26,6 @@ import android.hardware.radio.ITuner;
import android.hardware.radio.ProgramList;
import android.hardware.radio.ProgramSelector;
import android.hardware.radio.RadioManager;
-import android.os.Binder;
import android.os.RemoteException;
import android.util.ArrayMap;
import android.util.ArraySet;
@@ -55,6 +53,7 @@ final class TunerSession extends ITuner.Stub {
private final ITunerSession mHwSession;
final int mUserId;
final android.hardware.radio.ITunerCallback mCallback;
+ private final RadioServiceUserController mUserController;
@GuardedBy("mLock")
private boolean mIsClosed = false;
@@ -66,12 +65,14 @@ final class TunerSession extends ITuner.Stub {
// necessary only for older APIs compatibility
private RadioManager.BandConfig mDummyConfig = null;
- TunerSession(@NonNull RadioModule module, @NonNull ITunerSession hwSession,
- @NonNull android.hardware.radio.ITunerCallback callback) {
+ TunerSession(RadioModule module, ITunerSession hwSession,
+ android.hardware.radio.ITunerCallback callback,
+ RadioServiceUserController userController) {
mModule = Objects.requireNonNull(module);
mHwSession = Objects.requireNonNull(hwSession);
- mUserId = Binder.getCallingUserHandle().getIdentifier();
mCallback = Objects.requireNonNull(callback);
+ mUserController = Objects.requireNonNull(userController, "User controller can not be null");
+ mUserId = mUserController.getCallingUserId();
mEventLogger = new RadioEventLogger(TAG, TUNER_EVENT_LOGGER_QUEUE_SIZE);
}
@@ -120,7 +121,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void setConfiguration(RadioManager.BandConfig config) {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot set configuration for HAL 2.0 client from non-current user");
return;
}
@@ -162,7 +163,7 @@ final class TunerSession extends ITuner.Stub {
public void step(boolean directionDown, boolean skipSubChannel) throws RemoteException {
mEventLogger.logRadioEvent("Step with direction %s, skipSubChannel? %s",
directionDown ? "down" : "up", skipSubChannel ? "yes" : "no");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot step on HAL 2.0 client from non-current user");
return;
}
@@ -177,7 +178,7 @@ final class TunerSession extends ITuner.Stub {
public void seek(boolean directionDown, boolean skipSubChannel) throws RemoteException {
mEventLogger.logRadioEvent("Seek with direction %s, skipSubChannel? %s",
directionDown ? "down" : "up", skipSubChannel ? "yes" : "no");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot scan on HAL 2.0 client from non-current user");
return;
}
@@ -191,7 +192,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void tune(ProgramSelector selector) throws RemoteException {
mEventLogger.logRadioEvent("Tune with selector %s", selector);
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot tune on HAL 2.0 client from non-current user");
return;
}
@@ -205,7 +206,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void cancel() {
Slogf.i(TAG, "Cancel");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot cancel on HAL 2.0 client from non-current user");
return;
}
@@ -230,7 +231,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public boolean startBackgroundScan() {
Slogf.w(TAG, "Explicit background scan trigger is not supported with HAL 2.0");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG,
"Cannot start background scan on HAL 2.0 client from non-current user");
return false;
@@ -242,7 +243,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void startProgramListUpdates(ProgramList.Filter filter) {
mEventLogger.logRadioEvent("start programList updates %s", filter);
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG,
"Cannot start program list updates on HAL 2.0 client from non-current user");
return;
@@ -306,7 +307,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void stopProgramListUpdates() throws RemoteException {
mEventLogger.logRadioEvent("Stop programList updates");
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG,
"Cannot stop program list updates on HAL 2.0 client from non-current user");
return;
@@ -355,7 +356,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public void setConfigFlag(int flag, boolean value) throws RemoteException {
mEventLogger.logRadioEvent("Set ConfigFlag %s = %b", ConfigFlag.toString(flag), value);
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot set config flag for HAL 2.0 client from non-current user");
return;
}
@@ -368,7 +369,7 @@ final class TunerSession extends ITuner.Stub {
@Override
public Map<String, String> setParameters(Map<String, String> parameters) {
- if (!RadioServiceUserController.isCurrentOrSystemUser()) {
+ if (!mUserController.isCurrentOrSystemUser()) {
Slogf.w(TAG, "Cannot set parameters for HAL 2.0 client from non-current user");
return new ArrayMap<>();
}
diff --git a/services/core/java/com/android/server/camera/CameraServiceProxy.java b/services/core/java/com/android/server/camera/CameraServiceProxy.java
index 17835b2d085b..05fc6bc869ca 100644
--- a/services/core/java/com/android/server/camera/CameraServiceProxy.java
+++ b/services/core/java/com/android/server/camera/CameraServiceProxy.java
@@ -379,12 +379,8 @@ public class CameraServiceProxy extends SystemService
streamCount = mStreamStats.size();
}
if (CameraServiceProxy.DEBUG) {
- String ultrawideDebug = Flags.logUltrawideUsage()
- ? ", wideAngleUsage " + mUsedUltraWide
- : "";
- String zoomOverrideDebug = Flags.logZoomOverrideUsage()
- ? ", zoomOverrideUsage " + mUsedZoomOverride
- : "";
+ String ultrawideDebug = ", wideAngleUsage " + mUsedUltraWide;
+ String zoomOverrideDebug = ", zoomOverrideUsage " + mUsedZoomOverride;
String mostRequestedFpsRangeDebug = Flags.analytics24q3()
? ", mostRequestedFpsRange " + mMostRequestedFpsRange
: "";
@@ -1338,9 +1334,8 @@ public class CameraServiceProxy extends SystemService
List<CameraStreamStats> streamStats = cameraState.getStreamStats();
String userTag = cameraState.getUserTag();
int videoStabilizationMode = cameraState.getVideoStabilizationMode();
- boolean usedUltraWide = Flags.logUltrawideUsage() ? cameraState.getUsedUltraWide() : false;
- boolean usedZoomOverride =
- Flags.logZoomOverrideUsage() ? cameraState.getUsedZoomOverride() : false;
+ boolean usedUltraWide = cameraState.getUsedUltraWide();
+ boolean usedZoomOverride = cameraState.getUsedZoomOverride();
long logId = cameraState.getLogId();
int sessionIdx = cameraState.getSessionIndex();
CameraExtensionSessionStats extSessionStats = cameraState.getExtensionSessionStats();
diff --git a/services/core/java/com/android/server/display/BrightnessRangeController.java b/services/core/java/com/android/server/display/BrightnessRangeController.java
index 8a3e39257145..1d68ee54d96c 100644
--- a/services/core/java/com/android/server/display/BrightnessRangeController.java
+++ b/services/core/java/com/android/server/display/BrightnessRangeController.java
@@ -16,6 +16,7 @@
package com.android.server.display;
+import android.annotation.Nullable;
import android.hardware.display.BrightnessInfo;
import android.os.Handler;
import android.os.IBinder;
@@ -92,7 +93,7 @@ class BrightnessRangeController {
return mHbmController.getNormalBrightnessMax();
}
- void loadFromConfig(HighBrightnessModeMetadata hbmMetadata, IBinder token,
+ void loadFromConfig(@Nullable HighBrightnessModeMetadata hbmMetadata, IBinder token,
DisplayDeviceInfo info, DisplayDeviceConfig displayDeviceConfig) {
applyChanges(
() -> mNormalBrightnessModeController.resetNbmData(
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index ed16b1472ee5..9644b1dbb977 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -2170,9 +2170,7 @@ public final class DisplayManagerService extends SystemService {
HighBrightnessModeMetadata hbmMetadata =
mHighBrightnessModeMetadataMapper.getHighBrightnessModeMetadataLocked(display);
- if (hbmMetadata != null) {
- dpc.onDisplayChanged(hbmMetadata, leadDisplayId);
- }
+ dpc.onDisplayChanged(hbmMetadata, leadDisplayId);
}
}
@@ -2291,9 +2289,7 @@ public final class DisplayManagerService extends SystemService {
HighBrightnessModeMetadata hbmMetadata =
mHighBrightnessModeMetadataMapper.getHighBrightnessModeMetadataLocked(display);
- if (hbmMetadata != null) {
- dpc.onDisplayChanged(hbmMetadata, leadDisplayId);
- }
+ dpc.onDisplayChanged(hbmMetadata, leadDisplayId);
}
}
@@ -3560,6 +3556,18 @@ public final class DisplayManagerService extends SystemService {
DisplayManagerFlags getFlags() {
return new DisplayManagerFlags();
}
+
+ DisplayPowerController getDisplayPowerController(Context context,
+ DisplayPowerController.Injector injector,
+ DisplayManagerInternal.DisplayPowerCallbacks callbacks, Handler handler,
+ SensorManager sensorManager, DisplayBlanker blanker, LogicalDisplay logicalDisplay,
+ BrightnessTracker brightnessTracker, BrightnessSetting brightnessSetting,
+ Runnable onBrightnessChangeRunnable, HighBrightnessModeMetadata hbmMetadata,
+ boolean bootCompleted, DisplayManagerFlags flags) {
+ return new DisplayPowerController(context, injector, callbacks, handler, sensorManager,
+ blanker, logicalDisplay, brightnessTracker, brightnessSetting,
+ onBrightnessChangeRunnable, hbmMetadata, bootCompleted, flags);
+ }
}
@VisibleForTesting
@@ -3612,7 +3620,7 @@ public final class DisplayManagerService extends SystemService {
// with the corresponding displaydevice.
HighBrightnessModeMetadata hbmMetadata =
mHighBrightnessModeMetadataMapper.getHighBrightnessModeMetadataLocked(display);
- displayPowerController = new DisplayPowerController(
+ displayPowerController = mInjector.getDisplayPowerController(
mContext, /* injector= */ null, mDisplayPowerCallbacks, mPowerHandler,
mSensorManager, mDisplayBlanker, display, mBrightnessTracker, brightnessSetting,
() -> handleBrightnessChange(display), hbmMetadata, mBootCompleted, mFlags);
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index 7c591e3a2c03..c3faec007552 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -849,7 +849,8 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
*
* Make sure DisplayManagerService.mSyncRoot lock is held when this is called
*/
- public void onDisplayChanged(HighBrightnessModeMetadata hbmMetadata, int leadDisplayId) {
+ public void onDisplayChanged(@Nullable HighBrightnessModeMetadata hbmMetadata,
+ int leadDisplayId) {
mLeadDisplayId = leadDisplayId;
final DisplayDevice device = mLogicalDisplay.getPrimaryDisplayDeviceLocked();
if (device == null) {
@@ -949,7 +950,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
}
private void loadFromDisplayDeviceConfig(IBinder token, DisplayDeviceInfo info,
- HighBrightnessModeMetadata hbmMetadata) {
+ @Nullable HighBrightnessModeMetadata hbmMetadata) {
// All properties that depend on the associated DisplayDevice and the DDC must be
// updated here.
mScreenBrightnessDozeConfig = BrightnessUtils.clampAbsoluteBrightness(
diff --git a/services/core/java/com/android/server/display/HighBrightnessModeController.java b/services/core/java/com/android/server/display/HighBrightnessModeController.java
index da9eef2d7459..135cab6d0614 100644
--- a/services/core/java/com/android/server/display/HighBrightnessModeController.java
+++ b/services/core/java/com/android/server/display/HighBrightnessModeController.java
@@ -266,7 +266,7 @@ class HighBrightnessModeController {
mSettingsObserver.stopObserving();
}
- void setHighBrightnessModeMetadata(HighBrightnessModeMetadata hbmInfo) {
+ void setHighBrightnessModeMetadata(@Nullable HighBrightnessModeMetadata hbmInfo) {
mHighBrightnessModeMetadata = hbmInfo;
}
diff --git a/services/core/java/com/android/server/flags/services.aconfig b/services/core/java/com/android/server/flags/services.aconfig
index 649678c13a00..69ba785b3b4f 100644
--- a/services/core/java/com/android/server/flags/services.aconfig
+++ b/services/core/java/com/android/server/flags/services.aconfig
@@ -56,3 +56,14 @@ flag {
purpose: PURPOSE_BUGFIX
}
}
+
+flag {
+ namespace: "backstage_power"
+ name: "trace_battery_changed_broadcast_event"
+ description: "Add tracing to record battery changed broadcast event"
+ bug: "365410144"
+ is_fixed_read_only: true
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
diff --git a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java
index 81204ef5d7ed..a8d5696e8c77 100644
--- a/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java
+++ b/services/core/java/com/android/server/hdmi/HdmiCecLocalDevice.java
@@ -927,12 +927,14 @@ abstract class HdmiCecLocalDevice extends HdmiLocalDevice {
protected int handleVendorCommandWithId(HdmiCecMessage message) {
byte[] params = message.getParams();
int vendorId = HdmiUtils.threeBytesToInt(params);
- if (message.getDestination() == Constants.ADDR_BROADCAST
- || message.getSource() == Constants.ADDR_UNREGISTERED) {
- Slog.v(TAG, "Wrong broadcast vendor command. Ignoring");
- } else if (!mService.invokeVendorCommandListenersOnReceived(
+ if (!mService.invokeVendorCommandListenersOnReceived(
mDeviceType, message.getSource(), message.getDestination(), params, true)) {
- return Constants.ABORT_REFUSED;
+ if (message.getDestination() == Constants.ADDR_BROADCAST
+ || message.getSource() == Constants.ADDR_UNREGISTERED) {
+ Slog.v(TAG, "Broadcast vendor command with no listeners. Ignoring");
+ } else {
+ return Constants.ABORT_REFUSED;
+ }
}
return Constants.HANDLED;
}
diff --git a/services/core/java/com/android/server/input/InputManagerService.java b/services/core/java/com/android/server/input/InputManagerService.java
index 1285a61d08f2..dfcea9f8e46f 100644
--- a/services/core/java/com/android/server/input/InputManagerService.java
+++ b/services/core/java/com/android/server/input/InputManagerService.java
@@ -2269,14 +2269,8 @@ public class InputManagerService extends IInputManager.Stub
// Native callback.
@SuppressWarnings("unused")
private void notifyTouchpadHardwareState(TouchpadHardwareState hardwareStates, int deviceId) {
- Slog.d(TAG, "notifyTouchpadHardwareState: Time: "
- + hardwareStates.getTimestamp() + ", No. Buttons: "
- + hardwareStates.getButtonsDown() + ", No. Fingers: "
- + hardwareStates.getFingerCount() + ", No. Touch: "
- + hardwareStates.getTouchCount() + ", Id: "
- + deviceId);
if (mTouchpadDebugViewController != null) {
- mTouchpadDebugViewController.updateTouchpadHardwareState(hardwareStates);
+ mTouchpadDebugViewController.updateTouchpadHardwareState(hardwareStates, deviceId);
}
}
diff --git a/services/core/java/com/android/server/input/debug/TouchpadDebugView.java b/services/core/java/com/android/server/input/debug/TouchpadDebugView.java
index ba56ad073e6a..486d4afdbf43 100644
--- a/services/core/java/com/android/server/input/debug/TouchpadDebugView.java
+++ b/services/core/java/com/android/server/input/debug/TouchpadDebugView.java
@@ -22,6 +22,7 @@ import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.PixelFormat;
import android.graphics.Rect;
+import android.hardware.input.InputManager;
import android.util.Slog;
import android.view.Gravity;
import android.view.MotionEvent;
@@ -31,6 +32,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import com.android.server.input.TouchpadFingerState;
+import com.android.server.input.TouchpadHardwareProperties;
import com.android.server.input.TouchpadHardwareState;
import java.util.Objects;
@@ -59,13 +61,15 @@ public class TouchpadDebugView extends LinearLayout {
private TouchpadHardwareState mLastTouchpadState =
new TouchpadHardwareState(0, 0 /* buttonsDown */, 0, 0,
new TouchpadFingerState[0]);
+ private TouchpadVisualizationView mTouchpadVisualizationView;
- public TouchpadDebugView(Context context, int touchpadId) {
+ public TouchpadDebugView(Context context, int touchpadId,
+ TouchpadHardwareProperties touchpadHardwareProperties) {
super(context);
mTouchpadId = touchpadId;
mWindowManager =
Objects.requireNonNull(getContext().getSystemService(WindowManager.class));
- init(context);
+ init(context, touchpadHardwareProperties, touchpadId);
mTouchSlop = ViewConfiguration.get(context).getScaledTouchSlop();
// TODO(b/360137366): Use the hardware properties to initialise layout parameters.
@@ -88,32 +92,43 @@ public class TouchpadDebugView extends LinearLayout {
mWindowLayoutParams.gravity = Gravity.TOP | Gravity.LEFT;
}
- private void init(Context context) {
+ private void init(Context context, TouchpadHardwareProperties touchpadHardwareProperties,
+ int touchpadId) {
setOrientation(VERTICAL);
setLayoutParams(new LayoutParams(
LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT));
- setBackgroundColor(Color.RED);
-
- // TODO(b/286551975): Replace this content with the touchpad debug view.
- TextView textView1 = new TextView(context);
- textView1.setBackgroundColor(Color.TRANSPARENT);
- textView1.setTextSize(20);
- textView1.setText("Touchpad Debug View 1");
- textView1.setGravity(Gravity.CENTER);
- textView1.setTextColor(Color.WHITE);
- textView1.setLayoutParams(new LayoutParams(1000, 200));
-
- TextView textView2 = new TextView(context);
- textView2.setBackgroundColor(Color.TRANSPARENT);
- textView2.setTextSize(20);
- textView2.setText("Touchpad Debug View 2");
- textView2.setGravity(Gravity.CENTER);
- textView2.setTextColor(Color.WHITE);
- textView2.setLayoutParams(new LayoutParams(1000, 200));
-
- addView(textView1);
- addView(textView2);
+ setBackgroundColor(Color.TRANSPARENT);
+
+ TextView nameView = new TextView(context);
+ nameView.setBackgroundColor(Color.RED);
+ nameView.setTextSize(20);
+ nameView.setText(Objects.requireNonNull(Objects.requireNonNull(
+ mContext.getSystemService(InputManager.class))
+ .getInputDevice(touchpadId)).getName());
+ nameView.setGravity(Gravity.CENTER);
+ nameView.setTextColor(Color.WHITE);
+ nameView.setLayoutParams(new LayoutParams(1000, 200));
+
+ mTouchpadVisualizationView = new TouchpadVisualizationView(context,
+ touchpadHardwareProperties);
+ mTouchpadVisualizationView.setBackgroundColor(Color.WHITE);
+ //TODO(b/365568238): set the view size according to the touchpad size from the
+ // TouchpadHardwareProperties
+ mTouchpadVisualizationView.setLayoutParams(new LayoutParams(778, 500));
+
+ //TODO(b/365562952): Add a display for recognized gesture info here
+ TextView gestureInfoView = new TextView(context);
+ gestureInfoView.setBackgroundColor(Color.GRAY);
+ gestureInfoView.setTextSize(20);
+ gestureInfoView.setText("Touchpad Debug View 3");
+ gestureInfoView.setGravity(Gravity.CENTER);
+ gestureInfoView.setTextColor(Color.BLACK);
+ gestureInfoView.setLayoutParams(new LayoutParams(1000, 200));
+
+ addView(nameView);
+ addView(mTouchpadVisualizationView);
+ addView(gestureInfoView);
updateScreenDimensions();
}
@@ -204,7 +219,19 @@ public class TouchpadDebugView extends LinearLayout {
return mWindowLayoutParams;
}
- public void updateHardwareState(TouchpadHardwareState touchpadHardwareState) {
+ /**
+ * Notify the view of a change in the hardware state of a touchpad. The view should
+ * update its content to reflect the new state.
+ *
+ * @param touchpadHardwareState the hardware state of a touchpad
+ * @param deviceId the deviceId of the touchpad that is sending the hardware state
+ */
+ public void updateHardwareState(TouchpadHardwareState touchpadHardwareState, int deviceId) {
+ if (deviceId != mTouchpadId) {
+ return;
+ }
+
+ mTouchpadVisualizationView.onTouchpadHardwareStateNotified(touchpadHardwareState);
if (mLastTouchpadState.getButtonsDown() == 0) {
if (touchpadHardwareState.getButtonsDown() > 0) {
onTouchpadButtonPress();
@@ -219,18 +246,11 @@ public class TouchpadDebugView extends LinearLayout {
private void onTouchpadButtonPress() {
Slog.d("TouchpadDebugView", "You clicked me!");
-
- // Iterate through all child views
- // Temporary demonstration for testing
- for (int i = 0; i < getChildCount(); i++) {
- getChildAt(i).setBackgroundColor(Color.BLUE);
- }
+ getChildAt(0).setBackgroundColor(Color.BLUE);
}
private void onTouchpadButtonRelease() {
Slog.d("TouchpadDebugView", "You released the click");
- for (int i = 0; i < getChildCount(); i++) {
- getChildAt(i).setBackgroundColor(Color.RED);
- }
+ getChildAt(0).setBackgroundColor(Color.RED);
}
}
diff --git a/services/core/java/com/android/server/input/debug/TouchpadDebugViewController.java b/services/core/java/com/android/server/input/debug/TouchpadDebugViewController.java
index bc53c4947a71..b4b357a29363 100644
--- a/services/core/java/com/android/server/input/debug/TouchpadDebugViewController.java
+++ b/services/core/java/com/android/server/input/debug/TouchpadDebugViewController.java
@@ -68,6 +68,13 @@ public class TouchpadDebugViewController implements InputManager.InputDeviceList
@Override
public void onInputDeviceRemoved(int deviceId) {
hideDebugView(deviceId);
+ if (mTouchpadDebugView == null) {
+ final InputManager inputManager = Objects.requireNonNull(
+ mContext.getSystemService(InputManager.class));
+ for (int id : inputManager.getInputDeviceIds()) {
+ onInputDeviceAdded(id);
+ }
+ }
}
@Override
@@ -105,18 +112,20 @@ public class TouchpadDebugViewController implements InputManager.InputDeviceList
final WindowManager wm = Objects.requireNonNull(
mContext.getSystemService(WindowManager.class));
- mTouchpadDebugView = new TouchpadDebugView(mContext, touchpadId);
+ TouchpadHardwareProperties touchpadHardwareProperties =
+ mInputManagerService.getTouchpadHardwareProperties(
+ touchpadId);
+
+ mTouchpadDebugView = new TouchpadDebugView(mContext, touchpadId,
+ touchpadHardwareProperties);
final WindowManager.LayoutParams mWindowLayoutParams =
mTouchpadDebugView.getWindowLayoutParams();
wm.addView(mTouchpadDebugView, mWindowLayoutParams);
Slog.d(TAG, "Touchpad debug view created.");
- TouchpadHardwareProperties mTouchpadHardwareProperties =
- mInputManagerService.getTouchpadHardwareProperties(
- touchpadId);
- if (mTouchpadHardwareProperties != null) {
- Slog.d(TAG, mTouchpadHardwareProperties.toString());
+ if (touchpadHardwareProperties != null) {
+ Slog.d(TAG, touchpadHardwareProperties.toString());
} else {
Slog.w(TAG, "Failed to retrieve touchpad hardware properties for "
+ "device ID: " + touchpadId);
@@ -134,9 +143,16 @@ public class TouchpadDebugViewController implements InputManager.InputDeviceList
Slog.d(TAG, "Touchpad debug view removed.");
}
- public void updateTouchpadHardwareState(TouchpadHardwareState touchpadHardwareState) {
+ /**
+ * Notifies about an update in the touchpad's hardware state.
+ *
+ * @param touchpadHardwareState the hardware state of a touchpad
+ * @param deviceId the deviceId of the touchpad that is sending the hardware state
+ */
+ public void updateTouchpadHardwareState(TouchpadHardwareState touchpadHardwareState,
+ int deviceId) {
if (mTouchpadDebugView != null) {
- mTouchpadDebugView.updateHardwareState(touchpadHardwareState);
+ mTouchpadDebugView.updateHardwareState(touchpadHardwareState, deviceId);
}
}
}
diff --git a/services/core/java/com/android/server/input/debug/TouchpadVisualizationView.java b/services/core/java/com/android/server/input/debug/TouchpadVisualizationView.java
new file mode 100644
index 000000000000..9ba7d0a655f5
--- /dev/null
+++ b/services/core/java/com/android/server/input/debug/TouchpadVisualizationView.java
@@ -0,0 +1,130 @@
+/*
+ * Copyright 2024 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.server.input.debug;
+
+import android.content.Context;
+import android.graphics.Canvas;
+import android.graphics.Paint;
+import android.graphics.RectF;
+import android.util.Slog;
+import android.view.View;
+
+import com.android.server.input.TouchpadFingerState;
+import com.android.server.input.TouchpadHardwareProperties;
+import com.android.server.input.TouchpadHardwareState;
+
+public class TouchpadVisualizationView extends View {
+ private static final String TAG = "TouchpadVizMain";
+ private static final boolean DEBUG = true;
+
+ private final TouchpadHardwareProperties mTouchpadHardwareProperties;
+
+ TouchpadHardwareState mLatestHardwareState = new TouchpadHardwareState(0, 0, 0, 0,
+ new TouchpadFingerState[]{});
+
+ private final Paint mOvalPaint;
+
+ public TouchpadVisualizationView(Context context,
+ TouchpadHardwareProperties touchpadHardwareProperties) {
+ super(context);
+ mTouchpadHardwareProperties = touchpadHardwareProperties;
+ mOvalPaint = new Paint();
+ mOvalPaint.setAntiAlias(true);
+ mOvalPaint.setARGB(255, 0, 0, 0);
+ mOvalPaint.setStyle(Paint.Style.STROKE);
+ }
+
+ private final RectF mOvalRect = new RectF();
+
+ private void drawOval(Canvas canvas, float x, float y, float major, float minor, float angle,
+ Paint paint) {
+ canvas.save(Canvas.MATRIX_SAVE_FLAG);
+ canvas.rotate(angle, x, y);
+ mOvalRect.left = x - minor / 2;
+ mOvalRect.right = x + minor / 2;
+ mOvalRect.top = y - major / 2;
+ mOvalRect.bottom = y + major / 2;
+ canvas.drawOval(mOvalRect, paint);
+ canvas.restore();
+ }
+
+ @Override
+ protected void onDraw(Canvas canvas) {
+ for (TouchpadFingerState touchpadFingerState : mLatestHardwareState.getFingerStates()) {
+ float newX = translateRange(mTouchpadHardwareProperties.getLeft(),
+ mTouchpadHardwareProperties.getRight(), 0, getWidth(),
+ touchpadFingerState.getPositionX());
+
+ float newY = translateRange(mTouchpadHardwareProperties.getTop(),
+ mTouchpadHardwareProperties.getBottom(), 0, getHeight(),
+ touchpadFingerState.getPositionY());
+
+ float newAngle = -translateRange(mTouchpadHardwareProperties.getOrientationMinimum(),
+ mTouchpadHardwareProperties.getOrientationMaximum(), 0, 360,
+ touchpadFingerState.getOrientation());
+
+ float newTouchMajor =
+ touchpadFingerState.getTouchMajor() / mTouchpadHardwareProperties.getResX();
+ float newTouchMinor =
+ touchpadFingerState.getTouchMinor() / mTouchpadHardwareProperties.getResY();
+
+ drawOval(canvas, newX, newY, newTouchMajor, newTouchMinor, newAngle, mOvalPaint);
+ }
+ }
+
+ /**
+ * Receiving the touchpad hardware state and based on it update the latest hardware state.
+ *
+ * @param schs The new hardware state received.
+ */
+ public void onTouchpadHardwareStateNotified(TouchpadHardwareState schs) {
+ if (DEBUG) {
+ logHardwareState(schs);
+ }
+
+ mLatestHardwareState = schs;
+
+ invalidate();
+ }
+
+ private float translateRange(float rangeBeforeMin, float rangeBeforeMax,
+ float rangeAfterMin, float rangeAfterMax, float value) {
+ return rangeAfterMin + (value - rangeBeforeMin) / (rangeBeforeMax - rangeBeforeMin) * (
+ rangeAfterMax - rangeAfterMin);
+ }
+
+ private void logHardwareState(TouchpadHardwareState schs) {
+ Slog.d(TAG, "notifyTouchpadHardwareState: Time: "
+ + schs.getTimestamp() + ", No. Buttons: "
+ + schs.getButtonsDown() + ", No. Fingers: "
+ + schs.getFingerCount() + ", No. Touch: "
+ + schs.getTouchCount());
+
+ for (TouchpadFingerState finger : schs.getFingerStates()) {
+ Slog.d(TAG, "Finger #" + finger.getTrackingId()
+ + ": touchMajor= " + finger.getTouchMajor()
+ + ", touchMinor= " + finger.getTouchMinor()
+ + ", widthMajor= " + finger.getWidthMajor()
+ + ", widthMinor= " + finger.getWidthMinor()
+ + ", pressure= " + finger.getPressure()
+ + ", orientation= " + finger.getOrientation()
+ + ", positionX= " + finger.getPositionX()
+ + ", positionY= " + finger.getPositionY());
+ }
+ }
+
+}
diff --git a/services/core/java/com/android/server/location/gnss/GnssConfiguration.java b/services/core/java/com/android/server/location/gnss/GnssConfiguration.java
index a439f16e6d97..1740010a8d5f 100644
--- a/services/core/java/com/android/server/location/gnss/GnssConfiguration.java
+++ b/services/core/java/com/android/server/location/gnss/GnssConfiguration.java
@@ -80,8 +80,8 @@ public class GnssConfiguration {
"ENABLE_PSDS_PERIODIC_DOWNLOAD";
private static final String CONFIG_ENABLE_ACTIVE_SIM_EMERGENCY_SUPL =
"ENABLE_ACTIVE_SIM_EMERGENCY_SUPL";
- private static final String CONFIG_ENABLE_NI_SUPL_MESSAGE_INJECTION =
- "ENABLE_NI_SUPL_MESSAGE_INJECTION";
+ private static final String CONFIG_ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL =
+ "ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL";
static final String CONFIG_LONGTERM_PSDS_SERVER_1 = "LONGTERM_PSDS_SERVER_1";
static final String CONFIG_LONGTERM_PSDS_SERVER_2 = "LONGTERM_PSDS_SERVER_2";
static final String CONFIG_LONGTERM_PSDS_SERVER_3 = "LONGTERM_PSDS_SERVER_3";
@@ -230,7 +230,8 @@ public class GnssConfiguration {
* Default false if not set.
*/
boolean isNiSuplMessageInjectionEnabled() {
- return getBooleanConfig(CONFIG_ENABLE_NI_SUPL_MESSAGE_INJECTION, false);
+ return getBooleanConfig(CONFIG_ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL,
+ false);
}
/**
diff --git a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java
index 19381509c7fe..4b2c12abe5bb 100644
--- a/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/gnss/GnssLocationProvider.java
@@ -68,6 +68,7 @@ import android.location.LocationManager;
import android.location.LocationRequest;
import android.location.LocationResult;
import android.location.LocationResult.BadLocationException;
+import android.location.flags.Flags;
import android.location.provider.ProviderProperties;
import android.location.provider.ProviderRequest;
import android.location.util.identity.CallerIdentity;
@@ -310,6 +311,7 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
private String mC2KServerHost;
private int mC2KServerPort;
private boolean mSuplEsEnabled = false;
+ private boolean mNiSuplMessageListenerRegistered = false;
private final LocationExtras mLocationExtras = new LocationExtras();
private final NetworkTimeHelper mNetworkTimeHelper;
@@ -387,6 +389,10 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
// Reload gnss config for no SIM case
mGnssConfiguration.reloadGpsProperties();
}
+ if (Flags.enableNiSuplMessageInjectionByCarrierConfig()) {
+ updateNiSuplMessageListenerRegistration(
+ mGnssConfiguration.isNiSuplMessageInjectionEnabled());
+ }
}
private void reloadGpsProperties() {
@@ -532,28 +538,9 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
intentFilter.addAction(TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED);
mContext.registerReceiver(mIntentReceiver, intentFilter, null, mHandler);
- if (mNetworkConnectivityHandler.isNativeAgpsRilSupported()
- && mGnssConfiguration.isNiSuplMessageInjectionEnabled()) {
- // Listen to WAP PUSH NI SUPL message.
- // See User Plane Location Protocol Candidate Version 3.0,
- // OMA-TS-ULP-V3_0-20110920-C, Section 8.3 OMA Push.
- intentFilter = new IntentFilter();
- intentFilter.addAction(Intents.WAP_PUSH_RECEIVED_ACTION);
- try {
- intentFilter.addDataType("application/vnd.omaloc-supl-init");
- } catch (IntentFilter.MalformedMimeTypeException e) {
- Log.w(TAG, "Malformed SUPL init mime type");
- }
- mContext.registerReceiver(mIntentReceiver, intentFilter, null, mHandler);
-
- // Listen to MT SMS NI SUPL message.
- // See User Plane Location Protocol Candidate Version 3.0,
- // OMA-TS-ULP-V3_0-20110920-C, Section 8.4 MT SMS.
- intentFilter = new IntentFilter();
- intentFilter.addAction(Intents.DATA_SMS_RECEIVED_ACTION);
- intentFilter.addDataScheme("sms");
- intentFilter.addDataAuthority("localhost", "7275");
- mContext.registerReceiver(mIntentReceiver, intentFilter, null, mHandler);
+ if (!Flags.enableNiSuplMessageInjectionByCarrierConfig()) {
+ updateNiSuplMessageListenerRegistration(
+ mGnssConfiguration.isNiSuplMessageInjectionEnabled());
}
mNetworkConnectivityHandler.registerNetworkCallbacks();
@@ -592,6 +579,20 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
case TelephonyManager.ACTION_DEFAULT_DATA_SUBSCRIPTION_CHANGED:
subscriptionOrCarrierConfigChanged();
break;
+ }
+ }
+ };
+
+ private BroadcastReceiver mNiSuplIntentReceiver = new BroadcastReceiver() {
+ @Override
+ public void onReceive(Context context, Intent intent) {
+ String action = intent.getAction();
+ if (DEBUG) Log.d(TAG, "receive broadcast intent, action: " + action);
+ if (action == null) {
+ return;
+ }
+
+ switch (action) {
case Intents.WAP_PUSH_RECEIVED_ACTION:
case Intents.DATA_SMS_RECEIVED_ACTION:
injectSuplInit(intent);
@@ -1442,6 +1443,46 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
mGnssMetrics.logSvStatus(gnssStatus);
}
+ private void updateNiSuplMessageListenerRegistration(boolean shouldRegister) {
+ if (!mNetworkConnectivityHandler.isNativeAgpsRilSupported()) {
+ return;
+ }
+ if (mNiSuplMessageListenerRegistered == shouldRegister) {
+ return;
+ }
+
+ // WAP PUSH NI SUPL message intent filter.
+ // See User Plane Location Protocol Candidate Version 3.0,
+ // OMA-TS-ULP-V3_0-20110920-C, Section 8.3 OMA Push.
+ IntentFilter wapPushNiIntentFilter = new IntentFilter();
+ wapPushNiIntentFilter.addAction(Intents.WAP_PUSH_RECEIVED_ACTION);
+ try {
+ wapPushNiIntentFilter
+ .addDataType("application/vnd.omaloc-supl-init");
+ } catch (IntentFilter.MalformedMimeTypeException e) {
+ Log.w(TAG, "Malformed SUPL init mime type");
+ }
+
+ // MT SMS NI SUPL message intent filter.
+ // See User Plane Location Protocol Candidate Version 3.0,
+ // OMA-TS-ULP-V3_0-20110920-C, Section 8.4 MT SMS.
+ IntentFilter mtSmsNiIntentFilter = new IntentFilter();
+ mtSmsNiIntentFilter.addAction(Intents.DATA_SMS_RECEIVED_ACTION);
+ mtSmsNiIntentFilter.addDataScheme("sms");
+ mtSmsNiIntentFilter.addDataAuthority("localhost", "7275");
+
+ if (shouldRegister) {
+ mContext.registerReceiver(mNiSuplIntentReceiver,
+ wapPushNiIntentFilter, null, mHandler);
+ mContext.registerReceiver(mNiSuplIntentReceiver,
+ mtSmsNiIntentFilter, null, mHandler);
+ mNiSuplMessageListenerRegistered = true;
+ } else {
+ mContext.unregisterReceiver(mNiSuplIntentReceiver);
+ mNiSuplMessageListenerRegistered = false;
+ }
+ }
+
private void restartLocationRequest() {
if (DEBUG) Log.d(TAG, "restartLocationRequest");
setStarted(false);
@@ -1631,6 +1672,10 @@ public class GnssLocationProvider extends AbstractLocationProvider implements
if (dumpAll) {
mNetworkTimeHelper.dump(pw);
pw.println("mSupportsPsds=" + mSupportsPsds);
+ if (Flags.enableNiSuplMessageInjectionByCarrierConfig()) {
+ pw.println("mNiSuplMessageListenerRegistered="
+ + mNiSuplMessageListenerRegistered);
+ }
pw.println(
"PsdsServerConfigured=" + mGnssConfiguration.isLongTermPsdsServerConfigured());
pw.println("native internal state: ");
diff --git a/services/core/java/com/android/server/locksettings/LockSettingsService.java b/services/core/java/com/android/server/locksettings/LockSettingsService.java
index 38ef5b8cedb9..7d44ba199119 100644
--- a/services/core/java/com/android/server/locksettings/LockSettingsService.java
+++ b/services/core/java/com/android/server/locksettings/LockSettingsService.java
@@ -889,8 +889,14 @@ public class LockSettingsService extends ILockSettings.Stub {
// Hide notification first, as tie profile lock takes time
hideEncryptionNotification(new UserHandle(userId));
- if (isCredentialSharableWithParent(userId)) {
- tieProfileLockIfNecessary(userId, LockscreenCredential.createNone());
+ if (android.app.admin.flags.Flags.fixRaceConditionInTieProfileLock()) {
+ synchronized (mSpManager) {
+ tieProfileLockIfNecessary(userId, LockscreenCredential.createNone());
+ }
+ } else {
+ if (isCredentialSharableWithParent(userId)) {
+ tieProfileLockIfNecessary(userId, LockscreenCredential.createNone());
+ }
}
}
});
@@ -1287,7 +1293,13 @@ public class LockSettingsService extends ILockSettings.Stub {
mStorage.removeChildProfileLock(userId);
removeKeystoreProfileKey(userId);
} else {
- tieProfileLockIfNecessary(userId, profileUserPassword);
+ if (android.app.admin.flags.Flags.fixRaceConditionInTieProfileLock()) {
+ synchronized (mSpManager) {
+ tieProfileLockIfNecessary(userId, profileUserPassword);
+ }
+ } else {
+ tieProfileLockIfNecessary(userId, profileUserPassword);
+ }
}
} catch (IllegalStateException e) {
setBoolean(SEPARATE_PROFILE_CHALLENGE_KEY, old, userId);
diff --git a/services/core/java/com/android/server/logcat/TEST_MAPPING b/services/core/java/com/android/server/logcat/TEST_MAPPING
index 5b07cd960fbe..688dbe9ec444 100644
--- a/services/core/java/com/android/server/logcat/TEST_MAPPING
+++ b/services/core/java/com/android/server/logcat/TEST_MAPPING
@@ -1,15 +1,12 @@
{
"presubmit": [
{
- "name": "FrameworksServicesTests_android_server_logcat_Presubmit"
+ "name": "FrameworksServicesTests_android_server_logcat"
}
],
"postsubmit": [
{
- "name": "FrameworksServicesTests",
- "options": [
- {"include-filter": "com.android.server.logcat"}
- ]
+ "name": "FrameworksServicesTests_android_server_logcat"
}
]
}
diff --git a/services/core/java/com/android/server/notification/BubbleExtractor.java b/services/core/java/com/android/server/notification/BubbleExtractor.java
index b8900d7acee5..3d6f9cfed697 100644
--- a/services/core/java/com/android/server/notification/BubbleExtractor.java
+++ b/services/core/java/com/android/server/notification/BubbleExtractor.java
@@ -27,10 +27,11 @@ import static com.android.internal.util.FrameworkStatsLog.BUBBLE_DEVELOPER_ERROR
import android.app.ActivityManager;
import android.app.Notification;
import android.app.NotificationChannel;
-import android.app.PendingIntent;
import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.content.res.Resources;
import android.util.Slog;
@@ -47,6 +48,7 @@ public class BubbleExtractor implements NotificationSignalExtractor {
private ShortcutHelper mShortcutHelper;
private RankingConfig mConfig;
private ActivityManager mActivityManager;
+ private PackageManager mPackageManager;
private Context mContext;
boolean mSupportsBubble;
@@ -76,6 +78,11 @@ public class BubbleExtractor implements NotificationSignalExtractor {
return null;
}
+ if (mPackageManager == null) {
+ if (DBG) Slog.d(TAG, "missing package manager");
+ return null;
+ }
+
boolean notifCanPresentAsBubble = canPresentAsBubble(record)
&& !mActivityManager.isLowRamDevice()
&& record.isConversation()
@@ -133,6 +140,10 @@ public class BubbleExtractor implements NotificationSignalExtractor {
mShortcutHelper = helper;
}
+ public void setPackageManager(PackageManager packageManager) {
+ mPackageManager = packageManager;
+ }
+
@VisibleForTesting
public void setActivityManager(ActivityManager manager) {
mActivityManager = manager;
@@ -176,30 +187,25 @@ public class BubbleExtractor implements NotificationSignalExtractor {
// TODO: check the shortcut intent / ensure it can show in activity view
return true;
}
- return canLaunchInTaskView(mContext, metadata.getIntent(), pkg);
+ return canLaunchInTaskView(metadata.getIntent().getIntent(), pkg,
+ r.getUser().getIdentifier());
}
/**
- * Whether an intent is properly configured to display in an {@link
- * TaskView} for bubbling.
+ * Whether an intent is properly configured to display in a TaskView for bubbling.
*
- * @param context the context to use.
- * @param pendingIntent the pending intent of the bubble.
- * @param packageName the notification package name for this bubble.
+ * @param intent the intent of the bubble.
+ * @param packageName the notification package name for this bubble.
*/
- // Keep checks in sync with BubbleController#canLaunchInTaskView.
- @VisibleForTesting
- protected boolean canLaunchInTaskView(Context context, PendingIntent pendingIntent,
- String packageName) {
- if (pendingIntent == null) {
+ // Keep checks in sync with BubbleController#isResizableActivity.
+ private boolean canLaunchInTaskView(Intent intent, String packageName, int userId) {
+ if (intent == null) {
Slog.w(TAG, "Unable to create bubble -- no intent");
return false;
}
- Intent intent = pendingIntent.getIntent();
- ActivityInfo info = intent != null
- ? intent.resolveActivityInfo(context.getPackageManager(), 0)
- : null;
+ ResolveInfo resolveInfo = mPackageManager.resolveActivityAsUser(intent, 0, userId);
+ ActivityInfo info = resolveInfo != null ? resolveInfo.activityInfo : null;
if (info == null) {
FrameworkStatsLog.write(FrameworkStatsLog.BUBBLE_DEVELOPER_ERROR_REPORTED,
packageName,
diff --git a/services/core/java/com/android/server/notification/ManagedServices.java b/services/core/java/com/android/server/notification/ManagedServices.java
index 3523a3336a63..03fc60cad8d6 100644
--- a/services/core/java/com/android/server/notification/ManagedServices.java
+++ b/services/core/java/com/android/server/notification/ManagedServices.java
@@ -1094,7 +1094,7 @@ abstract public class ManagedServices {
return info;
}
throw new SecurityException("Disallowed call from unknown " + getCaption() + ": "
- + service + " " + service.getClass());
+ + service.asBinder() + " " + service.getClass());
}
public boolean isSameUser(IInterface service, int userId) {
@@ -1585,6 +1585,9 @@ abstract public class ManagedServices {
// after the rebind delay
if (isPackageOrComponentAllowedWithPermission(cn, userId)) {
registerService(cn, userId);
+ } else {
+ if (DEBUG) Slog.v(TAG, "skipped reregisterService cn=" + cn + " u=" + userId
+ + " because of isPackageOrComponentAllowedWithPermission check");
}
}
@@ -1918,6 +1921,7 @@ abstract public class ManagedServices {
.append(",targetSdkVersion=").append(targetSdkVersion)
.append(",connection=").append(connection == null ? null : "<connection>")
.append(",service=").append(service)
+ .append(",serviceAsBinder=").append(service != null ? service.asBinder() : null)
.append(']').toString();
}
@@ -1956,7 +1960,7 @@ abstract public class ManagedServices {
@Override
public void binderDied() {
- if (DEBUG) Slog.d(TAG, "binderDied");
+ if (DEBUG) Slog.d(TAG, "binderDied " + this);
// Remove the service, but don't unbind from the service. The system will bring the
// service back up, and the onServiceConnected handler will read the service with the
// new binding. If this isn't a bound service, and is just a registered
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 54e918972d46..e2ec0063c711 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -3020,6 +3020,7 @@ public class NotificationManagerService extends SystemService {
BubbleExtractor bubbsExtractor = mRankingHelper.findExtractor(BubbleExtractor.class);
if (bubbsExtractor != null) {
bubbsExtractor.setShortcutHelper(mShortcutHelper);
+ bubbsExtractor.setPackageManager(mPackageManagerClient);
}
registerNotificationPreferencesPullers();
if (mLockUtils == null) {
diff --git a/services/core/java/com/android/server/notification/NotificationRecord.java b/services/core/java/com/android/server/notification/NotificationRecord.java
index e54124608a26..b9f0968b5864 100644
--- a/services/core/java/com/android/server/notification/NotificationRecord.java
+++ b/services/core/java/com/android/server/notification/NotificationRecord.java
@@ -330,10 +330,19 @@ public final class NotificationRecord {
}
final long[] vibrationPattern = channel.getVibrationPattern();
- if (vibrationPattern == null) {
- return helper.createDefaultVibration(insistent);
+ if (vibrationPattern != null) {
+ return helper.createWaveformVibration(vibrationPattern, insistent);
}
- return helper.createWaveformVibration(vibrationPattern, insistent);
+
+ if (com.android.server.notification.Flags.notificationVibrationInSoundUri()) {
+ final VibrationEffect vibrationEffectFromSoundUri =
+ helper.createVibrationEffectFromSoundUri(channel.getSound());
+ if (vibrationEffectFromSoundUri != null) {
+ return vibrationEffectFromSoundUri;
+ }
+ }
+
+ return helper.createDefaultVibration(insistent);
}
private VibrationEffect calculateVibration() {
diff --git a/services/core/java/com/android/server/notification/VibratorHelper.java b/services/core/java/com/android/server/notification/VibratorHelper.java
index 8a0e595176ec..fbe77720b9fc 100644
--- a/services/core/java/com/android/server/notification/VibratorHelper.java
+++ b/services/core/java/com/android/server/notification/VibratorHelper.java
@@ -24,6 +24,9 @@ import android.content.Context;
import android.content.res.Resources;
import android.content.res.TypedArray;
import android.media.AudioAttributes;
+import android.media.RingtoneManager;
+import android.media.Utils;
+import android.net.Uri;
import android.os.Process;
import android.os.VibrationAttributes;
import android.os.VibrationEffect;
@@ -51,6 +54,7 @@ public final class VibratorHelper {
@Nullable private final float[] mDefaultPwlePattern;
@Nullable private final float[] mFallbackPwlePattern;
private final int mDefaultVibrationAmplitude;
+ private final Context mContext;
public VibratorHelper(Context context) {
mVibrator = context.getSystemService(Vibrator.class);
@@ -68,6 +72,7 @@ public final class VibratorHelper {
com.android.internal.R.array.config_notificationFallbackVibeWaveform);
mDefaultVibrationAmplitude = context.getResources().getInteger(
com.android.internal.R.integer.config_defaultVibrationAmplitude);
+ mContext = context;
}
/**
@@ -184,6 +189,16 @@ public final class VibratorHelper {
* @param insistent {@code true} if the vibration should loop until it is cancelled.
*/
public VibrationEffect createDefaultVibration(boolean insistent) {
+ if (com.android.server.notification.Flags.notificationVibrationInSoundUri()) {
+ final Uri defaultRingtoneUri = RingtoneManager.getActualDefaultRingtoneUri(mContext,
+ RingtoneManager.TYPE_NOTIFICATION);
+ final VibrationEffect vibrationEffectFromSoundUri =
+ createVibrationEffectFromSoundUri(defaultRingtoneUri);
+ if (vibrationEffectFromSoundUri != null) {
+ return vibrationEffectFromSoundUri;
+ }
+ }
+
if (mVibrator.hasFrequencyControl()) {
VibrationEffect effect = createPwleWaveformVibration(mDefaultPwlePattern, insistent);
if (effect != null) {
@@ -193,6 +208,22 @@ public final class VibratorHelper {
return createWaveformVibration(mDefaultPattern, insistent);
}
+ /**
+ * Safely create a {@link VibrationEffect} from given an uri {@code Uri}.
+ * with query parameter "vibration_uri"
+ *
+ * Use this function if the {@code Uri} is with a query parameter "vibration_uri" and the
+ * vibration_uri represents a valid vibration effect in xml
+ *
+ * @param uri {@code Uri} an uri including query parameter "vibraiton_uri"
+ */
+ public @Nullable VibrationEffect createVibrationEffectFromSoundUri(Uri uri) {
+ if (uri == null) {
+ return null;
+ }
+ return Utils.parseVibrationEffect(mVibrator, Utils.getVibrationUri(uri));
+ }
+
/** Returns if a given vibration can be played by the vibrator that does notification buzz. */
public boolean areEffectComponentsSupported(VibrationEffect effect) {
return mVibrator.areVibrationFeaturesSupported(effect);
diff --git a/services/core/java/com/android/server/notification/flags.aconfig b/services/core/java/com/android/server/notification/flags.aconfig
index aac2c404fd38..be3adc142fa4 100644
--- a/services/core/java/com/android/server/notification/flags.aconfig
+++ b/services/core/java/com/android/server/notification/flags.aconfig
@@ -156,3 +156,10 @@ flag {
description: "This flag enables forced auto-grouping conversations"
bug: "336488844"
}
+
+flag {
+ name: "notification_vibration_in_sound_uri"
+ namespace: "systemui"
+ description: "This flag enables sound uri with vibration source"
+ bug: "358524009"
+}
diff --git a/services/core/java/com/android/server/om/OverlayManagerService.java b/services/core/java/com/android/server/om/OverlayManagerService.java
index 6303ecd53dbb..a41675a4aac5 100644
--- a/services/core/java/com/android/server/om/OverlayManagerService.java
+++ b/services/core/java/com/android/server/om/OverlayManagerService.java
@@ -298,12 +298,13 @@ public final class OverlayManagerService extends SystemService {
restoreSettings();
- // Wipe all shell overlays on boot, to recover from a potentially broken device
- String shellPkgName = TextUtils.emptyIfNull(
- getContext().getString(android.R.string.config_systemShell));
- mSettings.removeIf(overlayInfo -> overlayInfo.isFabricated
- && shellPkgName.equals(overlayInfo.packageName));
-
+ if (Build.IS_USER) {
+ // Wipe all shell overlays on boot, to recover from a potentially broken device
+ String shellPkgName = TextUtils.emptyIfNull(
+ getContext().getString(android.R.string.config_systemShell));
+ mSettings.removeIf(overlayInfo -> overlayInfo.isFabricated
+ && shellPkgName.equals(overlayInfo.packageName));
+ }
initIfNeeded();
onStartUser(UserHandle.USER_SYSTEM);
diff --git a/services/core/java/com/android/server/pm/InstallPackageHelper.java b/services/core/java/com/android/server/pm/InstallPackageHelper.java
index 2c3f6ea3d9f7..f449126af0f9 100644
--- a/services/core/java/com/android/server/pm/InstallPackageHelper.java
+++ b/services/core/java/com/android/server/pm/InstallPackageHelper.java
@@ -1019,9 +1019,7 @@ final class InstallPackageHelper {
&& scanInstallPackages(requests, createdAppId, versionInfos)) {
List<ReconciledPackage> reconciledPackages =
reconcileInstallPackages(requests, versionInfos);
- if (reconciledPackages != null
- && renameAndUpdatePaths(requests)
- && commitInstallPackages(reconciledPackages)) {
+ if (reconciledPackages != null && commitInstallPackages(reconciledPackages)) {
success = true;
}
}
@@ -1031,49 +1029,24 @@ final class InstallPackageHelper {
}
}
- private boolean renameAndUpdatePaths(List<InstallRequest> requests) {
+ private boolean prepareInstallPackages(List<InstallRequest> requests) {
+ // TODO: will remove the locking after doRename is moved out of prepare
try (PackageManagerTracedLock installLock = mPm.mInstallLock.acquireLock()) {
for (InstallRequest request : requests) {
- ParsedPackage parsedPackage = request.getParsedPackage();
- final boolean isApex = (request.getScanFlags() & SCAN_AS_APEX) != 0;
- if (isApex) {
- continue;
- }
try {
- doRenameLI(request, parsedPackage);
- setUpFsVerity(parsedPackage);
- } catch (Installer.InstallerException | IOException | DigestException
- | NoSuchAlgorithmException | PrepareFailure e) {
- request.setError(PackageManagerException.INTERNAL_ERROR_VERITY_SETUP,
- "Failed to set up verity: " + e);
+ Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "preparePackage");
+ request.onPrepareStarted();
+ preparePackageLI(request);
+ } catch (PrepareFailure prepareFailure) {
+ request.setError(prepareFailure.error,
+ prepareFailure.getMessage());
+ request.setOriginPackage(prepareFailure.mConflictingPackage);
+ request.setOriginPermission(prepareFailure.mConflictingPermission);
return false;
+ } finally {
+ request.onPrepareFinished();
+ Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
}
-
- // update paths that are set before renaming
- PackageSetting scannedPackageSetting = request.getScannedPackageSetting();
- scannedPackageSetting.setPath(new File(parsedPackage.getPath()));
- scannedPackageSetting.setLegacyNativeLibraryPath(
- parsedPackage.getNativeLibraryRootDir());
- }
- return true;
- }
- }
-
- private boolean prepareInstallPackages(List<InstallRequest> requests) {
- for (InstallRequest request : requests) {
- try {
- Trace.traceBegin(TRACE_TAG_PACKAGE_MANAGER, "preparePackage");
- request.onPrepareStarted();
- preparePackage(request);
- } catch (PrepareFailure prepareFailure) {
- request.setError(prepareFailure.error,
- prepareFailure.getMessage());
- request.setOriginPackage(prepareFailure.mConflictingPackage);
- request.setOriginPermission(prepareFailure.mConflictingPermission);
- return false;
- } finally {
- request.onPrepareFinished();
- Trace.traceEnd(TRACE_TAG_PACKAGE_MANAGER);
}
}
return true;
@@ -1258,7 +1231,8 @@ final class InstallPackageHelper {
return newProp != null && newProp.getBoolean();
}
- private void preparePackage(InstallRequest request) throws PrepareFailure {
+ @GuardedBy("mPm.mInstallLock")
+ private void preparePackageLI(InstallRequest request) throws PrepareFailure {
final int[] allUsers = mPm.mUserManager.getUserIds();
final int installFlags = request.getInstallFlags();
final boolean onExternal = request.getVolumeUuid() != null;
@@ -1765,7 +1739,18 @@ final class InstallPackageHelper {
}
}
- if (isApex) {
+ if (!isApex) {
+ doRenameLI(request, parsedPackage);
+
+ try {
+ setUpFsVerity(parsedPackage);
+ } catch (Installer.InstallerException | IOException | DigestException
+ | NoSuchAlgorithmException e) {
+ throw PrepareFailure.ofInternalError(
+ "Failed to set up verity: " + e,
+ PackageManagerException.INTERNAL_ERROR_VERITY_SETUP);
+ }
+ } else {
// Use the path returned by apexd
parsedPackage.setPath(request.getApexInfo().modulePath);
parsedPackage.setBaseApkPath(request.getApexInfo().modulePath);
@@ -1897,10 +1882,16 @@ final class InstallPackageHelper {
}
if (!oldSharedUid.equals(newSharedUid)) {
- throw new PrepareFailure(INSTALL_FAILED_UID_CHANGED,
- "Package " + parsedPackage.getPackageName()
- + " shared user changed from "
- + oldSharedUid + " to " + newSharedUid);
+ if (!(oldSharedUid.equals("<nothing>") && ps.getPkg() == null
+ && ps.isArchivedOnAnyUser(allUsers))) {
+ // Only allow changing sharedUserId if unarchiving
+ // TODO(b/361558423): remove this check after pre-archiving installs
+ // accept a sharedUserId param in the API
+ throw new PrepareFailure(INSTALL_FAILED_UID_CHANGED,
+ "Package " + parsedPackage.getPackageName()
+ + " shared user changed from "
+ + oldSharedUid + " to " + newSharedUid);
+ }
}
// APK should not re-join shared UID
@@ -2101,21 +2092,7 @@ final class InstallPackageHelper {
// Reflect the rename in scanned details
try {
- String afterCanonicalPath = afterCodeFile.getCanonicalPath();
- String beforeCanonicalPath = beforeCodeFile.getCanonicalPath();
- parsedPackage.setPath(afterCanonicalPath);
-
- parsedPackage.setNativeLibraryDir(
- parsedPackage.getNativeLibraryDir()
- .replace(beforeCanonicalPath, afterCanonicalPath));
- parsedPackage.setNativeLibraryRootDir(
- parsedPackage.getNativeLibraryRootDir()
- .replace(beforeCanonicalPath, afterCanonicalPath));
- String secondaryNativeLibraryDir = parsedPackage.getSecondaryNativeLibraryDir();
- if (secondaryNativeLibraryDir != null) {
- parsedPackage.setSecondaryNativeLibraryDir(
- secondaryNativeLibraryDir.replace(beforeCanonicalPath, afterCanonicalPath));
- }
+ parsedPackage.setPath(afterCodeFile.getCanonicalPath());
} catch (IOException e) {
Slog.e(TAG, "Failed to get path: " + afterCodeFile, e);
throw new PrepareFailure(PackageManager.INSTALL_FAILED_MEDIA_UNAVAILABLE,
diff --git a/services/core/java/com/android/server/pm/PackageArchiver.java b/services/core/java/com/android/server/pm/PackageArchiver.java
index 5e45b4c2d5af..76ea0b963036 100644
--- a/services/core/java/com/android/server/pm/PackageArchiver.java
+++ b/services/core/java/com/android/server/pm/PackageArchiver.java
@@ -283,10 +283,7 @@ public class PackageArchiver {
return START_CLASS_NOT_FOUND;
}
- String currentLauncherPackageName = getCurrentLauncherPackageName(getParentUserId(userId));
- if ((currentLauncherPackageName == null || !TextUtils.equals(callerPackageName,
- currentLauncherPackageName)) && callingUid != Process.SHELL_UID) {
- // TODO(b/311619990): Remove dependency on SHELL_UID for testing
+ if (!isCallerQualifiedForUnarchival(callerPackageName, callingUid, userId)) {
Slog.e(TAG, TextUtils.formatSimple(
"callerPackageName: %s does not qualify for unarchival of package: " + "%s!",
callerPackageName, packageName));
@@ -335,6 +332,37 @@ public class PackageArchiver {
return START_ABORTED;
}
+ private boolean isCallerQualifiedForUnarchival(String callerPackageName, int callingUid,
+ int userId) {
+ // TODO(b/311619990): Remove dependency on SHELL_UID for testing
+ if (callingUid == Process.SHELL_UID) {
+ return true;
+ }
+ String currentLauncherPackageName = getCurrentLauncherPackageName(getParentUserId(userId));
+ if (currentLauncherPackageName != null && TextUtils.equals(
+ callerPackageName, currentLauncherPackageName)) {
+ return true;
+ }
+ Slog.w(TAG, TextUtils.formatSimple(
+ "Requester of unarchival: %s is not the default launcher package: %s.",
+ callerPackageName, currentLauncherPackageName));
+ // When the default launcher is not set, or when the current caller is not the default
+ // launcher, allow the caller to directly request unarchive if it is a launcher app
+ // that is a pre-installed system app.
+ final Computer snapshot = mPm.snapshotComputer();
+ final PackageStateInternal ps = snapshot.getPackageStateInternal(callerPackageName);
+ final boolean isSystem = ps != null && ps.isSystem();
+ return isSystem && isLauncherApp(snapshot, callerPackageName, userId);
+ }
+
+ private boolean isLauncherApp(Computer snapshot, String packageName, int userId) {
+ final Intent intent = snapshot.getHomeIntent();
+ intent.setPackage(packageName);
+ List<ResolveInfo> launcherActivities = snapshot.queryIntentActivitiesInternal(
+ intent, null /* resolvedType */, 0 /* flags */, userId);
+ return !launcherActivities.isEmpty();
+ }
+
// Profiles share their UI and default apps, so we have to get the profile parent before
// fetching the default launcher.
private int getParentUserId(int userId) {
@@ -936,13 +964,9 @@ public class PackageArchiver {
* <p> In the rare case the app had multiple launcher activities, only one of the icons is
* returned arbitrarily.
*
- * <p> By default, the icon will be overlay'd with a cloud icon on top. A launcher app can
+ * <p> By default, the icon will be overlay'd with a cloud icon on top. An app can
* disable the cloud overlay via the
* {@link LauncherApps.ArchiveCompatibilityParams#setEnableIconOverlay(boolean)} API.
- * The default launcher's cloud overlay mode determines the cloud overlay status returned by
- * any other callers. That is, if the current launcher has the cloud overlay disabled, any other
- * app that fetches the app icon will also get an icon that has the cloud overlay disabled.
- * This is to prevent style mismatch caused by icons that are fetched by different callers.
*/
@Nullable
public Bitmap getArchivedAppIcon(@NonNull String packageName, @NonNull UserHandle user,
diff --git a/services/core/java/com/android/server/pm/PackageSetting.java b/services/core/java/com/android/server/pm/PackageSetting.java
index 9fb9e717fe4d..9428de700385 100644
--- a/services/core/java/com/android/server/pm/PackageSetting.java
+++ b/services/core/java/com/android/server/pm/PackageSetting.java
@@ -925,6 +925,18 @@ public class PackageSetting extends SettingBase implements PackageStateInternal
return PackageArchiver.isArchived(readUserState(userId));
}
+ /**
+ * @return if the package is archived in any of the users
+ */
+ boolean isArchivedOnAnyUser(int[] userIds) {
+ for (int user : userIds) {
+ if (isArchived(user)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
int getInstallReason(int userId) {
return readUserState(userId).getInstallReason();
}
diff --git a/services/core/java/com/android/server/power/stats/PowerStatsCollector.java b/services/core/java/com/android/server/power/stats/PowerStatsCollector.java
index 291f0e38908e..e5b990eeda4b 100644
--- a/services/core/java/com/android/server/power/stats/PowerStatsCollector.java
+++ b/services/core/java/com/android/server/power/stats/PowerStatsCollector.java
@@ -432,9 +432,6 @@ public abstract class PowerStatsCollector {
EnergyConsumerResult[] energy =
mConsumedEnergyRetriever.getConsumedEnergy(mEnergyConsumerIds);
- System.out.println("mEnergyConsumerIds = " + Arrays.toString(mEnergyConsumerIds) + " "
- + "energy = "
- + Arrays.toString(energy));
if (energy == null) {
return false;
}
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java b/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java
index 09d2a0263f2e..83cb72e1df1f 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerInternal.java
@@ -35,7 +35,8 @@ import com.android.server.notification.NotificationDelegate;
public interface StatusBarManagerInternal {
void setNotificationDelegate(NotificationDelegate delegate);
- void showScreenPinningRequest(int taskId);
+ /** Show a screen pinning request for a specific task. */
+ void showScreenPinningRequest(int taskId, int userId);
void showAssistDisclosure();
void preloadRecentApps();
@@ -136,7 +137,7 @@ public interface StatusBarManagerInternal {
*
* @param hidesStatusBar whether it is being hidden
*/
- void setTopAppHidesStatusBar(boolean hidesStatusBar);
+ void setTopAppHidesStatusBar(int displayId, boolean hidesStatusBar);
boolean showShutdownUi(boolean isReboot, String requestString);
@@ -149,17 +150,18 @@ public interface StatusBarManagerInternal {
/**
* Notify System UI that the system get into or exit immersive mode.
+ * @param displayId The changed display Id.
* @param rootDisplayAreaId The changed display area Id.
* @param isImmersiveMode {@code true} if the display area get into immersive mode.
*/
- void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode);
+ void immersiveModeChanged(int displayId, int rootDisplayAreaId, boolean isImmersiveMode);
/**
* Show a rotation suggestion that a user may approve to rotate the screen.
*
* @param rotation rotation suggestion
*/
- void onProposedRotationChanged(int rotation, boolean isValid);
+ void onProposedRotationChanged(int displayId, int rotation, boolean isValid);
/**
* Notifies System UI that the display is ready to show system decorations.
diff --git a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
index 0fd59670436e..908f51b9cba9 100644
--- a/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
+++ b/services/core/java/com/android/server/statusbar/StatusBarManagerService.java
@@ -119,6 +119,7 @@ import com.android.server.LocalServices;
import com.android.server.UiThread;
import com.android.server.inputmethod.InputMethodManagerInternal;
import com.android.server.notification.NotificationDelegate;
+import com.android.server.pm.UserManagerInternal;
import com.android.server.pm.UserManagerService;
import com.android.server.policy.GlobalActionsProvider;
import com.android.server.power.ShutdownCheckPoints;
@@ -185,6 +186,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
private final ActivityManagerInternal mActivityManagerInternal;
private final ActivityTaskManagerInternal mActivityTaskManager;
private final PackageManagerInternal mPackageManagerInternal;
+ private final UserManagerInternal mUserManagerInternal;
private final SessionMonitor mSessionMonitor;
private int mCurrentUserId;
private boolean mTracingEnabled;
@@ -304,6 +306,7 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
mActivityTaskManager = LocalServices.getService(ActivityTaskManagerInternal.class);
mPackageManagerInternal = LocalServices.getService(PackageManagerInternal.class);
mActivityManagerInternal = LocalServices.getService(ActivityManagerInternal.class);
+ mUserManagerInternal = LocalServices.getService(UserManagerInternal.class);
mTileRequestTracker = new TileRequestTracker(mContext);
mSessionMonitor = new SessionMonitor(mContext);
@@ -360,7 +363,14 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
}
@Override
- public void showScreenPinningRequest(int taskId) {
+ public void showScreenPinningRequest(int taskId, int userId) {
+ if (isVisibleBackgroundUser(userId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping showScreenPinningRequest for visible background user "
+ + userId);
+ }
+ return;
+ }
IStatusBar bar = mBar;
if (bar != null) {
try {
@@ -439,6 +449,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
@Override
public void appTransitionFinished(int displayId) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping appTransitionFinished for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
enforceStatusBarService();
IStatusBar bar = mBar;
if (bar != null) {
@@ -588,6 +605,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
@Override
public void setWindowState(int displayId, int window, int state) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping setWindowState for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
IStatusBar bar = mBar;
if (bar != null) {
try {
@@ -598,6 +622,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
@Override
public void appTransitionPending(int displayId) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping appTransitionPending for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
IStatusBar bar = mBar;
if (bar != null) {
try {
@@ -608,6 +639,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
@Override
public void appTransitionCancelled(int displayId) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping appTransitionCancelled for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
IStatusBar bar = mBar;
if (bar != null) {
try {
@@ -619,6 +657,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
@Override
public void appTransitionStarting(int displayId, long statusBarAnimationsStartTime,
long statusBarAnimationsDuration) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping appTransitionStarting for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
IStatusBar bar = mBar;
if (bar != null) {
try {
@@ -629,7 +674,14 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
}
@Override
- public void setTopAppHidesStatusBar(boolean hidesStatusBar) {
+ public void setTopAppHidesStatusBar(int displayId, boolean hidesStatusBar) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping setTopAppHidesStatusBar for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
IStatusBar bar = mBar;
if (bar != null) {
try {
@@ -665,10 +717,18 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
}
@Override
- public void immersiveModeChanged(int rootDisplayAreaId, boolean isImmersiveMode) {
+ public void immersiveModeChanged(int displayId, int rootDisplayAreaId,
+ boolean isImmersiveMode) {
if (mBar == null) {
return;
}
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping immersiveModeChanged for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
if (!CLIENT_TRANSIENT) {
// Only call from here when the client transient is not enabled.
try {
@@ -680,7 +740,14 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
// TODO(b/118592525): support it per display if necessary.
@Override
- public void onProposedRotationChanged(int rotation, boolean isValid) {
+ public void onProposedRotationChanged(int displayId, int rotation, boolean isValid) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping onProposedRotationChanged for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
if (mBar != null){
try {
mBar.onProposedRotationChanged(rotation, isValid);
@@ -690,6 +757,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
@Override
public void onDisplayReady(int displayId) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping onDisplayReady for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
IStatusBar bar = mBar;
if (bar != null) {
try {
@@ -703,6 +777,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
AppearanceRegion[] appearanceRegions, boolean navbarColorManagedByIme,
@Behavior int behavior, @InsetsType int requestedVisibleTypes,
String packageName, LetterboxDetails[] letterboxDetails) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping onSystemBarAttributesChanged for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
getUiState(displayId).setBarAttributes(appearance, appearanceRegions,
navbarColorManagedByIme, behavior, requestedVisibleTypes, packageName,
letterboxDetails);
@@ -719,6 +800,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
@Override
public void showTransient(int displayId, @InsetsType int types,
boolean isGestureOnSystemBar) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping showTransient for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
getUiState(displayId).showTransient(types);
IStatusBar bar = mBar;
if (bar != null) {
@@ -730,6 +818,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
@Override
public void abortTransient(int displayId, @InsetsType int types) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping abortTransient for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
getUiState(displayId).clearTransient(types);
IStatusBar bar = mBar;
if (bar != null) {
@@ -776,6 +871,15 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
@Override
public void setNavigationBarLumaSamplingEnabled(int displayId, boolean enable) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG,
+ "Skipping setNavigationBarLumaSamplingEnabled for visible background "
+ + "user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
IStatusBar bar = mBar;
if (bar != null) {
try {
@@ -1416,6 +1520,13 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
}
private void setDisableFlags(int displayId, int flags, String cause) {
+ if (isVisibleBackgroundUserOnDisplay(displayId)) {
+ if (SPEW) {
+ Slog.d(TAG, "Skipping setDisableFlags for visible background user "
+ + mUserManagerInternal.getUserAssignedToDisplay(displayId));
+ }
+ return;
+ }
// also allows calls from window manager which is in this process.
enforceStatusBarService();
@@ -2713,16 +2824,30 @@ public class StatusBarManagerService extends IStatusBarService.Stub implements D
if (callingUserId == USER_SYSTEM || callingUserId == mCurrentUserId) {
return;
}
- final long ident = Binder.clearCallingIdentity();
- try {
- if (mUserManager.isSameProfileGroup(callingUserId, mCurrentUserId)) {
- return;
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
+ if (!isVisibleBackgroundUser(callingUserId)) {
+ return;
}
throw new SecurityException("User " + callingUserId
+ " is not permitted to use this method");
}
-}
+
+ private boolean isVisibleBackgroundUser(int userId) {
+ if (!mVisibleBackgroundUsersEnabled) {
+ return false;
+ }
+ // The main use case for visible background users is the Automotive multi-display
+ // configuration where a passenger can use a secondary display while the driver is
+ // using the main display.
+ // TODO(b/341604160) - Support visible background users properly and remove carve outs
+ return mUserManagerInternal.isVisibleBackgroundFullUser(userId);
+ }
+
+ private boolean isVisibleBackgroundUserOnDisplay(int displayId) {
+ if (!mVisibleBackgroundUsersEnabled) {
+ return false;
+ }
+ int userId = mUserManagerInternal.getUserAssignedToDisplay(displayId);
+ return isVisibleBackgroundUser(userId);
+ }
+} \ No newline at end of file
diff --git a/services/core/java/com/android/server/vcn/routeselection/IpSecPacketLossDetector.java b/services/core/java/com/android/server/vcn/routeselection/IpSecPacketLossDetector.java
index 474253223628..5f704a002a33 100644
--- a/services/core/java/com/android/server/vcn/routeselection/IpSecPacketLossDetector.java
+++ b/services/core/java/com/android/server/vcn/routeselection/IpSecPacketLossDetector.java
@@ -276,7 +276,7 @@ public class IpSecPacketLossDetector extends NetworkMetricMonitor {
// enabled on the last one as a sample
mInboundTransform = inboundTransform;
- if (!Flags.allowDisableIpsecLossDetector() || canStart()) {
+ if (canStart()) {
start();
}
}
@@ -292,7 +292,7 @@ public class IpSecPacketLossDetector extends NetworkMetricMonitor {
mMaxSeqNumIncreasePerSecond = getMaxSeqNumIncreasePerSecond(carrierConfig);
}
- if (Flags.allowDisableIpsecLossDetector() && canStart() != isStarted()) {
+ if (canStart() != isStarted()) {
if (canStart()) {
start();
} else {
diff --git a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
index f53dda6ee35b..78359bd15717 100644
--- a/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
+++ b/services/core/java/com/android/server/wallpaper/WallpaperManagerService.java
@@ -2224,15 +2224,21 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
public ParcelFileDescriptor getWallpaperWithFeature(String callingPkg, String callingFeatureId,
IWallpaperManagerCallback cb, final int which, Bundle outParams, int wallpaperUserId,
boolean getCropped) {
- final boolean hasPrivilege = hasPermission(READ_WALLPAPER_INTERNAL)
- || hasPermission(MANAGE_EXTERNAL_STORAGE);
+ final int callingPid = Binder.getCallingPid();
+ final int callingUid = Binder.getCallingUid();
+ final boolean hasPrivilege = hasPermission(READ_WALLPAPER_INTERNAL);
if (!hasPrivilege) {
- mContext.getSystemService(StorageManager.class).checkPermissionReadImages(true,
- Binder.getCallingPid(), Binder.getCallingUid(), callingPkg, callingFeatureId);
+ boolean hasManageExternalStorage = hasPermission(MANAGE_EXTERNAL_STORAGE)
+ || hasAppOpPermission(MANAGE_EXTERNAL_STORAGE, callingUid, callingPkg,
+ callingFeatureId, "getWallpaperWithFeature from package: " + callingPkg);
+ if (!hasManageExternalStorage) {
+ mContext.getSystemService(StorageManager.class).checkPermissionReadImages(true,
+ callingPid, callingUid, callingPkg, callingFeatureId);
+ }
}
- wallpaperUserId = ActivityManager.handleIncomingUser(Binder.getCallingPid(),
- Binder.getCallingUid(), wallpaperUserId, false, true, "getWallpaper", null);
+ wallpaperUserId = ActivityManager.handleIncomingUser(callingPid, callingUid,
+ wallpaperUserId, false, true, "getWallpaper", null);
if (which != FLAG_SYSTEM && which != FLAG_LOCK) {
throw new IllegalArgumentException("Must specify exactly one kind of wallpaper to read");
@@ -2348,6 +2354,22 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
return mContext.checkCallingOrSelfPermission(permission) == PERMISSION_GRANTED;
}
+ private boolean hasAppOpPermission(String permission, int callingUid, String callingPackage,
+ String attributionTag, String message) {
+ final String op = AppOpsManager.permissionToOp(permission);
+ final int opMode = mAppOpsManager.noteOpNoThrow(op, callingUid, callingPackage,
+ attributionTag, message);
+ switch (opMode) {
+ case AppOpsManager.MODE_ALLOWED:
+ case AppOpsManager.MODE_FOREGROUND:
+ return true;
+ case AppOpsManager.MODE_DEFAULT:
+ return hasPermission(permission);
+ default:
+ return false;
+ }
+ }
+
@Override
public WallpaperInfo getWallpaperInfo(int userId) {
return getWallpaperInfoWithFlags(FLAG_SYSTEM, userId);
@@ -3169,7 +3191,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
final WallpaperDestinationChangeHandler
liveSync = new WallpaperDestinationChangeHandler(
newWallpaper);
- boolean same = changingToSame(name, newWallpaper);
+ boolean same = changingToSame(name, newWallpaper.connection,
+ newWallpaper.wallpaperComponent);
/*
* If we have a shared system+lock wallpaper, and we reapply the same wallpaper
@@ -3257,14 +3280,15 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
return name == null || name.equals(mDefaultWallpaperComponent);
}
- private boolean changingToSame(ComponentName componentName, WallpaperData wallpaper) {
- if (wallpaper.connection != null) {
- final ComponentName wallpaperName = wallpaper.wallpaperComponent;
- if (isDefaultComponent(componentName) && isDefaultComponent(wallpaperName)) {
+ private boolean changingToSame(ComponentName newComponentName,
+ WallpaperConnection currentConnection, ComponentName currentComponentName) {
+ if (currentConnection != null) {
+ if (isDefaultComponent(newComponentName) && isDefaultComponent(currentComponentName)) {
if (DEBUG) Slog.v(TAG, "changingToSame: still using default");
// Still using default wallpaper.
return true;
- } else if (wallpaperName != null && wallpaperName.equals(componentName)) {
+ } else if (currentComponentName != null && currentComponentName.equals(
+ newComponentName)) {
// Changing to same wallpaper.
if (DEBUG) Slog.v(TAG, "same wallpaper");
return true;
@@ -3279,7 +3303,8 @@ public class WallpaperManagerService extends IWallpaperManager.Stub
Slog.v(TAG, "bindWallpaperComponentLocked: componentName=" + componentName);
}
// Has the component changed?
- if (!force && changingToSame(componentName, wallpaper)) {
+ if (!force && changingToSame(componentName, wallpaper.connection,
+ wallpaper.wallpaperComponent)) {
try {
if (DEBUG_LIVE) {
Slog.v(TAG, "Changing to the same component, ignoring");
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 0be6471f189e..1dfa06300ace 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -2848,7 +2848,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
final boolean hasImeSurface;
if (mStartingData != null) {
if (mStartingData.mWaitForSyncTransactionCommit
- || mTransitionController.isCollecting(this)) {
+ || mSyncState != SYNC_STATE_NONE) {
mStartingData.mRemoveAfterTransaction = AFTER_TRANSACTION_REMOVE_DIRECTLY;
mStartingData.mPrepareRemoveAnimation = prepareAnimation;
return;
@@ -6079,9 +6079,10 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
return false;
}
- // Check if the activity is on a sleeping display, canTurnScreenOn will also check
- // keyguard visibility
- if (mDisplayContent.isSleeping()) {
+ // Check if the activity is on a sleeping display and keyguard is not going away (to
+ // align with TaskFragment#shouldSleepActivities), canTurnScreenOn will also check keyguard
+ // visibility
+ if (mDisplayContent.isSleeping() && !mDisplayContent.isKeyguardGoingAway()) {
return canTurnScreenOn();
} else {
return mTaskSupervisor.getKeyguardController().checkKeyguardVisibility(this);
diff --git a/services/core/java/com/android/server/wm/AppCompatAspectRatioPolicy.java b/services/core/java/com/android/server/wm/AppCompatAspectRatioPolicy.java
index b23e75a0fbc2..51ef87dcab1b 100644
--- a/services/core/java/com/android/server/wm/AppCompatAspectRatioPolicy.java
+++ b/services/core/java/com/android/server/wm/AppCompatAspectRatioPolicy.java
@@ -122,9 +122,12 @@ class AppCompatAspectRatioPolicy {
if (aspectRatioOverrides.shouldApplyUserMinAspectRatioOverride()) {
return aspectRatioOverrides.getUserMinAspectRatio();
}
+ final DisplayContent displayContent = mActivityRecord.getDisplayContent();
+ final boolean shouldOverrideMinAspectRatioForCamera = displayContent != null
+ && displayContent.mAppCompatCameraPolicy.shouldOverrideMinAspectRatioForCamera(
+ mActivityRecord);
if (!aspectRatioOverrides.shouldOverrideMinAspectRatio()
- && !mAppCompatOverrides.getAppCompatCameraOverrides()
- .shouldOverrideMinAspectRatioForCamera()) {
+ && !shouldOverrideMinAspectRatioForCamera) {
return info.getMinAspectRatio();
}
diff --git a/services/core/java/com/android/server/wm/AppCompatCameraOverrides.java b/services/core/java/com/android/server/wm/AppCompatCameraOverrides.java
index d8abf69b65af..241390c12818 100644
--- a/services/core/java/com/android/server/wm/AppCompatCameraOverrides.java
+++ b/services/core/java/com/android/server/wm/AppCompatCameraOverrides.java
@@ -85,9 +85,10 @@ class AppCompatCameraOverrides {
}
/**
- * Whether we should apply the min aspect ratio per-app override only when an app is connected
- * to the camera.
- * When this override is applied the min aspect ratio given in the app's manifest will be
+ * Whether applying the min aspect ratio per-app override only when an app is connected
+ * to the camera is allowed.
+ *
+ * <p>When this override is applied the min aspect ratio given in the app's manifest will be
* overridden to the largest enabled aspect ratio treatment unless the app's manifest value
* is higher. The treatment will also apply if no value is provided in the manifest.
*
@@ -97,9 +98,8 @@ class AppCompatCameraOverrides {
* <li>Per-app override is enabled
* </ul>
*/
- boolean shouldOverrideMinAspectRatioForCamera() {
- return isCameraActive() && mAllowMinAspectRatioOverrideOptProp
- .shouldEnableWithOptInOverrideAndOptOutProperty(
+ boolean isOverrideMinAspectRatioForCameraEnabled() {
+ return mAllowMinAspectRatioOverrideOptProp.shouldEnableWithOptInOverrideAndOptOutProperty(
isChangeEnabled(mActivityRecord,
OVERRIDE_MIN_ASPECT_RATIO_ONLY_FOR_CAMERA));
}
@@ -174,24 +174,6 @@ class AppCompatCameraOverrides {
OVERRIDE_CAMERA_COMPAT_DISABLE_FREEFORM_WINDOWING_TREATMENT);
}
- /**
- * @return {@code true} if the Camera is active for the current activity
- */
- boolean isCameraActive() {
- return mActivityRecord.mDisplayContent != null
- && mActivityRecord.mDisplayContent.mAppCompatCameraPolicy
- .isCameraActive(mActivityRecord, /* mustBeFullscreen */ true);
- }
-
- /**
- * @return {@code true} if the configuration needs to be recomputed after a camera state update.
- */
- boolean shouldRecomputeConfigurationForCameraCompat() {
- return isOverrideOrientationOnlyForCameraEnabled()
- || isCameraCompatSplitScreenAspectRatioAllowed()
- || shouldOverrideMinAspectRatioForCamera();
- }
-
boolean isOverrideOrientationOnlyForCameraEnabled() {
return isChangeEnabled(mActivityRecord, OVERRIDE_ORIENTATION_ONLY_FOR_CAMERA);
}
diff --git a/services/core/java/com/android/server/wm/AppCompatCameraPolicy.java b/services/core/java/com/android/server/wm/AppCompatCameraPolicy.java
index a42b8794b43d..67bfd7605128 100644
--- a/services/core/java/com/android/server/wm/AppCompatCameraPolicy.java
+++ b/services/core/java/com/android/server/wm/AppCompatCameraPolicy.java
@@ -166,6 +166,9 @@ class AppCompatCameraPolicy {
: SCREEN_ORIENTATION_UNSPECIFIED;
}
+ /**
+ * @return {@code true} if the Camera is active for the provided {@link ActivityRecord}.
+ */
boolean isCameraActive(@NonNull ActivityRecord activity, boolean mustBeFullscreen) {
return mDisplayRotationCompatPolicy != null
&& mDisplayRotationCompatPolicy.isCameraActive(activity, mustBeFullscreen);
@@ -179,4 +182,13 @@ class AppCompatCameraPolicy {
return null;
}
+ /**
+ * Whether we should apply the min aspect ratio per-app override only when an app is connected
+ * to the camera.
+ */
+ boolean shouldOverrideMinAspectRatioForCamera(@NonNull ActivityRecord activityRecord) {
+ return isCameraActive(activityRecord, /* mustBeFullscreen= */ true)
+ && activityRecord.mAppCompatController.getAppCompatCameraOverrides()
+ .isOverrideMinAspectRatioForCameraEnabled();
+ }
}
diff --git a/services/core/java/com/android/server/wm/AppCompatOrientationPolicy.java b/services/core/java/com/android/server/wm/AppCompatOrientationPolicy.java
index c5506de419d0..7477c6272d89 100644
--- a/services/core/java/com/android/server/wm/AppCompatOrientationPolicy.java
+++ b/services/core/java/com/android/server/wm/AppCompatOrientationPolicy.java
@@ -58,13 +58,16 @@ class AppCompatOrientationPolicy {
&& displayContent.getIgnoreOrientationRequest();
final boolean shouldApplyUserFullscreenOverride = mAppCompatOverrides
.getAppCompatAspectRatioOverrides().shouldApplyUserFullscreenOverride();
+ final boolean isCameraActive = displayContent != null
+ && displayContent.mAppCompatCameraPolicy.isCameraActive(mActivityRecord,
+ /* mustBeFullscreen */ true);
if (shouldApplyUserFullscreenOverride && isIgnoreOrientationRequestEnabled
// Do not override orientation to fullscreen for camera activities.
// Fixed-orientation activities are rarely tested in other orientations, and it
// often results in sideways or stretched previews. As the camera compat treatment
// targets fixed-orientation activities, overriding the orientation disables the
// treatment.
- && !mAppCompatOverrides.getAppCompatCameraOverrides().isCameraActive()) {
+ && !isCameraActive) {
Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate)
+ " for " + mActivityRecord + " is overridden to "
+ screenOrientationToString(SCREEN_ORIENTATION_USER)
@@ -110,7 +113,7 @@ class AppCompatOrientationPolicy {
// often results in sideways or stretched previews. As the camera compat treatment
// targets fixed-orientation activities, overriding the orientation disables the
// treatment.
- && !mAppCompatOverrides.getAppCompatCameraOverrides().isCameraActive()) {
+ && !isCameraActive) {
Slog.v(TAG, "Requested orientation " + screenOrientationToString(candidate)
+ " for " + mActivityRecord + " is overridden to "
+ screenOrientationToString(SCREEN_ORIENTATION_USER));
diff --git a/services/core/java/com/android/server/wm/BackNavigationController.java b/services/core/java/com/android/server/wm/BackNavigationController.java
index 4e4616dcaa3f..0646fb74ddfd 100644
--- a/services/core/java/com/android/server/wm/BackNavigationController.java
+++ b/services/core/java/com/android/server/wm/BackNavigationController.java
@@ -1072,8 +1072,10 @@ class BackNavigationController {
return close.asWindowState() != null;
}
- private void initiate(@NonNull WindowContainer close, @NonNull WindowContainer[] open,
+ private void initiate(ScheduleAnimationBuilder builder,
@NonNull ActivityRecord[] openingActivities) {
+ WindowContainer close = builder.mCloseTarget;
+ WindowContainer[] open = builder.mOpenTargets;
if (isActivitySwitch(close, open)) {
mSwitchType = ACTIVITY_SWITCH;
if (Flags.migratePredictiveBackTransition()) {
@@ -1091,9 +1093,17 @@ class BackNavigationController {
return;
}
- mCloseAdaptor = createAdaptor(close, false, mSwitchType);
+ final Transition prepareTransition = builder.prepareTransitionIfNeeded(
+ openingActivities);
+ final SurfaceControl.Transaction st = openingActivities[0].getSyncTransaction();
+ final SurfaceControl.Transaction ct = prepareTransition != null
+ ? st : close.getPendingTransaction();
+ mCloseAdaptor = createAdaptor(close, false, mSwitchType, ct);
if (mCloseAdaptor.mAnimationTarget == null) {
Slog.w(TAG, "composeNewAnimations fail, skip");
+ if (prepareTransition != null) {
+ prepareTransition.abort();
+ }
clearBackAnimateTarget(true /* cancel */);
return;
}
@@ -1110,12 +1120,17 @@ class BackNavigationController {
next.getWindowConfiguration().getRotation());
}
}
- mOpenAnimAdaptor = new BackWindowAnimationAdaptorWrapper(true, mSwitchType, open);
+ mOpenAnimAdaptor = new BackWindowAnimationAdaptorWrapper(
+ true, mSwitchType, st, open);
if (!mOpenAnimAdaptor.isValid()) {
Slog.w(TAG, "compose animations fail, skip");
+ if (prepareTransition != null) {
+ prepareTransition.abort();
+ }
clearBackAnimateTarget(true /* cancel */);
return;
}
+ mOpenAnimAdaptor.mPreparedOpenTransition = prepareTransition;
mOpenActivities = openingActivities;
}
@@ -1147,19 +1162,21 @@ class BackNavigationController {
return new Pair<>(replaceClose, replaceOpen);
}
- private boolean composeAnimations(@NonNull WindowContainer close,
- @NonNull WindowContainer[] open, @NonNull ActivityRecord[] openingActivities) {
+ private boolean composeAnimations(@NonNull ScheduleAnimationBuilder builder,
+ @NonNull ActivityRecord[] openingActivities) {
if (mComposed || mWaitTransition) {
Slog.e(TAG, "Previous animation is running " + this);
return false;
}
clearBackAnimateTarget(true /* cancel */);
- if (close == null || open == null || open.length == 0 || open.length > 2) {
+ final WindowContainer[] open = builder.mOpenTargets;
+ if (builder.mCloseTarget == null || open == null || open.length == 0
+ || open.length > 2) {
Slog.e(TAG, "reset animation with null target close: "
- + close + " open: " + Arrays.toString(open));
+ + builder.mCloseTarget + " open: " + Arrays.toString(open));
return false;
}
- initiate(close, open, openingActivities);
+ initiate(builder, openingActivities);
if (mSwitchType == UNKNOWN) {
return false;
}
@@ -1384,10 +1401,10 @@ class BackNavigationController {
}
@NonNull private static BackWindowAnimationAdaptor createAdaptor(
- @NonNull WindowContainer target, boolean isOpen, int switchType) {
+ @NonNull WindowContainer target, boolean isOpen, int switchType,
+ SurfaceControl.Transaction st) {
final BackWindowAnimationAdaptor adaptor =
new BackWindowAnimationAdaptor(target, isOpen, switchType);
- final SurfaceControl.Transaction pt = target.getPendingTransaction();
// Workaround to show TaskFragment which can be hide in Transitions and won't show
// during isAnimating.
if (isOpen && target.asActivityRecord() != null) {
@@ -1395,10 +1412,10 @@ class BackNavigationController {
if (fragment != null) {
// Ensure task fragment surface has updated, in case configuration has changed.
fragment.updateOrganizedTaskFragmentSurface();
- pt.show(fragment.mSurfaceControl);
+ st.show(fragment.mSurfaceControl);
}
}
- target.startAnimation(pt, adaptor, false /* hidden */, ANIMATION_TYPE_PREDICT_BACK);
+ target.startAnimation(st, adaptor, false /* hidden */, ANIMATION_TYPE_PREDICT_BACK);
return adaptor;
}
@@ -1417,12 +1434,12 @@ class BackNavigationController {
private Transition mPreparedOpenTransition;
BackWindowAnimationAdaptorWrapper(boolean isOpen, int switchType,
- @NonNull WindowContainer... targets) {
+ SurfaceControl.Transaction st, @NonNull WindowContainer... targets) {
mAdaptors = new BackWindowAnimationAdaptor[targets.length];
for (int i = targets.length - 1; i >= 0; --i) {
- mAdaptors[i] = createAdaptor(targets[i], isOpen, switchType);
+ mAdaptors[i] = createAdaptor(targets[i], isOpen, switchType, st);
}
- mRemoteAnimationTarget = targets.length > 1 ? createWrapTarget()
+ mRemoteAnimationTarget = targets.length > 1 ? createWrapTarget(st)
: mAdaptors[0].mAnimationTarget;
}
@@ -1448,7 +1465,7 @@ class BackNavigationController {
mPreparedOpenTransition = null;
}
- private RemoteAnimationTarget createWrapTarget() {
+ private RemoteAnimationTarget createWrapTarget(SurfaceControl.Transaction st) {
// Special handle for opening two activities together.
// If we animate both activities separately, the animation area and rounded corner
// would also being handled separately. To make them seem like "open" together, wrap
@@ -1470,12 +1487,11 @@ class BackNavigationController {
.build();
mCloseTransaction = new SurfaceControl.Transaction();
mCloseTransaction.reparent(leashSurface, null);
- final SurfaceControl.Transaction pt = wc.getPendingTransaction();
- pt.setLayer(leashSurface, wc.getLastLayer());
+ st.setLayer(leashSurface, wc.getLastLayer());
for (int i = mAdaptors.length - 1; i >= 0; --i) {
BackWindowAnimationAdaptor adaptor = mAdaptors[i];
- pt.reparent(adaptor.mAnimationTarget.leash, leashSurface);
- pt.setPosition(adaptor.mAnimationTarget.leash,
+ st.reparent(adaptor.mAnimationTarget.leash, leashSurface);
+ st.setPosition(adaptor.mAnimationTarget.leash,
adaptor.mAnimationTarget.localBounds.left,
adaptor.mAnimationTarget.localBounds.top);
// For adjacent activity embedded, reparent Activity to TaskFragment when
@@ -1738,6 +1754,7 @@ class BackNavigationController {
WindowContainer mCloseTarget;
WindowContainer[] mOpenTargets;
boolean mIsLaunchBehind;
+ TaskSnapshot mSnapshot;
ScheduleAnimationBuilder(int type, BackAnimationAdapter adapter,
NavigationMonitor monitor) {
@@ -1771,6 +1788,13 @@ class BackNavigationController {
return wc == mCloseTarget || mCloseTarget.hasChild(wc) || wc.hasChild(mCloseTarget);
}
+ private Transition prepareTransitionIfNeeded(ActivityRecord[] visibleOpenActivities) {
+ if (mSnapshot == null) {
+ return setLaunchBehind(visibleOpenActivities);
+ }
+ return null;
+ }
+
/**
* Apply preview strategy on the opening target
*
@@ -1780,26 +1804,17 @@ class BackNavigationController {
private void applyPreviewStrategy(
@NonNull BackWindowAnimationAdaptorWrapper openAnimationAdaptor,
@NonNull ActivityRecord[] visibleOpenActivities) {
- boolean needsLaunchBehind = true;
if (isSupportWindowlessSurface() && mShowWindowlessSurface && !mIsLaunchBehind) {
boolean activitiesAreDrawn = false;
for (int i = visibleOpenActivities.length - 1; i >= 0; --i) {
// If the activity hasn't stopped, it's window should remain drawn.
activitiesAreDrawn |= visibleOpenActivities[i].firstWindowDrawn;
}
- final WindowContainer mainOpen = openAnimationAdaptor.mAdaptors[0].mTarget;
- final TaskSnapshot snapshot = getSnapshot(mainOpen, visibleOpenActivities);
// Don't create starting surface if previous activities haven't stopped or
// the snapshot does not exist.
- if (snapshot != null || !activitiesAreDrawn) {
- openAnimationAdaptor.createStartingSurface(snapshot);
+ if (mSnapshot != null || !activitiesAreDrawn) {
+ openAnimationAdaptor.createStartingSurface(mSnapshot);
}
- // Only use LaunchBehind if snapshot does not exist.
- needsLaunchBehind = snapshot == null;
- }
- if (needsLaunchBehind) {
- openAnimationAdaptor.mPreparedOpenTransition =
- setLaunchBehind(visibleOpenActivities);
}
// Force update mLastSurfaceShowing for opening activity and its task.
if (mWindowManagerService.mRoot.mTransitionController.isShellTransitionsEnabled()) {
@@ -1821,7 +1836,11 @@ class BackNavigationController {
return null;
}
- if (!composeAnimations(mCloseTarget, mOpenTargets, openingActivities)) {
+ if (!shouldLaunchBehind && mShowWindowlessSurface) {
+ mSnapshot = getSnapshot(mOpenTargets[0], openingActivities);
+ }
+
+ if (!composeAnimations(this, openingActivities)) {
return null;
}
mCloseTarget.mTransitionController.mSnapshotController
diff --git a/services/core/java/com/android/server/wm/DesktopAppCompatAspectRatioPolicy.java b/services/core/java/com/android/server/wm/DesktopAppCompatAspectRatioPolicy.java
index ff1742b70edc..192469183a54 100644
--- a/services/core/java/com/android/server/wm/DesktopAppCompatAspectRatioPolicy.java
+++ b/services/core/java/com/android/server/wm/DesktopAppCompatAspectRatioPolicy.java
@@ -198,9 +198,11 @@ public class DesktopAppCompatAspectRatioPolicy {
return aspectRatioOverrides.getUserMinAspectRatio();
}
+ final DisplayContent dc = task.mDisplayContent;
+ final boolean shouldOverrideMinAspectRatioForCamera = dc != null
+ && dc.mAppCompatCameraPolicy.shouldOverrideMinAspectRatioForCamera(mActivityRecord);
if (!aspectRatioOverrides.shouldOverrideMinAspectRatio()
- && !mAppCompatOverrides.getAppCompatCameraOverrides()
- .shouldOverrideMinAspectRatioForCamera()) {
+ && !shouldOverrideMinAspectRatioForCamera) {
return info.getMinAspectRatio();
}
diff --git a/services/core/java/com/android/server/wm/Dimmer.java b/services/core/java/com/android/server/wm/Dimmer.java
index 2d1eb419a0bf..c5643ea54623 100644
--- a/services/core/java/com/android/server/wm/Dimmer.java
+++ b/services/core/java/com/android/server/wm/Dimmer.java
@@ -55,7 +55,7 @@ class Dimmer {
SurfaceControl mDimSurface;
final WindowContainer<?> mHostContainer;
// The last container to request to dim
- private WindowContainer<?> mLastRequestedDimContainer;
+ private WindowState mLastDimmingWindow;
/** Animation */
private final DimmerAnimationHelper mAnimationHelper;
boolean mSkipAnimation = false;
@@ -129,8 +129,8 @@ class Dimmer {
* Set the parameters to prepare the dim to be relative parented to the dimming container
*/
void prepareReparent(@NonNull WindowContainer<?> geometryParent,
- @NonNull WindowContainer<?> relativeParent, int relativeLayer) {
- mAnimationHelper.setRequestedRelativeParent(relativeParent, relativeLayer);
+ @NonNull WindowState relativeParent) {
+ mAnimationHelper.setRequestedRelativeParent(relativeParent);
mAnimationHelper.setRequestedGeometryParent(geometryParent);
}
@@ -146,7 +146,7 @@ class Dimmer {
* Whether anyone is currently requesting the dim
*/
boolean isDimming() {
- return mLastRequestedDimContainer != null
+ return mLastDimmingWindow != null
&& (mHostContainer.isVisibleRequested() || !Flags.useTasksDimOnly());
}
@@ -186,7 +186,7 @@ class Dimmer {
*/
void resetDimStates() {
if (mDimState != null) {
- mDimState.mLastRequestedDimContainer = null;
+ mDimState.mLastDimmingWindow = null;
}
}
@@ -200,7 +200,7 @@ class Dimmer {
* @param alpha Dim amount
* @param blurRadius Blur amount
*/
- protected void adjustAppearance(@NonNull WindowContainer<?> dimmingContainer,
+ protected void adjustAppearance(@NonNull WindowState dimmingContainer,
float alpha, int blurRadius) {
final DimState d = obtainDimState(dimmingContainer);
d.prepareLookChange(alpha, blurRadius);
@@ -218,14 +218,13 @@ class Dimmer {
* continue dimming. Indeed, this method won't be able to keep dimming or get a new DimState
* without also adjusting the appearance.
* @param geometryParent The container that defines the geometry of the dim
- * @param dimmingContainer The container which to dim above. Should be a child of the host.
- * @param relativeLayer The position of the dim wrt the container
+ * @param dimmingContainer The container that is dimming. The dim layer will be rel-z
+ * parented below it
*/
public void adjustPosition(@NonNull WindowContainer<?> geometryParent,
- @NonNull WindowContainer<?> dimmingContainer,
- int relativeLayer) {
+ @NonNull WindowState dimmingContainer) {
if (mDimState != null) {
- mDimState.prepareReparent(geometryParent, dimmingContainer, relativeLayer);
+ mDimState.prepareReparent(geometryParent, dimmingContainer);
}
}
@@ -250,9 +249,9 @@ class Dimmer {
if (!Flags.useTasksDimOnly()) {
mDimState.adjustSurfaceLayout(t);
}
- final WindowState ws = mDimState.mLastRequestedDimContainer.asWindowState();
- if (!mDimState.mIsVisible && ws != null && ws.mActivityRecord != null
- && ws.mActivityRecord.mStartingData != null) {
+ if (!mDimState.mIsVisible && mDimState.mLastDimmingWindow != null
+ && mDimState.mLastDimmingWindow.mActivityRecord != null
+ && mDimState.mLastDimmingWindow.mActivityRecord.mStartingData != null) {
// Skip enter animation while starting window is on top of its activity
mDimState.mSkipAnimation = true;
}
@@ -262,11 +261,11 @@ class Dimmer {
}
@NonNull
- private DimState obtainDimState(@NonNull WindowContainer<?> container) {
+ private DimState obtainDimState(@NonNull WindowState window) {
if (mDimState == null) {
mDimState = new DimState();
}
- mDimState.mLastRequestedDimContainer = container;
+ mDimState.mLastDimmingWindow = window;
return mDimState;
}
diff --git a/services/core/java/com/android/server/wm/DimmerAnimationHelper.java b/services/core/java/com/android/server/wm/DimmerAnimationHelper.java
index 4abf80618f6c..faf6dc667916 100644
--- a/services/core/java/com/android/server/wm/DimmerAnimationHelper.java
+++ b/services/core/java/com/android/server/wm/DimmerAnimationHelper.java
@@ -48,9 +48,8 @@ public class DimmerAnimationHelper {
static class Change {
private float mAlpha = -1f;
private int mBlurRadius = -1;
- private WindowContainer<?> mDimmingContainer = null;
+ private WindowState mDimmingContainer = null;
private WindowContainer<?> mGeometryParent = null;
- private int mRelativeLayer = -1;
private static final float EPSILON = 0.0001f;
Change() {}
@@ -64,7 +63,6 @@ public class DimmerAnimationHelper {
mBlurRadius = other.mBlurRadius;
mDimmingContainer = other.mDimmingContainer;
mGeometryParent = other.mGeometryParent;
- mRelativeLayer = other.mRelativeLayer;
}
// Same alpha and blur
@@ -84,7 +82,7 @@ public class DimmerAnimationHelper {
@Override
public String toString() {
return "Dim state: alpha=" + mAlpha + ", blur=" + mBlurRadius + ", container="
- + mDimmingContainer + ", relativePosition=" + mRelativeLayer;
+ + mDimmingContainer + ", geometryParent " + mGeometryParent;
}
}
@@ -100,14 +98,13 @@ public class DimmerAnimationHelper {
}
void setExitParameters() {
- setRequestedRelativeParent(mRequestedProperties.mDimmingContainer, -1 /* relativeLayer */);
+ setRequestedRelativeParent(mRequestedProperties.mDimmingContainer);
setRequestedAppearance(0f /* alpha */, 0 /* blur */);
}
// Sets a requested change without applying it immediately
- void setRequestedRelativeParent(@NonNull WindowContainer<?> relativeParent, int relativeLayer) {
+ void setRequestedRelativeParent(@NonNull WindowState relativeParent) {
mRequestedProperties.mDimmingContainer = relativeParent;
- mRequestedProperties.mRelativeLayer = relativeLayer;
}
// Sets the requested layer to reparent the dim to without applying it immediately
@@ -124,7 +121,7 @@ public class DimmerAnimationHelper {
/**
* Commit the last changes we received. Called after
* {@link Change#setExitParameters()},
- * {@link Change#setRequestedRelativeParent(WindowContainer, int)}, or
+ * {@link Change#setRequestedRelativeParent(WindowContainer)}, or
* {@link Change#setRequestedAppearance(float, int)}
*/
void applyChanges(@NonNull SurfaceControl.Transaction t, @NonNull Dimmer.DimState dim) {
@@ -147,8 +144,8 @@ public class DimmerAnimationHelper {
reparent(dim.mDimSurface,
startProperties.mGeometryParent != mRequestedProperties.mGeometryParent
? mRequestedProperties.mGeometryParent.getSurfaceControl() : null,
- mRequestedProperties.mDimmingContainer.getSurfaceControl(),
- mRequestedProperties.mRelativeLayer, t);
+ mRequestedProperties.mDimmingContainer != startProperties.mDimmingContainer
+ ? mRequestedProperties.mDimmingContainer.getSurfaceControl() : null, t);
if (!startProperties.hasSameVisualProperties(mRequestedProperties)) {
stopCurrentAnimation(dim.mDimSurface);
@@ -187,9 +184,11 @@ public class DimmerAnimationHelper {
mLocalAnimationAdapter.startAnimation(dim.mDimSurface, t,
ANIMATION_TYPE_DIMMER, /* finishCallback */ (type, animator) -> {
synchronized (dim.mHostContainer.mWmService.mGlobalLock) {
- setCurrentAlphaBlur(dim.mDimSurface, t);
+ SurfaceControl.Transaction finishTransaction =
+ dim.mHostContainer.getSyncTransaction();
+ setCurrentAlphaBlur(dim.mDimSurface, finishTransaction);
if (targetAlpha == 0f && !dim.isDimming()) {
- dim.remove(t);
+ dim.remove(finishTransaction);
}
mLocalAnimationAdapter = null;
mAlphaAnimationSpec = null;
@@ -232,14 +231,15 @@ public class DimmerAnimationHelper {
*/
static void reparent(@NonNull SurfaceControl dimLayer,
@Nullable SurfaceControl newGeometryParent,
- @NonNull SurfaceControl relativeParent,
- int relativePosition,
+ @Nullable SurfaceControl newRelativeParent,
@NonNull SurfaceControl.Transaction t) {
try {
if (newGeometryParent != null) {
t.reparent(dimLayer, newGeometryParent);
}
- t.setRelativeLayer(dimLayer, relativeParent, relativePosition);
+ if (newRelativeParent != null) {
+ t.setRelativeLayer(dimLayer, newRelativeParent, -1);
+ }
} catch (NullPointerException e) {
Log.w(TAG, "Tried to change parent of dim " + dimLayer + " after remove", e);
}
@@ -256,10 +256,13 @@ public class DimmerAnimationHelper {
private static long getDimDuration(@NonNull WindowContainer<?> container) {
// Use the same duration as the animation on the WindowContainer
- AnimationAdapter animationAdapter = container.mSurfaceAnimator.getAnimation();
- final float durationScale = container.mWmService.getTransitionAnimationScaleLocked();
- return animationAdapter == null ? (long) (DEFAULT_DIM_ANIM_DURATION_MS * durationScale)
- : animationAdapter.getDurationHint();
+ if (container.mSurfaceAnimator != null) {
+ AnimationAdapter animationAdapter = container.mSurfaceAnimator.getAnimation();
+ final float durationScale = container.mWmService.getTransitionAnimationScaleLocked();
+ return animationAdapter == null ? (long) (DEFAULT_DIM_ANIM_DURATION_MS * durationScale)
+ : animationAdapter.getDurationHint();
+ }
+ return 0;
}
/**
diff --git a/services/core/java/com/android/server/wm/DisplayPolicy.java b/services/core/java/com/android/server/wm/DisplayPolicy.java
index 107d31e4e25c..0fa1a2138e35 100644
--- a/services/core/java/com/android/server/wm/DisplayPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayPolicy.java
@@ -2517,7 +2517,7 @@ public class DisplayPolicy {
if (getStatusBar() != null) {
final StatusBarManagerInternal statusBar = getStatusBarManagerInternal();
if (statusBar != null) {
- statusBar.setTopAppHidesStatusBar(topAppHidesStatusBar);
+ statusBar.setTopAppHidesStatusBar(getDisplayId(), topAppHidesStatusBar);
}
}
@@ -2544,9 +2544,9 @@ public class DisplayPolicy {
mService.mPolicy.isUserSetupComplete(),
isNavBarEmpty(disableFlags));
} else {
- // TODO (b/277290737): Move this to the client side, instead of using a proxy.
- callStatusBarSafely(statusBar -> statusBar.immersiveModeChanged(rootDisplayAreaId,
- isImmersiveMode));
+ // TODO(b/277290737): Move this to the client side, instead of using a proxy.
+ callStatusBarSafely(statusBar -> statusBar.immersiveModeChanged(getDisplayId(),
+ rootDisplayAreaId, isImmersiveMode));
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayRotation.java b/services/core/java/com/android/server/wm/DisplayRotation.java
index 5200e820fc02..8c06cfecdc40 100644
--- a/services/core/java/com/android/server/wm/DisplayRotation.java
+++ b/services/core/java/com/android/server/wm/DisplayRotation.java
@@ -81,7 +81,6 @@ import android.window.WindowContainerTransaction;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.protolog.ProtoLog;
-import com.android.server.LocalServices;
import com.android.server.UiThread;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.statusbar.StatusBarManagerInternal;
@@ -136,7 +135,6 @@ public class DisplayRotation {
private final RotationLockHistory mRotationLockHistory = new RotationLockHistory();
private OrientationListener mOrientationListener;
- private StatusBarManagerInternal mStatusBarManagerInternal;
private SettingsObserver mSettingsObserver;
@NonNull
private final DeviceStateController mDeviceStateController;
@@ -1559,11 +1557,9 @@ public class DisplayRotation {
/** Notify the StatusBar that system rotation suggestion has changed. */
private void sendProposedRotationChangeToStatusBarInternal(int rotation, boolean isValid) {
- if (mStatusBarManagerInternal == null) {
- mStatusBarManagerInternal = LocalServices.getService(StatusBarManagerInternal.class);
- }
- if (mStatusBarManagerInternal != null) {
- mStatusBarManagerInternal.onProposedRotationChanged(rotation, isValid);
+ final StatusBarManagerInternal bar = mDisplayPolicy.getStatusBarManagerInternal();
+ if (bar != null) {
+ bar.onProposedRotationChanged(mDisplayContent.getDisplayId(), rotation, isValid);
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java b/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java
index 27d97677bb13..efc38439bfcf 100644
--- a/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java
+++ b/services/core/java/com/android/server/wm/DisplayRotationCompatPolicy.java
@@ -408,9 +408,26 @@ final class DisplayRotationCompatPolicy implements CameraStateMonitor.CameraComp
private void recomputeConfigurationForCameraCompatIfNeeded(
@NonNull ActivityRecord activityRecord) {
- if (activityRecord.mAppCompatController.getAppCompatCameraOverrides()
- .shouldRecomputeConfigurationForCameraCompat()) {
+ if (shouldRecomputeConfigurationForCameraCompat(activityRecord)) {
activityRecord.recomputeConfiguration();
}
}
+
+ /**
+ * @return {@code true} if the configuration needs to be recomputed after a camera state update.
+ */
+ private boolean shouldRecomputeConfigurationForCameraCompat(
+ @NonNull ActivityRecord activityRecord) {
+ final AppCompatCameraOverrides overrides = activityRecord.mAppCompatController
+ .getAppCompatCameraOverrides();
+ return overrides.isOverrideOrientationOnlyForCameraEnabled()
+ || overrides.isCameraCompatSplitScreenAspectRatioAllowed()
+ || shouldOverrideMinAspectRatio(activityRecord);
+ }
+
+ private boolean shouldOverrideMinAspectRatio(@NonNull ActivityRecord activityRecord) {
+ return activityRecord.mAppCompatController.getAppCompatCameraOverrides()
+ .isOverrideMinAspectRatioForCameraEnabled()
+ && isCameraActive(activityRecord, /* mustBeFullscreen= */ true);
+ }
}
diff --git a/services/core/java/com/android/server/wm/LockTaskController.java b/services/core/java/com/android/server/wm/LockTaskController.java
index 0dadade38ddb..e65396e00b20 100644
--- a/services/core/java/com/android/server/wm/LockTaskController.java
+++ b/services/core/java/com/android/server/wm/LockTaskController.java
@@ -659,7 +659,7 @@ public class LockTaskController {
StatusBarManagerInternal statusBarManager = LocalServices.getService(
StatusBarManagerInternal.class);
if (statusBarManager != null) {
- statusBarManager.showScreenPinningRequest(task.mTaskId);
+ statusBarManager.showScreenPinningRequest(task.mTaskId, task.mUserId);
}
return;
} else if (mLockTaskModeState == LOCK_TASK_MODE_PINNED) {
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index 8c93b4fe447c..3bb273c55f55 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -3192,13 +3192,6 @@ class Task extends TaskFragment {
return "Task=" + mTaskId;
}
- WindowContainer<?> getDimmerParent() {
- if (!inMultiWindowMode() && isTranslucentForTransition()) {
- return getRootDisplayArea();
- }
- return this;
- }
-
@Deprecated
@Override
Dimmer getDimmer() {
@@ -3222,6 +3215,13 @@ class Task extends TaskFragment {
return mDimmer;
}
+ boolean isSuitableForDimming() {
+ // If the window is in multi-window mode, we want to dim at the Task level to ensure the dim
+ // bounds match the area the app lives in.
+ // If translucent, we will move the dim to the display area
+ return inMultiWindowMode() || !isTranslucentAndVisible();
+ }
+
@Override
void prepareSurfaces() {
mDimmer.resetDimStates();
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java
index e6226ab6786d..366cf4d039b8 100644
--- a/services/core/java/com/android/server/wm/Transition.java
+++ b/services/core/java/com/android/server/wm/Transition.java
@@ -73,6 +73,7 @@ import static com.android.server.wm.ActivityTaskManagerInternal.APP_TRANSITION_W
import static com.android.server.wm.SurfaceAnimator.ANIMATION_TYPE_PREDICT_BACK;
import static com.android.server.wm.WindowContainer.AnimationFlags.PARENTS;
import static com.android.server.wm.WindowState.BLAST_TIMEOUT_DURATION;
+import static com.android.window.flags.Flags.enableDisplayFocusInShellTransitions;
import android.annotation.IntDef;
import android.annotation.NonNull;
@@ -223,6 +224,13 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
private final ArrayList<Task> mOnTopTasksAtReady = new ArrayList<>();
/**
+ * Tracks the top display like top tasks so we can trigger a MOVED_TO_TOP transition even when
+ * a display gets moved to front but there's no change in per-display focused tasks.
+ */
+ private DisplayContent mOnTopDisplayStart = null;
+ private DisplayContent mOnTopDisplayAtReady = null;
+
+ /**
* Set of participating windowtokens (activity/wallpaper) which are visible at the end of
* the transition animation.
*/
@@ -484,12 +492,8 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
boolean canApplyDim(@NonNull Task task) {
if (mTransientLaunches == null) return true;
if (Flags.useTasksDimOnly()) {
- WindowContainer<?> dimmerParent = task.getDimmerParent();
- if (dimmerParent == null) {
- return false;
- }
- // Always allow to dim if the host only affects its task.
- if (dimmerParent.asTask() == task) {
+ if (task.isSuitableForDimming()) {
+ // Always allow to dim if the dimming occurs at task level (dim parented to task)
return true;
}
} else {
@@ -772,6 +776,10 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
if (dc == null || mTargetDisplays.contains(dc)) return;
mTargetDisplays.add(dc);
addOnTopTasks(dc, mOnTopTasksStart);
+ if (mOnTopDisplayStart == null) {
+ mOnTopDisplayStart =
+ mController.mAtm.mRootWindowContainer.getTopFocusedDisplayContent();
+ }
// Handle the case {transition.start(); applyTransaction(wct);} that the animating state
// is set before collecting participants.
if (mController.isAnimating()) {
@@ -995,6 +1003,8 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
for (int i = 0; i < mTargetDisplays.size(); ++i) {
addOnTopTasks(mTargetDisplays.get(i), mOnTopTasksAtReady);
}
+ mOnTopDisplayAtReady =
+ mController.mAtm.mRootWindowContainer.getTopFocusedDisplayContent();
mController.onTransitionPopulated(this);
}
}
@@ -2079,6 +2089,10 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
return true;
}
}
+ if (enableDisplayFocusInShellTransitions() && mOnTopDisplayStart
+ != mController.mAtm.mRootWindowContainer.getTopFocusedDisplayContent()) {
+ return true;
+ }
return false;
}
@@ -2110,6 +2124,8 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
includesOrderChange = true;
break;
}
+ includesOrderChange |= enableDisplayFocusInShellTransitions()
+ && mOnTopDisplayStart != mOnTopDisplayAtReady;
if (!includesOrderChange && !reportCurrent) {
// This transition doesn't include an order change, so if it isn't required to report
// the current focus (eg. it's the last of a cluster of transitions), then don't
@@ -2120,6 +2136,8 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
// latest state and compare with the last reported state (or our start state if no
// reported state exists).
ArrayList<Task> onTopTasksEnd = new ArrayList<>();
+ final DisplayContent onTopDisplayEnd =
+ mController.mAtm.mRootWindowContainer.getTopFocusedDisplayContent();
for (int d = 0; d < mTargetDisplays.size(); ++d) {
addOnTopTasks(mTargetDisplays.get(d), onTopTasksEnd);
final int displayId = mTargetDisplays.get(d).mDisplayId;
@@ -2127,11 +2145,15 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
for (int i = onTopTasksEnd.size() - 1; i >= 0; --i) {
final Task task = onTopTasksEnd.get(i);
if (task.getDisplayId() != displayId) continue;
- // If it didn't change since last report, don't report
- if (reportedOnTop == null) {
- if (mOnTopTasksStart.contains(task)) continue;
- } else if (reportedOnTop.contains(task)) {
- continue;
+ if (!enableDisplayFocusInShellTransitions()
+ || mOnTopDisplayStart == onTopDisplayEnd
+ || displayId != onTopDisplayEnd.mDisplayId) {
+ // If it didn't change since last report, don't report
+ if (reportedOnTop == null) {
+ if (mOnTopTasksStart.contains(task)) continue;
+ } else if (reportedOnTop.contains(task)) {
+ continue;
+ }
}
// Need to report it.
mParticipants.add(task);
@@ -2333,10 +2355,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
// Place the nav bar on top of anything else in the top activity.
t.setLayer(navSurfaceControl, Integer.MAX_VALUE);
}
- final StatusBarManagerInternal bar = dc.getDisplayPolicy().getStatusBarManagerInternal();
- if (bar != null) {
- bar.setNavigationBarLumaSamplingEnabled(mRecentsDisplayId, false);
- }
+ sendLumaSamplingEnabledToStatusBarInternal(dc, false);
}
/** @see RecentsAnimationController#restoreNavigationBarFromApp */
@@ -2354,10 +2373,7 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
final DisplayContent dc =
mController.mAtm.mRootWindowContainer.getDisplayContent(recentsDisplayId);
- final StatusBarManagerInternal bar = dc.getDisplayPolicy().getStatusBarManagerInternal();
- if (bar != null) {
- bar.setNavigationBarLumaSamplingEnabled(recentsDisplayId, true);
- }
+ sendLumaSamplingEnabledToStatusBarInternal(dc, true);
final WindowState navWindow = dc.getDisplayPolicy().getNavigationBar();
if (navWindow == null) return;
navWindow.setSurfaceTranslationY(0);
@@ -2391,6 +2407,14 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
dc.mWmService.scheduleAnimationLocked();
}
+ private void sendLumaSamplingEnabledToStatusBarInternal(@NonNull DisplayContent dc,
+ boolean enabled) {
+ final StatusBarManagerInternal bar = dc.getDisplayPolicy().getStatusBarManagerInternal();
+ if (bar != null) {
+ bar.setNavigationBarLumaSamplingEnabled(dc.getDisplayId(), enabled);
+ }
+ }
+
private void reportStartReasonsToLogger() {
// Record transition start in metrics logger. We just assume everything is "DRAWN"
// at this point since splash-screen is a presentation (shell) detail.
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index fb57a1bb94c1..459a509a3b3c 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -90,6 +90,7 @@ import static android.view.WindowManager.LayoutParams.TYPE_WALLPAPER;
import static android.view.WindowManager.REMOVE_CONTENT_MODE_UNDEFINED;
import static android.view.WindowManager.TRANSIT_NONE;
import static android.view.WindowManager.TRANSIT_OPEN;
+import static android.view.WindowManager.TRANSIT_TO_FRONT;
import static android.view.WindowManager.fixScale;
import static android.view.WindowManagerGlobal.ADD_OKAY;
import static android.view.WindowManagerGlobal.RELAYOUT_RES_CANCEL_AND_REDRAW;
@@ -158,6 +159,7 @@ import static com.android.server.wm.WindowManagerServiceDumpProto.ROOT_WINDOW_CO
import static com.android.server.wm.WindowManagerServiceDumpProto.WINDOW_FRAMES_VALID;
import static com.android.window.flags.Flags.multiCrop;
import static com.android.window.flags.Flags.setScPropertiesInClient;
+import static com.android.window.flags.Flags.enableDisplayFocusInShellTransitions;
import android.Manifest;
import android.Manifest.permission;
@@ -1545,7 +1547,23 @@ public class WindowManagerService extends IWindowManager.Stub
return WindowManagerGlobal.ADD_APP_EXITING;
}
- final DisplayContent displayContent = getDisplayContentOrCreate(displayId, attrs.token);
+ if (type >= FIRST_SUB_WINDOW && type <= LAST_SUB_WINDOW) {
+ parentWindow = windowForClientLocked(null, attrs.token, false);
+ if (parentWindow == null) {
+ ProtoLog.w(WM_ERROR, "Attempted to add window with token that is not a window: "
+ + "%s. Aborting.", attrs.token);
+ return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
+ }
+ if (parentWindow.mAttrs.type >= FIRST_SUB_WINDOW
+ && parentWindow.mAttrs.type <= LAST_SUB_WINDOW) {
+ ProtoLog.w(WM_ERROR, "Attempted to add window with token that is a sub-window: "
+ + "%s. Aborting.", attrs.token);
+ return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
+ }
+ }
+ final DisplayContent displayContent = parentWindow != null
+ ? parentWindow.mDisplayContent
+ : getDisplayContentOrCreate(displayId, attrs.token);
if (displayContent == null) {
ProtoLog.w(WM_ERROR, "Attempted to add window to a display that does "
@@ -1565,21 +1583,6 @@ public class WindowManagerService extends IWindowManager.Stub
return WindowManagerGlobal.ADD_DUPLICATE_ADD;
}
- if (type >= FIRST_SUB_WINDOW && type <= LAST_SUB_WINDOW) {
- parentWindow = windowForClientLocked(null, attrs.token, false);
- if (parentWindow == null) {
- ProtoLog.w(WM_ERROR, "Attempted to add window with token that is not a window: "
- + "%s. Aborting.", attrs.token);
- return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
- }
- if (parentWindow.mAttrs.type >= FIRST_SUB_WINDOW
- && parentWindow.mAttrs.type <= LAST_SUB_WINDOW) {
- ProtoLog.w(WM_ERROR, "Attempted to add window with token that is a sub-window: "
- + "%s. Aborting.", attrs.token);
- return WindowManagerGlobal.ADD_BAD_SUBWINDOW_TOKEN;
- }
- }
-
if (type == TYPE_PRESENTATION || type == TYPE_PRIVATE_PRESENTATION) {
mDisplayManagerInternal.onPresentation(displayContent.getDisplay().getDisplayId(),
/*isShown=*/ true);
@@ -3238,9 +3241,28 @@ public class WindowManagerService extends IWindowManager.Stub
return;
}
+ Transition transition = null;
+ boolean transitionNewlyCreated = false;
+ if (enableDisplayFocusInShellTransitions()) {
+ transition = mAtmService.getTransitionController().requestTransitionIfNeeded(
+ TRANSIT_TO_FRONT, 0 /* flags */, null /* trigger */,
+ displayContent);
+ if (transition != null) {
+ transitionNewlyCreated = true;
+ } else {
+ transition =
+ mAtmService.getTransitionController().getCollectingTransition();
+ }
+ if (transition != null) {
+ transition.recordTaskOrder(displayContent);
+ }
+ }
// Nothing prevented us from moving the display to the top. Let's do it!
displayContent.getParent().positionChildAt(WindowContainer.POSITION_TOP,
displayContent, true /* includingParents */);
+ if (transitionNewlyCreated) {
+ transition.setReady(displayContent, true /* ready */);
+ }
}
}
}
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 256d0c661634..021be5727bf6 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -5196,14 +5196,8 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
Dimmer dimmer;
WindowContainer<?> geometryParent = task;
if (Flags.useTasksDimOnly()) {
- if (task != null) {
- geometryParent = task.getDimmerParent();
- dimmer = task.mDimmer;
- } else {
- RootDisplayArea displayArea = getRootDisplayArea();
- geometryParent = displayArea;
- dimmer = displayArea != null ? displayArea.getDimmer() : null;
- }
+ geometryParent = getDimParent();
+ dimmer = getDimController();
if (dimmer == null) {
ProtoLog.e(WM_DEBUG_DIMMER, "WindowState %s does not have task or"
+ " display area for dimming", this);
@@ -5216,9 +5210,28 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
if (isVisibleNow()) {
dimmer.adjustAppearance(this, dimAmount, blurRadius);
}
- dimmer.adjustPosition(geometryParent,
- this /* relativeParent */, -1 /* relativeLayer */);
+ dimmer.adjustPosition(geometryParent, this /* relativeParent */);
+ }
+ }
+
+ private Dimmer getDimController() {
+ Task task = getTask();
+ if (task != null) {
+ return task.mDimmer;
+ }
+ RootDisplayArea displayArea = getRootDisplayArea();
+ if (displayArea != null) {
+ return displayArea.getDimmer();
+ }
+ return null;
+ }
+
+ private WindowContainer<?> getDimParent() {
+ Task task = getTask();
+ if (task != null && task.isSuitableForDimming()) {
+ return task;
}
+ return getRootDisplayArea();
}
private boolean shouldDrawBlurBehind() {
diff --git a/services/core/jni/com_android_server_vibrator_VibratorController.cpp b/services/core/jni/com_android_server_vibrator_VibratorController.cpp
index 5c5ac28b2169..39c0c3ef1847 100644
--- a/services/core/jni/com_android_server_vibrator_VibratorController.cpp
+++ b/services/core/jni/com_android_server_vibrator_VibratorController.cpp
@@ -54,6 +54,9 @@ static struct {
jmethodID setCompositionSizeMax;
jmethodID setQFactor;
jmethodID setFrequencyProfile;
+ jmethodID setMaxEnvelopeEffectSize;
+ jmethodID setMinEnvelopeEffectControlPointDurationMillis;
+ jmethodID setMaxEnvelopeEffectControlPointDurationMillis;
} sVibratorInfoBuilderClassInfo;
static struct {
jfieldID id;
@@ -484,6 +487,25 @@ static jboolean vibratorGetInfo(JNIEnv* env, jclass /* clazz */, jlong ptr,
env->CallObjectMethod(vibratorInfoBuilder, sVibratorInfoBuilderClassInfo.setQFactor,
static_cast<jfloat>(info.qFactor.value()));
}
+ if (info.maxEnvelopeEffectSize.isOk()) {
+ env->CallObjectMethod(vibratorInfoBuilder,
+ sVibratorInfoBuilderClassInfo.setMaxEnvelopeEffectSize,
+ static_cast<jint>(info.maxEnvelopeEffectSize.value()));
+ }
+ if (info.minEnvelopeEffectControlPointDuration.isOk()) {
+ env->CallObjectMethod(vibratorInfoBuilder,
+ sVibratorInfoBuilderClassInfo
+ .setMinEnvelopeEffectControlPointDurationMillis,
+ static_cast<jint>(
+ info.minEnvelopeEffectControlPointDuration.value().count()));
+ }
+ if (info.maxEnvelopeEffectControlPointDuration.isOk()) {
+ env->CallObjectMethod(vibratorInfoBuilder,
+ sVibratorInfoBuilderClassInfo
+ .setMaxEnvelopeEffectControlPointDurationMillis,
+ static_cast<jint>(
+ info.maxEnvelopeEffectControlPointDuration.value().count()));
+ }
jfloat minFrequency = static_cast<jfloat>(info.minFrequency.valueOr(NAN));
jfloat resonantFrequency = static_cast<jfloat>(info.resonantFrequency.valueOr(NAN));
@@ -580,6 +602,17 @@ int register_android_server_vibrator_VibratorController(JavaVM* jvm, JNIEnv* env
GetMethodIDOrDie(env, vibratorInfoBuilderClass, "setFrequencyProfile",
"(Landroid/os/VibratorInfo$FrequencyProfile;)"
"Landroid/os/VibratorInfo$Builder;");
+ sVibratorInfoBuilderClassInfo.setMaxEnvelopeEffectSize =
+ GetMethodIDOrDie(env, vibratorInfoBuilderClass, "setMaxEnvelopeEffectSize",
+ "(I)Landroid/os/VibratorInfo$Builder;");
+ sVibratorInfoBuilderClassInfo.setMinEnvelopeEffectControlPointDurationMillis =
+ GetMethodIDOrDie(env, vibratorInfoBuilderClass,
+ "setMinEnvelopeEffectControlPointDurationMillis",
+ "(I)Landroid/os/VibratorInfo$Builder;");
+ sVibratorInfoBuilderClassInfo.setMaxEnvelopeEffectControlPointDurationMillis =
+ GetMethodIDOrDie(env, vibratorInfoBuilderClass,
+ "setMaxEnvelopeEffectControlPointDurationMillis",
+ "(I)Landroid/os/VibratorInfo$Builder;");
return jniRegisterNativeMethods(env,
"com/android/server/vibrator/VibratorController$NativeWrapper",
diff --git a/services/tests/appfunctions/src/android/app/appfunctions/AppFunctionRuntimeMetadataTest.kt b/services/tests/appfunctions/src/android/app/appfunctions/AppFunctionRuntimeMetadataTest.kt
new file mode 100644
index 000000000000..650e520ebb7d
--- /dev/null
+++ b/services/tests/appfunctions/src/android/app/appfunctions/AppFunctionRuntimeMetadataTest.kt
@@ -0,0 +1,104 @@
+/*
+ * Copyright (C) 2024 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 android.app.appfunctions
+
+import android.app.appsearch.AppSearchSchema
+import com.google.common.truth.Truth.assertThat
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class AppFunctionRuntimeMetadataTest {
+
+ @Test
+ fun getRuntimeSchemaNameForPackage() {
+ val actualSchemaName =
+ AppFunctionRuntimeMetadata.getRuntimeSchemaNameForPackage("com.example.app")
+
+ assertThat(actualSchemaName).isEqualTo("AppFunctionRuntimeMetadata-com.example.app")
+ }
+
+ @Test
+ fun testCreateChildRuntimeSchema() {
+ val runtimeSchema: AppSearchSchema =
+ AppFunctionRuntimeMetadata.createAppFunctionRuntimeSchema("com.example.app")
+
+ assertThat(runtimeSchema.schemaType).isEqualTo("AppFunctionRuntimeMetadata-com.example.app")
+ val propertyNameSet = runtimeSchema.properties.map { it.name }.toSet()
+ assertThat(propertyNameSet.contains(AppFunctionRuntimeMetadata.PROPERTY_FUNCTION_ID))
+ .isTrue()
+ assertThat(propertyNameSet.contains(AppFunctionRuntimeMetadata.PROPERTY_PACKAGE_NAME))
+ .isTrue()
+ assertThat(propertyNameSet.contains(AppFunctionRuntimeMetadata.PROPERTY_ENABLED)).isTrue()
+ assertThat(
+ propertyNameSet.contains(
+ AppFunctionRuntimeMetadata.PROPERTY_APP_FUNCTION_STATIC_METADATA_QUALIFIED_ID
+ )
+ )
+ .isTrue()
+ }
+
+ @Test
+ fun testCreateParentRuntimeSchema() {
+ val runtimeSchema: AppSearchSchema =
+ AppFunctionRuntimeMetadata.createParentAppFunctionRuntimeSchema()
+
+ assertThat(runtimeSchema.schemaType).isEqualTo("AppFunctionRuntimeMetadata")
+ val propertyNameSet = runtimeSchema.properties.map { it.name }.toSet()
+ assertThat(propertyNameSet.contains(AppFunctionRuntimeMetadata.PROPERTY_FUNCTION_ID))
+ .isTrue()
+ assertThat(propertyNameSet.contains(AppFunctionRuntimeMetadata.PROPERTY_PACKAGE_NAME))
+ .isTrue()
+ assertThat(propertyNameSet.contains(AppFunctionRuntimeMetadata.PROPERTY_ENABLED)).isTrue()
+ assertThat(
+ propertyNameSet.contains(
+ AppFunctionRuntimeMetadata.PROPERTY_APP_FUNCTION_STATIC_METADATA_QUALIFIED_ID
+ )
+ )
+ .isTrue()
+ }
+
+ @Test
+ fun testGetPackageNameFromSchema() {
+ val expectedPackageName = "com.foo.test"
+ val expectedPackageName2 = "com.bar.test"
+ val testSchemaType =
+ AppFunctionRuntimeMetadata.createAppFunctionRuntimeSchema(expectedPackageName)
+ .schemaType
+ val testSchemaType2 =
+ AppFunctionRuntimeMetadata.createAppFunctionRuntimeSchema(expectedPackageName2)
+ .schemaType
+
+ val actualPackageName = AppFunctionRuntimeMetadata.getPackageNameFromSchema(testSchemaType)
+ val actualPackageName2 =
+ AppFunctionRuntimeMetadata.getPackageNameFromSchema(testSchemaType2)
+
+ assertThat(actualPackageName).isEqualTo(expectedPackageName)
+ assertThat(actualPackageName2).isEqualTo(expectedPackageName2)
+ }
+
+ @Test
+ fun testGetPackageNameFromParentSchema() {
+ val expectedPackageName = AppFunctionRuntimeMetadata.APP_FUNCTION_INDEXER_PACKAGE
+ val testSchemaType =
+ AppFunctionRuntimeMetadata.createParentAppFunctionRuntimeSchema().schemaType
+
+ val actualPackageName = AppFunctionRuntimeMetadata.getPackageNameFromSchema(testSchemaType)
+
+ assertThat(actualPackageName).isEqualTo(expectedPackageName)
+ }
+}
diff --git a/services/tests/appfunctions/src/com/android/server/appfunctions/FutureAppSearchSessionTest.kt b/services/tests/appfunctions/src/com/android/server/appfunctions/FutureAppSearchSessionTest.kt
index a0f1a559bb52..3bc44111ba08 100644
--- a/services/tests/appfunctions/src/com/android/server/appfunctions/FutureAppSearchSessionTest.kt
+++ b/services/tests/appfunctions/src/com/android/server/appfunctions/FutureAppSearchSessionTest.kt
@@ -19,8 +19,10 @@ import android.app.appfunctions.AppFunctionRuntimeMetadata
import android.app.appfunctions.AppFunctionRuntimeMetadata.APP_FUNCTION_RUNTIME_NAMESPACE
import android.app.appfunctions.AppFunctionRuntimeMetadata.createAppFunctionRuntimeSchema
import android.app.appfunctions.AppFunctionRuntimeMetadata.createParentAppFunctionRuntimeSchema
+import android.app.appsearch.AppSearchBatchResult
import android.app.appsearch.AppSearchManager
import android.app.appsearch.PutDocumentsRequest
+import android.app.appsearch.RemoveByDocumentIdRequest
import android.app.appsearch.SearchSpec
import android.app.appsearch.SetSchemaRequest
import androidx.test.platform.app.InstrumentationRegistry
@@ -56,7 +58,7 @@ class FutureAppSearchSessionTest {
SetSchemaRequest.Builder()
.addSchemas(
createParentAppFunctionRuntimeSchema(),
- createAppFunctionRuntimeSchema(TEST_PACKAGE_NAME)
+ createAppFunctionRuntimeSchema(TEST_PACKAGE_NAME),
)
.build()
@@ -74,7 +76,7 @@ class FutureAppSearchSessionTest {
SetSchemaRequest.Builder()
.addSchemas(
createParentAppFunctionRuntimeSchema(),
- createAppFunctionRuntimeSchema(TEST_PACKAGE_NAME)
+ createAppFunctionRuntimeSchema(TEST_PACKAGE_NAME),
)
.build()
val schema = session.setSchema(setSchemaRequest)
@@ -93,6 +95,40 @@ class FutureAppSearchSessionTest {
}
@Test
+ fun remove() {
+ val searchContext = AppSearchManager.SearchContext.Builder(TEST_DB).build()
+ FutureAppSearchSession(appSearchManager, testExecutor, searchContext).use { session ->
+ val setSchemaRequest =
+ SetSchemaRequest.Builder()
+ .addSchemas(
+ createParentAppFunctionRuntimeSchema(),
+ createAppFunctionRuntimeSchema(TEST_PACKAGE_NAME),
+ )
+ .build()
+ val schema = session.setSchema(setSchemaRequest)
+ assertThat(schema.get()).isNotNull()
+ val appFunctionRuntimeMetadata =
+ AppFunctionRuntimeMetadata.Builder(TEST_PACKAGE_NAME, TEST_FUNCTION_ID, "").build()
+ val putDocumentsRequest: PutDocumentsRequest =
+ PutDocumentsRequest.Builder()
+ .addGenericDocuments(appFunctionRuntimeMetadata)
+ .build()
+ val putResult = session.put(putDocumentsRequest)
+ assertThat(putResult.get().isSuccess).isTrue()
+ val removeDocumentRequest =
+ RemoveByDocumentIdRequest.Builder(APP_FUNCTION_RUNTIME_NAMESPACE)
+ .addIds(appFunctionRuntimeMetadata.id)
+ .build()
+
+ val removeResult: AppSearchBatchResult<String, Void> =
+ session.remove(removeDocumentRequest).get()
+
+ assertThat(removeResult).isNotNull()
+ assertThat(removeResult.isSuccess).isTrue()
+ }
+ }
+
+ @Test
fun search() {
val searchContext = AppSearchManager.SearchContext.Builder(TEST_DB).build()
FutureAppSearchSession(appSearchManager, testExecutor, searchContext).use { session ->
@@ -100,7 +136,7 @@ class FutureAppSearchSessionTest {
SetSchemaRequest.Builder()
.addSchemas(
createParentAppFunctionRuntimeSchema(),
- createAppFunctionRuntimeSchema(TEST_PACKAGE_NAME)
+ createAppFunctionRuntimeSchema(TEST_PACKAGE_NAME),
)
.build()
val schema = session.setSchema(setSchemaRequest)
@@ -132,7 +168,7 @@ class FutureAppSearchSessionTest {
SetSchemaRequest.Builder()
.addSchemas(
createParentAppFunctionRuntimeSchema(),
- createAppFunctionRuntimeSchema(TEST_PACKAGE_NAME)
+ createAppFunctionRuntimeSchema(TEST_PACKAGE_NAME),
)
.build()
val schema = session.setSchema(setSchemaRequest)
@@ -144,12 +180,13 @@ class FutureAppSearchSessionTest {
.build()
val putResult = session.put(putDocumentsRequest)
- val genricDocument = session
- .getByDocumentId(
- /* documentId= */ "${TEST_PACKAGE_NAME}/${TEST_FUNCTION_ID}",
- APP_FUNCTION_RUNTIME_NAMESPACE
- )
- .get()
+ val genricDocument =
+ session
+ .getByDocumentId(
+ /* documentId= */ "${TEST_PACKAGE_NAME}/${TEST_FUNCTION_ID}",
+ APP_FUNCTION_RUNTIME_NAMESPACE,
+ )
+ .get()
val foundAppFunctionRuntimeMetadata = AppFunctionRuntimeMetadata(genricDocument)
assertThat(foundAppFunctionRuntimeMetadata.functionId).isEqualTo(TEST_FUNCTION_ID)
diff --git a/services/tests/appfunctions/src/com/android/server/appfunctions/MetadataSyncAdapterTest.kt b/services/tests/appfunctions/src/com/android/server/appfunctions/MetadataSyncAdapterTest.kt
new file mode 100644
index 000000000000..5769e07ee58d
--- /dev/null
+++ b/services/tests/appfunctions/src/com/android/server/appfunctions/MetadataSyncAdapterTest.kt
@@ -0,0 +1,274 @@
+/*
+ * 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.server.appfunctions
+
+import android.app.appfunctions.AppFunctionRuntimeMetadata
+import android.app.appsearch.AppSearchManager
+import android.app.appsearch.AppSearchManager.SearchContext
+import android.app.appsearch.PutDocumentsRequest
+import android.app.appsearch.SetSchemaRequest
+import android.util.ArrayMap
+import android.util.ArraySet
+import androidx.test.platform.app.InstrumentationRegistry
+import com.google.common.truth.Truth.assertThat
+import com.google.common.util.concurrent.MoreExecutors
+import org.junit.After
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.junit.runners.JUnit4
+
+@RunWith(JUnit4::class)
+class MetadataSyncAdapterTest {
+ private val context = InstrumentationRegistry.getInstrumentation().targetContext
+ private val appSearchManager = context.getSystemService(AppSearchManager::class.java)
+ private val testExecutor = MoreExecutors.directExecutor()
+
+ @Before
+ @After
+ fun clearData() {
+ val searchContext = SearchContext.Builder(TEST_DB).build()
+ FutureAppSearchSession(appSearchManager, testExecutor, searchContext).use {
+ val setSchemaRequest = SetSchemaRequest.Builder().setForceOverride(true).build()
+ it.setSchema(setSchemaRequest)
+ }
+ }
+
+ @Test
+ fun getPackageToFunctionIdMap() {
+ val searchContext: SearchContext = SearchContext.Builder(TEST_DB).build()
+ val functionRuntimeMetadata =
+ AppFunctionRuntimeMetadata.Builder(TEST_TARGET_PKG_NAME, "testFunctionId", "").build()
+ val setSchemaRequest =
+ SetSchemaRequest.Builder()
+ .addSchemas(AppFunctionRuntimeMetadata.createParentAppFunctionRuntimeSchema())
+ .addSchemas(
+ AppFunctionRuntimeMetadata.createAppFunctionRuntimeSchema(TEST_TARGET_PKG_NAME)
+ )
+ .build()
+ val putDocumentsRequest: PutDocumentsRequest =
+ PutDocumentsRequest.Builder().addGenericDocuments(functionRuntimeMetadata).build()
+ FutureAppSearchSession(appSearchManager, testExecutor, searchContext).use {
+ val setSchemaResponse = it.setSchema(setSchemaRequest).get()
+ assertThat(setSchemaResponse).isNotNull()
+ val appSearchBatchResult = it.put(putDocumentsRequest).get()
+ assertThat(appSearchBatchResult.isSuccess).isTrue()
+ }
+
+ val metadataSyncAdapter =
+ MetadataSyncAdapter(
+ testExecutor,
+ FutureAppSearchSession(appSearchManager, testExecutor, searchContext),
+ )
+ val packageToFunctionIdMap =
+ metadataSyncAdapter.getPackageToFunctionIdMap(
+ AppFunctionRuntimeMetadata.RUNTIME_SCHEMA_TYPE,
+ AppFunctionRuntimeMetadata.PROPERTY_FUNCTION_ID,
+ AppFunctionRuntimeMetadata.PROPERTY_PACKAGE_NAME,
+ )
+
+ assertThat(packageToFunctionIdMap).isNotNull()
+ assertThat(packageToFunctionIdMap[TEST_TARGET_PKG_NAME]).containsExactly("testFunctionId")
+ }
+
+ @Test
+ fun getPackageToFunctionIdMap_multipleDocuments() {
+ val searchContext: SearchContext = SearchContext.Builder(TEST_DB).build()
+ val functionRuntimeMetadata =
+ AppFunctionRuntimeMetadata.Builder(TEST_TARGET_PKG_NAME, "testFunctionId", "").build()
+ val functionRuntimeMetadata1 =
+ AppFunctionRuntimeMetadata.Builder(TEST_TARGET_PKG_NAME, "testFunctionId1", "").build()
+ val functionRuntimeMetadata2 =
+ AppFunctionRuntimeMetadata.Builder(TEST_TARGET_PKG_NAME, "testFunctionId2", "").build()
+ val functionRuntimeMetadata3 =
+ AppFunctionRuntimeMetadata.Builder(TEST_TARGET_PKG_NAME, "testFunctionId3", "").build()
+ val setSchemaRequest =
+ SetSchemaRequest.Builder()
+ .addSchemas(AppFunctionRuntimeMetadata.createParentAppFunctionRuntimeSchema())
+ .addSchemas(
+ AppFunctionRuntimeMetadata.createAppFunctionRuntimeSchema(TEST_TARGET_PKG_NAME)
+ )
+ .build()
+ val putDocumentsRequest: PutDocumentsRequest =
+ PutDocumentsRequest.Builder()
+ .addGenericDocuments(
+ functionRuntimeMetadata,
+ functionRuntimeMetadata1,
+ functionRuntimeMetadata2,
+ functionRuntimeMetadata3,
+ )
+ .build()
+ FutureAppSearchSession(appSearchManager, testExecutor, searchContext).use {
+ val setSchemaResponse = it.setSchema(setSchemaRequest).get()
+ assertThat(setSchemaResponse).isNotNull()
+ val appSearchBatchResult = it.put(putDocumentsRequest).get()
+ assertThat(appSearchBatchResult.isSuccess).isTrue()
+ }
+
+ val metadataSyncAdapter =
+ MetadataSyncAdapter(
+ testExecutor,
+ FutureAppSearchSession(appSearchManager, testExecutor, searchContext),
+ )
+ val packageToFunctionIdMap =
+ metadataSyncAdapter.getPackageToFunctionIdMap(
+ AppFunctionRuntimeMetadata.RUNTIME_SCHEMA_TYPE,
+ AppFunctionRuntimeMetadata.PROPERTY_FUNCTION_ID,
+ AppFunctionRuntimeMetadata.PROPERTY_PACKAGE_NAME,
+ )
+
+ assertThat(packageToFunctionIdMap).isNotNull()
+ assertThat(packageToFunctionIdMap[TEST_TARGET_PKG_NAME])
+ .containsExactly(
+ "testFunctionId",
+ "testFunctionId1",
+ "testFunctionId2",
+ "testFunctionId3",
+ )
+ }
+
+ @Test
+ fun getAddedFunctionsDiffMap_noDiff() {
+ val staticPackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+ staticPackageToFunctionMap.putAll(
+ mapOf(TEST_TARGET_PKG_NAME to ArraySet(setOf("testFunction1")))
+ )
+ val runtimePackageToFunctionMap: ArrayMap<String, ArraySet<String>> =
+ ArrayMap(staticPackageToFunctionMap)
+
+ val addedFunctionsDiffMap =
+ MetadataSyncAdapter.getAddedFunctionsDiffMap(
+ staticPackageToFunctionMap,
+ runtimePackageToFunctionMap,
+ )
+
+ assertThat(addedFunctionsDiffMap.isEmpty()).isEqualTo(true)
+ }
+
+ @Test
+ fun getAddedFunctionsDiffMap_addedFunction() {
+ val staticPackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+ staticPackageToFunctionMap.putAll(
+ mapOf(TEST_TARGET_PKG_NAME to ArraySet(setOf("testFunction1", "testFunction2")))
+ )
+ val runtimePackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+ runtimePackageToFunctionMap.putAll(
+ mapOf(TEST_TARGET_PKG_NAME to ArraySet(setOf("testFunction1")))
+ )
+
+ val addedFunctionsDiffMap =
+ MetadataSyncAdapter.getAddedFunctionsDiffMap(
+ staticPackageToFunctionMap,
+ runtimePackageToFunctionMap,
+ )
+
+ assertThat(addedFunctionsDiffMap.size).isEqualTo(1)
+ assertThat(addedFunctionsDiffMap[TEST_TARGET_PKG_NAME]).containsExactly("testFunction2")
+ }
+
+ @Test
+ fun getAddedFunctionsDiffMap_addedFunctionNewPackage() {
+ val staticPackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+ staticPackageToFunctionMap.putAll(
+ mapOf(TEST_TARGET_PKG_NAME to ArraySet(setOf("testFunction1")))
+ )
+ val runtimePackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+
+ val addedFunctionsDiffMap =
+ MetadataSyncAdapter.getAddedFunctionsDiffMap(
+ staticPackageToFunctionMap,
+ runtimePackageToFunctionMap,
+ )
+
+ assertThat(addedFunctionsDiffMap.size).isEqualTo(1)
+ assertThat(addedFunctionsDiffMap[TEST_TARGET_PKG_NAME]).containsExactly("testFunction1")
+ }
+
+ @Test
+ fun getAddedFunctionsDiffMap_removedFunction() {
+ val staticPackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+ val runtimePackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+ runtimePackageToFunctionMap.putAll(
+ mapOf(TEST_TARGET_PKG_NAME to ArraySet(setOf("testFunction1")))
+ )
+
+ val addedFunctionsDiffMap =
+ MetadataSyncAdapter.getAddedFunctionsDiffMap(
+ staticPackageToFunctionMap,
+ runtimePackageToFunctionMap,
+ )
+
+ assertThat(addedFunctionsDiffMap.isEmpty()).isEqualTo(true)
+ }
+
+ @Test
+ fun getRemovedFunctionsDiffMap_noDiff() {
+ val staticPackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+ staticPackageToFunctionMap.putAll(
+ mapOf(TEST_TARGET_PKG_NAME to ArraySet(setOf("testFunction1")))
+ )
+ val runtimePackageToFunctionMap: ArrayMap<String, ArraySet<String>> =
+ ArrayMap(staticPackageToFunctionMap)
+
+ val removedFunctionsDiffMap =
+ MetadataSyncAdapter.getRemovedFunctionsDiffMap(
+ staticPackageToFunctionMap,
+ runtimePackageToFunctionMap,
+ )
+
+ assertThat(removedFunctionsDiffMap.isEmpty()).isEqualTo(true)
+ }
+
+ @Test
+ fun getRemovedFunctionsDiffMap_removedFunction() {
+ val staticPackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+ val runtimePackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+ runtimePackageToFunctionMap.putAll(
+ mapOf(TEST_TARGET_PKG_NAME to ArraySet(setOf("testFunction1")))
+ )
+
+ val removedFunctionsDiffMap =
+ MetadataSyncAdapter.getRemovedFunctionsDiffMap(
+ staticPackageToFunctionMap,
+ runtimePackageToFunctionMap,
+ )
+
+ assertThat(removedFunctionsDiffMap.size).isEqualTo(1)
+ assertThat(removedFunctionsDiffMap[TEST_TARGET_PKG_NAME]).containsExactly("testFunction1")
+ }
+
+ @Test
+ fun getRemovedFunctionsDiffMap_addedFunction() {
+ val staticPackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+ staticPackageToFunctionMap.putAll(
+ mapOf(TEST_TARGET_PKG_NAME to ArraySet(setOf("testFunction1")))
+ )
+ val runtimePackageToFunctionMap: ArrayMap<String, ArraySet<String>> = ArrayMap()
+
+ val removedFunctionsDiffMap =
+ MetadataSyncAdapter.getRemovedFunctionsDiffMap(
+ staticPackageToFunctionMap,
+ runtimePackageToFunctionMap,
+ )
+
+ assertThat(removedFunctionsDiffMap.isEmpty()).isEqualTo(true)
+ }
+
+ private companion object {
+ const val TEST_DB: String = "test_db"
+ const val TEST_TARGET_PKG_NAME = "com.android.frameworks.appfunctionstests"
+ }
+}
diff --git a/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java b/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
index 52f1cbd89e13..76c8e6862211 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
@@ -143,6 +143,7 @@ import com.android.server.display.DisplayManagerService.DeviceStateListener;
import com.android.server.display.DisplayManagerService.SyncRoot;
import com.android.server.display.config.SensorData;
import com.android.server.display.feature.DisplayManagerFlags;
+import com.android.server.display.layout.Layout;
import com.android.server.display.notifications.DisplayNotificationManager;
import com.android.server.input.InputManagerInternal;
import com.android.server.lights.LightsManager;
@@ -3201,6 +3202,45 @@ public class DisplayManagerServiceTest {
argThat(matchesFilter));
}
+ @Test
+ public void testOnDisplayChanged_HbmMetadataNull() {
+ DisplayPowerController dpc = mock(DisplayPowerController.class);
+ DisplayManagerService.Injector injector = new BasicInjector() {
+ @Override
+ DisplayPowerController getDisplayPowerController(Context context,
+ DisplayPowerController.Injector injector,
+ DisplayManagerInternal.DisplayPowerCallbacks callbacks, Handler handler,
+ SensorManager sensorManager, DisplayBlanker blanker,
+ LogicalDisplay logicalDisplay, BrightnessTracker brightnessTracker,
+ BrightnessSetting brightnessSetting, Runnable onBrightnessChangeRunnable,
+ HighBrightnessModeMetadata hbmMetadata, boolean bootCompleted,
+ DisplayManagerFlags flags) {
+ return dpc;
+ }
+ };
+ DisplayManagerService displayManager = new DisplayManagerService(mContext, injector);
+ DisplayManagerInternal localService = displayManager.new LocalService();
+ registerDefaultDisplays(displayManager);
+ displayManager.onBootPhase(SystemService.PHASE_WAIT_FOR_DEFAULT_DISPLAY);
+
+ // Add the FakeDisplayDevice
+ FakeDisplayDevice displayDevice = new FakeDisplayDevice();
+ DisplayDeviceInfo displayDeviceInfo = new DisplayDeviceInfo();
+ displayDeviceInfo.state = Display.STATE_ON;
+ displayDevice.setDisplayDeviceInfo(displayDeviceInfo);
+ displayManager.getDisplayDeviceRepository()
+ .onDisplayDeviceEvent(displayDevice, DisplayAdapter.DISPLAY_DEVICE_EVENT_ADDED);
+ initDisplayPowerController(localService);
+
+ // Simulate DisplayDevice change
+ DisplayDeviceInfo displayDeviceInfo2 = new DisplayDeviceInfo();
+ displayDeviceInfo2.copyFrom(displayDeviceInfo);
+ displayDeviceInfo2.state = Display.STATE_DOZE;
+ updateDisplayDeviceInfo(displayManager, displayDevice, displayDeviceInfo2);
+
+ verify(dpc).onDisplayChanged(/* hbmMetadata= */ null, Layout.NO_LEAD_DISPLAY);
+ }
+
private void initDisplayPowerController(DisplayManagerInternal localService) {
localService.initPowerManagement(new DisplayManagerInternal.DisplayPowerCallbacks() {
@Override
diff --git a/services/tests/mockingservicestests/Android.bp b/services/tests/mockingservicestests/Android.bp
index 5a7693194d88..01435ff7f253 100644
--- a/services/tests/mockingservicestests/Android.bp
+++ b/services/tests/mockingservicestests/Android.bp
@@ -138,8 +138,6 @@ android_ravenwood_test {
auto_gen_config: true,
}
-FLAKY = ["androidx.test.filters.FlakyTest"]
-
test_module_config {
name: "FrameworksMockingServicesTests_blob",
base: "FrameworksMockingServicesTests",
@@ -152,7 +150,6 @@ test_module_config {
base: "FrameworksMockingServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.DeviceIdleControllerTest"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -161,7 +158,6 @@ test_module_config {
test_suites: ["device-tests"],
include_filters: ["com.android.server.AppStateTrackerTest"],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -177,7 +173,6 @@ test_module_config {
test_suites: ["device-tests"],
include_filters: ["com.android.server.alarm"],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -185,7 +180,7 @@ test_module_config {
base: "FrameworksMockingServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.job"],
- exclude_annotations: FLAKY + ["androidx.test.filters.LargeTest"],
+ exclude_annotations: ["androidx.test.filters.LargeTest"],
}
test_module_config {
@@ -200,7 +195,6 @@ test_module_config {
base: "FrameworksMockingServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.tare"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -215,7 +209,6 @@ test_module_config {
base: "FrameworksMockingServicesTests",
test_suites: ["device-tests"],
include_filters: ["android.service.games"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -245,7 +238,6 @@ test_module_config {
test_suites: ["device-tests"],
include_filters: ["com.android.server.am."],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -265,7 +257,6 @@ test_module_config {
test_suites: ["device-tests"],
// Matches appop too
include_filters: ["com.android.server.app"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -301,7 +292,6 @@ test_module_config {
base: "FrameworksMockingServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.pm"],
- exclude_annotations: FLAKY + ["org.junit.Ignore"],
}
test_module_config {
@@ -309,7 +299,6 @@ test_module_config {
base: "FrameworksMockingServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.power"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -324,7 +313,6 @@ test_module_config {
base: "FrameworksMockingServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.trust"],
- exclude_annotations: FLAKY,
}
test_module_config {
diff --git a/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java b/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java
index d9573559fa8d..5ec53023dc67 100644
--- a/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java
+++ b/services/tests/mockingservicestests/src/com/android/server/am/MockingOomAdjusterTests.java
@@ -438,6 +438,28 @@ public class MockingOomAdjusterTests {
@SuppressWarnings("GuardedBy")
@Test
+ public void testUpdateOomAdj_DoOne_TopSleepingReceivingBroadcast() {
+ ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
+ MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, true));
+ doReturn(PROCESS_STATE_TOP_SLEEPING).when(mService.mAtmInternal).getTopProcessState();
+ doReturn(app).when(mService).getTopApp();
+ updateOomAdj(app);
+
+ assertProcStates(app, PROCESS_STATE_TOP_SLEEPING, FOREGROUND_APP_ADJ,
+ SCHED_GROUP_BACKGROUND);
+ assertTrue(app.mState.hasForegroundActivities());
+
+ doReturn(true).when(mService).isReceivingBroadcastLocked(any(ProcessRecord.class),
+ any(int[].class));
+ updateOomAdj(app);
+
+ assertProcStates(app, PROCESS_STATE_RECEIVER, FOREGROUND_APP_ADJ, SCHED_GROUP_BACKGROUND);
+ assertTrue(app.mState.hasForegroundActivities());
+
+ }
+
+ @SuppressWarnings("GuardedBy")
+ @Test
public void testUpdateOomAdj_DoOne_ExecutingService() {
ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, true));
@@ -1182,6 +1204,25 @@ public class MockingOomAdjusterTests {
@SuppressWarnings("GuardedBy")
@Test
+ public void testUpdateOomAdj_DoOne_BoundFgService_Sleeping() {
+ ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
+ MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
+ ProcessRecord client = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
+ MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, false));
+ bindService(app, client, null, null, Context.BIND_FOREGROUND_SERVICE, mock(IBinder.class));
+ client.mState.setMaxAdj(PERSISTENT_PROC_ADJ);
+ mService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_ASLEEP);
+ updateOomAdj(client, app);
+ mService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
+
+ assertProcStates(app, PROCESS_STATE_BOUND_FOREGROUND_SERVICE, VISIBLE_APP_ADJ,
+ SCHED_GROUP_RESTRICTED);
+ assertProcStates(client, PROCESS_STATE_PERSISTENT, PERSISTENT_PROC_ADJ,
+ SCHED_GROUP_DEFAULT);
+ }
+
+ @SuppressWarnings("GuardedBy")
+ @Test
public void testUpdateOomAdj_DoOne_Service_BoundNotForeground() {
ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, false));
@@ -2766,6 +2807,30 @@ public class MockingOomAdjusterTests {
@SuppressWarnings("GuardedBy")
@Test
+ public void testUpdateOomAdj_DoOne_AboveClient() {
+ ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
+ MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, true));
+ ProcessRecord service = spy(makeDefaultProcessRecord(MOCKAPP2_PID, MOCKAPP2_UID,
+ MOCKAPP2_PROCESSNAME, MOCKAPP2_PACKAGENAME, true));
+ doReturn(PROCESS_STATE_TOP).when(mService.mAtmInternal).getTopProcessState();
+ doReturn(app).when(mService).getTopApp();
+ mService.mWakefulness.set(PowerManagerInternal.WAKEFULNESS_AWAKE);
+ updateOomAdj(app);
+
+ assertEquals(FOREGROUND_APP_ADJ, app.mState.getSetAdj());
+
+ // Simulate binding to a service in the same process using BIND_ABOVE_CLIENT and
+ // verify that its OOM adjustment level is unaffected.
+ bindService(service, app, null, null, Context.BIND_ABOVE_CLIENT, mock(IBinder.class));
+ app.mServices.updateHasAboveClientLocked();
+ assertTrue(app.mServices.hasAboveClient());
+
+ updateOomAdj(app);
+ assertEquals(VISIBLE_APP_ADJ, app.mState.getSetAdj());
+ }
+
+ @SuppressWarnings("GuardedBy")
+ @Test
public void testUpdateOomAdj_DoOne_AboveClient_SameProcess() {
ProcessRecord app = spy(makeDefaultProcessRecord(MOCKAPP_PID, MOCKAPP_UID,
MOCKAPP_PROCESSNAME, MOCKAPP_PACKAGENAME, true));
diff --git a/services/tests/servicestests/Android.bp b/services/tests/servicestests/Android.bp
index a862c43fd841..914b29f44bb1 100644
--- a/services/tests/servicestests/Android.bp
+++ b/services/tests/servicestests/Android.bp
@@ -36,6 +36,7 @@ android_test {
"-Werror",
],
static_libs: [
+ "a11ychecker",
"aatf",
"accessibility_protos_lite",
"cts-input-lib",
@@ -273,21 +274,12 @@ java_genrule {
"$(location soong_zip) -o $(out) -C $(genDir)/res -D $(genDir)/res",
}
-FLAKY = [
- "androidx.test.filters.FlakyTest",
-]
-
-FLAKY_AND_IGNORED = [
- "androidx.test.filters.FlakyTest",
- "org.junit.Ignore",
-]
// Used by content protection TEST_MAPPING
test_module_config {
name: "FrameworksServicesTests_contentprotection",
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.contentprotection"],
- exclude_annotations: FLAKY_AND_IGNORED,
}
test_module_config {
@@ -295,7 +287,6 @@ test_module_config {
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.om."],
- exclude_annotations: FLAKY_AND_IGNORED,
}
// Used by contexthub TEST_MAPPING
@@ -306,7 +297,6 @@ test_module_config {
include_filters: ["com.android.server.location.contexthub."],
// TODO(ron): are these right, does it run anything?
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY_AND_IGNORED,
}
test_module_config {
@@ -316,7 +306,6 @@ test_module_config {
include_filters: ["com.android.server.location.contexthub."],
// TODO(ron): are these right, does it run anything?
include_annotations: ["android.platform.test.annotations.Postsubmit"],
- exclude_annotations: FLAKY_AND_IGNORED,
}
// Used by contentcapture
@@ -325,7 +314,6 @@ test_module_config {
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.contentcapture"],
- exclude_annotations: FLAKY_AND_IGNORED,
}
test_module_config {
@@ -333,7 +321,6 @@ test_module_config {
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.recoverysystem."],
- exclude_annotations: FLAKY,
}
// server pm TEST_MAPPING
@@ -343,7 +330,6 @@ test_module_config {
test_suites: ["device-tests"],
include_annotations: ["android.platform.test.annotations.Presubmit"],
include_filters: ["com.android.server.pm."],
- exclude_annotations: FLAKY_AND_IGNORED,
}
test_module_config {
@@ -352,7 +338,6 @@ test_module_config {
test_suites: ["device-tests"],
include_annotations: ["android.platform.test.annotations.Postsubmit"],
include_filters: ["com.android.server.pm."],
- exclude_annotations: FLAKY_AND_IGNORED,
}
// server os TEST_MAPPING
@@ -368,7 +353,6 @@ test_module_config {
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY_AND_IGNORED,
}
test_module_config {
@@ -390,14 +374,6 @@ test_module_config {
}
test_module_config {
- name: "FrameworksServicesTests_com_android_server_tare_Presubmit",
- base: "FrameworksServicesTests",
- test_suites: ["device-tests"],
- include_filters: ["com.android.server.tare"],
- exclude_annotations: FLAKY,
-}
-
-test_module_config {
name: "FrameworksServicesTests_com_android_server_tare",
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
@@ -405,14 +381,6 @@ test_module_config {
}
test_module_config {
- name: "FrameworksServicesTests_com_android_server_usage_Presubmit",
- base: "FrameworksServicesTests",
- test_suites: ["device-tests"],
- include_filters: ["com.android.server.usage"],
- exclude_annotations: FLAKY,
-}
-
-test_module_config {
name: "FrameworksServicesTests_com_android_server_usage",
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
@@ -427,14 +395,6 @@ test_module_config {
}
test_module_config {
- name: "FrameworksServicesTests_accessibility_Presubmit",
- base: "FrameworksServicesTests",
- test_suites: ["device-tests"],
- include_filters: ["com.android.server.accessibility"],
- exclude_annotations: FLAKY,
-}
-
-test_module_config {
name: "FrameworksServicesTests_accessibility",
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
@@ -462,7 +422,6 @@ test_module_config {
test_suites: ["device-tests"],
include_filters: ["com.android.server.am."],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -485,7 +444,6 @@ test_module_config {
test_suites: ["device-tests"],
include_filters: ["com.android.server.audio"],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY_AND_IGNORED,
}
test_module_config {
@@ -501,7 +459,6 @@ test_module_config {
test_suites: ["device-tests"],
include_filters: ["com.android.server.hdmi"],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY_AND_IGNORED,
}
test_module_config {
@@ -509,7 +466,6 @@ test_module_config {
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.hdmi"],
- exclude_annotations: ["org.junit.Ignore"],
}
test_module_config {
@@ -524,7 +480,6 @@ test_module_config {
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.lights"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -540,7 +495,6 @@ test_module_config {
test_suites: ["device-tests"],
include_filters: ["com.android.server.location.contexthub."],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY_AND_IGNORED,
}
test_module_config {
@@ -548,15 +502,6 @@ test_module_config {
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.locksettings."],
- exclude_annotations: FLAKY,
-}
-
-test_module_config {
- name: "FrameworksServicesTests_android_server_logcat_Presubmit",
- base: "FrameworksServicesTests",
- test_suites: ["device-tests"],
- include_filters: ["com.android.server.logcat"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -572,7 +517,6 @@ test_module_config {
test_suites: ["device-tests"],
include_filters: ["com.android.server.net."],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -602,7 +546,6 @@ test_module_config {
test_suites: ["device-tests"],
include_filters: ["com.android.server.policy."],
include_annotations: ["android.platform.test.annotations.Presubmit"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -624,7 +567,6 @@ test_module_config {
base: "FrameworksServicesTests",
test_suites: ["device-tests"],
include_filters: ["com.android.server.power.hint"],
- exclude_annotations: FLAKY,
}
test_module_config {
@@ -654,7 +596,6 @@ test_module_config {
test_suites: ["device-tests"],
include_filters: ["com.android.server.location.contexthub."],
include_annotations: ["android.platform.test.annotations.Postsubmit"],
- exclude_annotations: FLAKY_AND_IGNORED,
}
test_module_config {
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityManagerServiceTest.java b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityManagerServiceTest.java
index 2e6c93cb92aa..566feb7e3d80 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityManagerServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityManagerServiceTest.java
@@ -35,6 +35,7 @@ import static com.android.internal.accessibility.common.ShortcutConstants.UserSh
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
+import static com.android.internal.accessibility.dialog.AccessibilityButtonChooserActivity.EXTRA_TYPE_TO_CHOOSE;
import static com.android.server.accessibility.AccessibilityManagerService.ACTION_LAUNCH_HEARING_DEVICES_DIALOG;
import static com.android.window.flags.Flags.FLAG_ALWAYS_DRAW_MAGNIFICATION_FULLSCREEN_BORDER;
@@ -2046,6 +2047,53 @@ public class AccessibilityManagerServiceTest {
}
@Test
+ public void showAccessibilityTargetSelection_navBarNavigationMode_softwareExtra() {
+ mFakePermissionEnforcer.grant(Manifest.permission.STATUS_BAR_SERVICE);
+ final AccessibilityUserState userState = new AccessibilityUserState(
+ UserHandle.USER_SYSTEM, mTestableContext, mA11yms);
+ mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState);
+ Settings.Secure.putIntForUser(mTestableContext.getContentResolver(),
+ NAVIGATION_MODE, NAV_BAR_MODE_3BUTTON, userState.mUserId);
+
+ mA11yms.notifyAccessibilityButtonLongClicked(Display.DEFAULT_DISPLAY);
+ mTestableLooper.processAllMessages();
+
+ assertStartActivityWithExpectedShortcutType(mTestableContext.getMockContext(), SOFTWARE);
+ }
+
+ @Test
+ @DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void showAccessibilityTargetSelection_gestureNavigationMode_softwareExtra() {
+ mFakePermissionEnforcer.grant(Manifest.permission.STATUS_BAR_SERVICE);
+ final AccessibilityUserState userState = new AccessibilityUserState(
+ UserHandle.USER_SYSTEM, mTestableContext, mA11yms);
+ mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState);
+ Settings.Secure.putIntForUser(mTestableContext.getContentResolver(),
+ NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, userState.mUserId);
+
+ mA11yms.notifyAccessibilityButtonLongClicked(Display.DEFAULT_DISPLAY);
+ mTestableLooper.processAllMessages();
+
+ assertStartActivityWithExpectedShortcutType(mTestableContext.getMockContext(), SOFTWARE);
+ }
+
+ @Test
+ @EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void showAccessibilityTargetSelection_gestureNavigationMode_gestureExtra() {
+ mFakePermissionEnforcer.grant(Manifest.permission.STATUS_BAR_SERVICE);
+ final AccessibilityUserState userState = new AccessibilityUserState(
+ UserHandle.USER_SYSTEM, mTestableContext, mA11yms);
+ mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState);
+ Settings.Secure.putIntForUser(mTestableContext.getContentResolver(),
+ NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, userState.mUserId);
+
+ mA11yms.notifyAccessibilityButtonLongClicked(Display.DEFAULT_DISPLAY);
+ mTestableLooper.processAllMessages();
+
+ assertStartActivityWithExpectedShortcutType(mTestableContext.getMockContext(), GESTURE);
+ }
+
+ @Test
public void registerUserInitializationCompleteCallback_isRegistered() {
mA11yms.mUserInitializationCompleteCallbacks.clear();
@@ -2075,6 +2123,43 @@ public class AccessibilityManagerServiceTest {
UserHandle.MIN_SECONDARY_USER_ID);
}
+ @Test
+ @DisableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void getShortcutTypeForGenericShortcutCalls_softwareType() {
+ final AccessibilityUserState userState = new AccessibilityUserState(
+ UserHandle.USER_SYSTEM, mTestableContext, mA11yms);
+ mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState);
+
+ assertThat(mA11yms.getShortcutTypeForGenericShortcutCalls(userState.mUserId))
+ .isEqualTo(SOFTWARE);
+ }
+
+ @Test
+ @EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void getShortcutTypeForGenericShortcutCalls_gestureNavigationMode_gestureType() {
+ final AccessibilityUserState userState = new AccessibilityUserState(
+ UserHandle.USER_SYSTEM, mTestableContext, mA11yms);
+ mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState);
+ Settings.Secure.putIntForUser(mTestableContext.getContentResolver(),
+ NAVIGATION_MODE, NAV_BAR_MODE_GESTURAL, userState.mUserId);
+
+ assertThat(mA11yms.getShortcutTypeForGenericShortcutCalls(userState.mUserId))
+ .isEqualTo(GESTURE);
+ }
+
+ @Test
+ @EnableFlags(android.provider.Flags.FLAG_A11Y_STANDALONE_GESTURE_ENABLED)
+ public void getShortcutTypeForGenericShortcutCalls_buttonNavigationMode_softwareType() {
+ final AccessibilityUserState userState = new AccessibilityUserState(
+ UserHandle.USER_SYSTEM, mTestableContext, mA11yms);
+ mA11yms.mUserStates.put(UserHandle.USER_SYSTEM, userState);
+ Settings.Secure.putIntForUser(mTestableContext.getContentResolver(),
+ NAVIGATION_MODE, NAV_BAR_MODE_3BUTTON, userState.mUserId);
+
+ assertThat(mA11yms.getShortcutTypeForGenericShortcutCalls(userState.mUserId))
+ .isEqualTo(SOFTWARE);
+ }
+
private Set<String> readStringsFromSetting(String setting) {
final Set<String> result = new ArraySet<>();
mA11yms.readColonDelimitedSettingToSet(
@@ -2148,6 +2233,14 @@ public class AccessibilityManagerServiceTest {
Intent.EXTRA_COMPONENT_NAME)).isEqualTo(componentName);
}
+ private void assertStartActivityWithExpectedShortcutType(Context mockContext,
+ @UserShortcutType int shortcutType) {
+ verify(mockContext).startActivityAsUser(mIntentArgumentCaptor.capture(),
+ any(Bundle.class), any(UserHandle.class));
+ assertThat(mIntentArgumentCaptor.getValue().getIntExtra(
+ EXTRA_TYPE_TO_CHOOSE, -1)).isEqualTo(shortcutType);
+ }
+
private void setupShortcutTargetServices() {
setupShortcutTargetServices(mA11yms.getCurrentUserState());
}
diff --git a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityUserStateTest.java b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityUserStateTest.java
index 62fa95149067..627b5e39a20a 100644
--- a/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityUserStateTest.java
+++ b/services/tests/servicestests/src/com/android/server/accessibility/AccessibilityUserStateTest.java
@@ -28,10 +28,13 @@ import static android.view.accessibility.AccessibilityManager.STATE_FLAG_ACCESSI
import static android.view.accessibility.AccessibilityManager.STATE_FLAG_HIGH_TEXT_CONTRAST_ENABLED;
import static android.view.accessibility.AccessibilityManager.STATE_FLAG_TOUCH_EXPLORATION_ENABLED;
+import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.GESTURE;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.HARDWARE;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.QUICK_SETTINGS;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TRIPLETAP;
+import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.TWOFINGER_DOUBLETAP;
import static com.android.server.accessibility.AccessibilityUserState.doesShortcutTargetsStringContain;
import static com.google.common.truth.Truth.assertThat;
@@ -67,6 +70,8 @@ import androidx.test.InstrumentationRegistry;
import com.android.internal.R;
import com.android.internal.accessibility.AccessibilityShortcutController;
+import com.android.internal.accessibility.common.ShortcutConstants;
+import com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType;
import com.android.internal.util.test.FakeSettingsProvider;
import org.junit.After;
@@ -504,6 +509,36 @@ public class AccessibilityUserStateTest {
assertThat(actual).containsExactly(tileComponent, mMockServiceInfo);
}
+ @Test
+ public void isShortcutMagnificationEnabledLocked_anyShortcutType_returnsTrue() {
+ // Clear every shortcut
+ for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ setMagnificationForShortcutType(shortcutType, false);
+ }
+ // Check each shortcut individually
+ for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ // Setup
+ setMagnificationForShortcutType(shortcutType, true);
+
+ // Checking
+ assertThat(mUserState.getShortcutTargetsLocked(shortcutType))
+ .containsExactly(MAGNIFICATION_CONTROLLER_NAME);
+ assertThat(mUserState.isShortcutMagnificationEnabledLocked()).isTrue();
+
+ // Cleanup
+ setMagnificationForShortcutType(shortcutType, false);
+ }
+ }
+
+ @Test
+ public void isShortcutMagnificationEnabledLocked_noShortcutTypes_returnsFalse() {
+ // Clear every shortcut
+ for (int shortcutType : ShortcutConstants.USER_SHORTCUT_TYPES) {
+ setMagnificationForShortcutType(shortcutType, false);
+ }
+ assertThat(mUserState.isShortcutMagnificationEnabledLocked()).isFalse();
+ }
+
private int getSecureIntForUser(String key, int userId) {
return Settings.Secure.getIntForUser(mMockResolver, key, -1, userId);
}
@@ -511,4 +546,16 @@ public class AccessibilityUserStateTest {
private void putSecureIntForUser(String key, int value, int userId) {
Settings.Secure.putIntForUser(mMockResolver, key, value, userId);
}
+
+ private void setMagnificationForShortcutType(
+ @UserShortcutType int shortcutType, boolean enabled) {
+ if (shortcutType == TRIPLETAP) {
+ mUserState.setMagnificationSingleFingerTripleTapEnabledLocked(enabled);
+ } else if (shortcutType == TWOFINGER_DOUBLETAP) {
+ mUserState.setMagnificationTwoFingerTripleTapEnabledLocked(enabled);
+ } else {
+ mUserState.updateShortcutTargetsLocked(
+ enabled ? Set.of(MAGNIFICATION_CONTROLLER_NAME) : Set.of(), shortcutType);
+ }
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java b/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java
index 6b8e414255cd..b4b36125f770 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/BiometricServiceTest.java
@@ -558,7 +558,9 @@ public class BiometricServiceTest {
waitForIdle();
verify(mReceiver1).onError(
eq(BiometricAuthenticator.TYPE_NONE),
- eq(BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE),
+ eq(Flags.mandatoryBiometrics()
+ ? BiometricConstants.BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS
+ : BiometricConstants.BIOMETRIC_ERROR_HW_UNAVAILABLE),
eq(0 /* vendorCode */));
// Enrolled, not disabled in settings, user requires confirmation in settings
@@ -1450,7 +1452,9 @@ public class BiometricServiceTest {
}
@Test
- public void testCanAuthenticate_whenBiometricsNotEnabledForApps() throws Exception {
+ @RequiresFlagsDisabled(Flags.FLAG_MANDATORY_BIOMETRICS)
+ public void testCanAuthenticate_whenBiometricsNotEnabledForApps_returnsHardwareUnavailable()
+ throws Exception {
setupAuthForOnly(TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
when(mBiometricService.mSettingObserver.getEnabledForApps(anyInt())).thenReturn(false);
when(mTrustManager.isDeviceSecure(anyInt(), anyInt()))
@@ -1468,6 +1472,25 @@ public class BiometricServiceTest {
}
@Test
+ @RequiresFlagsEnabled(Flags.FLAG_MANDATORY_BIOMETRICS)
+ public void testCanAuthenticate_whenBiometricsNotEnabledForApps() throws Exception {
+ setupAuthForOnly(TYPE_FACE, Authenticators.BIOMETRIC_STRONG);
+ when(mBiometricService.mSettingObserver.getEnabledForApps(anyInt())).thenReturn(false);
+ when(mTrustManager.isDeviceSecure(anyInt(), anyInt()))
+ .thenReturn(true);
+
+ // When only biometric is requested
+ int authenticators = Authenticators.BIOMETRIC_STRONG;
+ assertEquals(BiometricManager.BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+
+ // When credential and biometric are requested
+ authenticators = Authenticators.BIOMETRIC_STRONG | Authenticators.DEVICE_CREDENTIAL;
+ assertEquals(BiometricManager.BIOMETRIC_SUCCESS,
+ invokeCanAuthenticate(mBiometricService, authenticators));
+ }
+
+ @Test
public void testCanAuthenticate_whenNoBiometricSensor() throws Exception {
mBiometricService = new BiometricService(mContext, mInjector, mBiometricHandlerProvider);
mBiometricService.onStart();
diff --git a/services/tests/servicestests/src/com/android/server/biometrics/PreAuthInfoTest.java b/services/tests/servicestests/src/com/android/server/biometrics/PreAuthInfoTest.java
index 760d38e855a6..b758f57ff407 100644
--- a/services/tests/servicestests/src/com/android/server/biometrics/PreAuthInfoTest.java
+++ b/services/tests/servicestests/src/com/android/server/biometrics/PreAuthInfoTest.java
@@ -20,6 +20,7 @@ import static android.app.admin.DevicePolicyManager.KEYGUARD_DISABLE_FEATURES_NO
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FACE;
import static android.hardware.biometrics.BiometricAuthenticator.TYPE_FINGERPRINT;
import static android.hardware.biometrics.BiometricManager.BIOMETRIC_ERROR_HW_UNAVAILABLE;
+import static android.hardware.biometrics.BiometricManager.BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS;
import static com.android.server.biometrics.sensors.LockoutTracker.LOCKOUT_NONE;
@@ -266,6 +267,29 @@ public class PreAuthInfoTest {
@Test
@RequiresFlagsEnabled(Flags.FLAG_MANDATORY_BIOMETRICS)
+ public void testCalculateByPriority()
+ throws Exception {
+ when(mFaceAuthenticator.hasEnrolledTemplates(anyInt(), any())).thenReturn(false);
+ when(mSettingObserver.getEnabledForApps(anyInt())).thenReturn(false);
+
+ BiometricSensor faceSensor = getFaceSensor();
+ BiometricSensor fingerprintSensor = getFingerprintSensor();
+ PromptInfo promptInfo = new PromptInfo();
+ promptInfo.setConfirmationRequested(false /* requireConfirmation */);
+ promptInfo.setAuthenticators(BiometricManager.Authenticators.BIOMETRIC_STRONG);
+ promptInfo.setDisallowBiometricsIfPolicyExists(false /* checkDevicePolicy */);
+ PreAuthInfo preAuthInfo = PreAuthInfo.create(mTrustManager, mDevicePolicyManager,
+ mSettingObserver, List.of(faceSensor, fingerprintSensor),
+ 0 /* userId */, promptInfo, TEST_PACKAGE_NAME,
+ false /* checkDevicePolicyManager */, mContext, mBiometricCameraManager);
+
+ assertThat(preAuthInfo.eligibleSensors).hasSize(0);
+ assertThat(preAuthInfo.getCanAuthenticateResult()).isEqualTo(
+ BIOMETRIC_ERROR_NOT_ENABLED_FOR_APPS);
+ }
+
+ @Test
+ @RequiresFlagsEnabled(Flags.FLAG_MANDATORY_BIOMETRICS)
public void testMandatoryBiometricsNegativeButtonText_whenSet()
throws Exception {
when(mTrustManager.isInSignificantPlace()).thenReturn(false);
diff --git a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTest.java b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTest.java
index 004c6c68781c..21129a7a9d85 100644
--- a/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTest.java
+++ b/services/tests/servicestests/src/com/android/server/hdmi/HdmiCecLocalDeviceTest.java
@@ -19,6 +19,7 @@ import static android.hardware.hdmi.HdmiDeviceInfo.DEVICE_TV;
import static com.android.server.SystemService.PHASE_SYSTEM_SERVICES_READY;
import static com.android.server.hdmi.Constants.ADDR_AUDIO_SYSTEM;
+import static com.android.server.hdmi.Constants.ADDR_BROADCAST;
import static com.android.server.hdmi.Constants.ADDR_PLAYBACK_1;
import static com.android.server.hdmi.Constants.ADDR_TV;
import static com.android.server.hdmi.Constants.MESSAGE_DEVICE_VENDOR_ID;
@@ -529,21 +530,32 @@ public class HdmiCecLocalDeviceTest {
public void handleVendorCommand_notHandled() {
HdmiCecMessage vendorCommand = HdmiCecMessageBuilder.buildVendorCommand(ADDR_TV,
ADDR_PLAYBACK_1, new byte[]{0});
- mNativeWrapper.onCecMessage(vendorCommand);
+ @Constants.HandleMessageResult int result =
+ mHdmiLocalDevice.handleVendorCommand(vendorCommand);
mTestLooper.dispatchAll();
- HdmiCecMessageBuilder.buildFeatureAbortCommand(ADDR_PLAYBACK_1, ADDR_TV,
- vendorCommand.getOpcode(), Constants.ABORT_REFUSED);
+ assertEquals(Constants.ABORT_REFUSED, result);
}
@Test
public void handleVendorCommandWithId_notHandled_Cec14() {
HdmiCecMessage vendorCommand = HdmiCecMessageBuilder.buildVendorCommandWithId(ADDR_TV,
ADDR_PLAYBACK_1, 0x1234, new byte[]{0});
- mNativeWrapper.onCecMessage(vendorCommand);
+ @Constants.HandleMessageResult int result =
+ mHdmiLocalDevice.handleVendorCommandWithId(vendorCommand);
mTestLooper.dispatchAll();
- HdmiCecMessageBuilder.buildFeatureAbortCommand(ADDR_PLAYBACK_1, ADDR_TV,
- vendorCommand.getOpcode(), Constants.ABORT_REFUSED);
+ assertEquals(Constants.ABORT_REFUSED, result);
+ }
+
+ @Test
+ public void handleVendorCommandWithId_broadcasted_handled() {
+ HdmiCecMessage vendorCommand = HdmiCecMessageBuilder.buildVendorCommandWithId(ADDR_TV,
+ ADDR_BROADCAST, 0x1234, new byte[]{0});
+ @Constants.HandleMessageResult int result =
+ mHdmiLocalDevice.handleVendorCommandWithId(vendorCommand);
+ mTestLooper.dispatchAll();
+
+ assertEquals(Constants.HANDLED, result);
}
}
diff --git a/services/tests/servicestests/src/com/android/server/webkit/TestSystemImpl.java b/services/tests/servicestests/src/com/android/server/webkit/TestSystemImpl.java
index cbf79356e9c4..def33551a820 100644
--- a/services/tests/servicestests/src/com/android/server/webkit/TestSystemImpl.java
+++ b/services/tests/servicestests/src/com/android/server/webkit/TestSystemImpl.java
@@ -19,7 +19,7 @@ package com.android.server.webkit;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageInfo;
import android.content.pm.PackageManager.NameNotFoundException;
-import android.content.pm.UserInfo;
+import android.os.UserHandle;
import android.webkit.UserPackage;
import android.webkit.WebViewProviderInfo;
@@ -137,16 +137,12 @@ public class TestSystemImpl implements SystemInterface {
List<UserPackage> ret = new ArrayList();
// Loop over defined users, and find the corresponding package for each user.
for (int userId : mUsers) {
- ret.add(new UserPackage(createUserInfo(userId),
+ ret.add(new UserPackage(UserHandle.of(userId),
userPackages == null ? null : userPackages.get(userId)));
}
return ret;
}
- private static UserInfo createUserInfo(int userId) {
- return new UserInfo(userId, "User nr. " + userId, 0 /* flags */);
- }
-
/**
* Set package for primary user.
*/
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java b/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java
index b5bc610f82ea..2effc692e877 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/BubbleExtractorTest.java
@@ -30,9 +30,9 @@ import static junit.framework.Assert.assertNotNull;
import static junit.framework.Assert.assertNull;
import static junit.framework.Assert.assertTrue;
-import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.when;
@@ -44,6 +44,8 @@ import android.app.PendingIntent;
import android.app.Person;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ResolveInfo;
import android.content.pm.ShortcutInfo;
import android.os.SystemClock;
import android.os.UserHandle;
@@ -89,6 +91,8 @@ public class BubbleExtractorTest extends UiServiceTestCase {
@Mock
ShortcutHelper mShortcutHelper;
@Mock
+ PackageManager mPackageManager;
+ @Mock
ActivityManager mActivityManager;
@Before
@@ -98,6 +102,7 @@ public class BubbleExtractorTest extends UiServiceTestCase {
mBubbleExtractor.initialize(mContext, mock(NotificationUsageStats.class));
mBubbleExtractor.setConfig(mConfig);
mBubbleExtractor.setShortcutHelper(mShortcutHelper);
+ mBubbleExtractor.setPackageManager(mPackageManager);
mBubbleExtractor.setActivityManager(mActivityManager);
mChannel = new NotificationChannel(CHANNEL_ID, CHANNEL_ID, IMPORTANCE_DEFAULT);
@@ -106,7 +111,7 @@ public class BubbleExtractorTest extends UiServiceTestCase {
}
/* NotificationRecord that fulfills conversation requirements (message style + shortcut) */
- private NotificationRecord getNotificationRecord(boolean addBubble) {
+ private NotificationRecord getNotificationRecord(boolean addBubble, UserHandle user) {
final Builder builder = new Builder(getContext())
.setContentTitle("foo")
.setSmallIcon(android.R.drawable.sym_def_app_icon)
@@ -127,13 +132,13 @@ public class BubbleExtractorTest extends UiServiceTestCase {
n.setBubbleMetadata(mBubbleMetadata);
}
StatusBarNotification sbn = new StatusBarNotification(PKG, PKG, ID, TAG, UID,
- PID, n, mUser, null, System.currentTimeMillis());
+ PID, n, user, null, System.currentTimeMillis());
NotificationRecord r = new NotificationRecord(getContext(), sbn, mChannel);
r.setShortcutInfo(mShortcutInfo);
return r;
}
- void setUpIntentBubble(boolean isValid) {
+ void setUpIntentBubble(boolean isValid, UserHandle user) {
when(mPendingIntent.getIntent()).thenReturn(mIntent);
when(mBubbleMetadata.getIntent()).thenReturn(mPendingIntent);
when(mBubbleMetadata.getShortcutId()).thenReturn(null);
@@ -143,18 +148,21 @@ public class BubbleExtractorTest extends UiServiceTestCase {
info.resizeMode = isValid
? RESIZE_MODE_RESIZEABLE
: RESIZE_MODE_UNRESIZEABLE;
- when(mIntent.resolveActivityInfo(any(), anyInt())).thenReturn(info);
+ ResolveInfo resolveInfo = new ResolveInfo();
+ resolveInfo.activityInfo = info;
+ when(mPackageManager.resolveActivityAsUser(eq(mIntent), eq(0), eq(user.getIdentifier())))
+ .thenReturn(resolveInfo);
}
- void setUpShortcutBubble(boolean isValid) {
+ void setUpShortcutBubble(boolean isValid, UserHandle user) {
when(mBubbleMetadata.getShortcutId()).thenReturn(SHORTCUT_ID);
when(mBubbleMetadata.getIntent()).thenReturn(null);
ShortcutInfo answer = isValid ? mShortcutInfo : null;
- when(mShortcutHelper.getValidShortcutInfo(SHORTCUT_ID, PKG, mUser)).thenReturn(answer);
+ when(mShortcutHelper.getValidShortcutInfo(SHORTCUT_ID, PKG, user)).thenReturn(answer);
}
- void setUpBubblesEnabled(boolean feature, int app, int channel) {
- when(mConfig.bubblesEnabled(mUser)).thenReturn(feature);
+ void setUpBubblesEnabled(boolean feature, int app, int channel, UserHandle user) {
+ when(mConfig.bubblesEnabled(user)).thenReturn(feature);
when(mConfig.getBubblePreference(anyString(), anyInt())).thenReturn(app);
mChannel.setAllowBubbles(channel);
}
@@ -167,10 +175,11 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testAppYesChannelNo() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- ALLOW_BUBBLE_OFF /* channel */);
+ ALLOW_BUBBLE_OFF /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ setUpShortcutBubble(true /* isValid */, mUser);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
assertFalse(r.canBubble());
@@ -181,10 +190,11 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testAppYesChannelDefault() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ setUpShortcutBubble(true /* isValid */, mUser);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
@@ -195,10 +205,11 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testAppYesChannelYes() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- ALLOW_BUBBLE_ON /* channel */);
+ ALLOW_BUBBLE_ON /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ setUpShortcutBubble(true /* isValid */, mUser);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
@@ -209,10 +220,11 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testAppYesChannelYesFeatureNo() {
setUpBubblesEnabled(false /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- ALLOW_BUBBLE_ON /* channel */);
+ ALLOW_BUBBLE_ON /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ setUpShortcutBubble(true /* isValid */, mUser);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
@@ -224,10 +236,11 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testAppNoChannelYes() throws Exception {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_NONE /* app */,
- ALLOW_BUBBLE_ON /* channel */);
+ ALLOW_BUBBLE_ON /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ setUpShortcutBubble(true /* isValid */, mUser);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
@@ -239,10 +252,11 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testAppNoChannelDefault() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_NONE /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ setUpShortcutBubble(true /* isValid */, mUser);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
@@ -254,10 +268,11 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testAppSelectedChannelDefault() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_SELECTED /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ setUpShortcutBubble(true /* isValid */, mUser);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
@@ -269,10 +284,11 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testAppSelectedChannelNo() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_SELECTED /* app */,
- ALLOW_BUBBLE_OFF /* channel */);
+ ALLOW_BUBBLE_OFF /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ setUpShortcutBubble(true /* isValid */, mUser);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
@@ -284,11 +300,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testAppSeletedChannelYes() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_SELECTED /* app */,
- ALLOW_BUBBLE_ON /* channel */);
+ ALLOW_BUBBLE_ON /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
+ setUpShortcutBubble(true /* isValid */, mUser);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
@@ -299,11 +316,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testAppSeletedChannelYesFeatureNo() {
setUpBubblesEnabled(false /* feature */,
BUBBLE_PREFERENCE_SELECTED /* app */,
- ALLOW_BUBBLE_ON /* channel */);
+ ALLOW_BUBBLE_ON /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
+ setUpShortcutBubble(true /* isValid */, mUser);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
@@ -319,11 +337,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_false_previouslyRemoved() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
+ setUpShortcutBubble(true /* isValid */, mUser);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
r.setFlagBubbleRemoved(true);
mBubbleExtractor.process(r);
@@ -337,11 +356,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_true_shortcutBubble() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(true /* isValid */);
+ setUpShortcutBubble(true /* isValid */, mUser);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
assertTrue(r.canBubble());
@@ -353,11 +373,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_true_intentBubble() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpIntentBubble(true /* isValid */);
+ setUpIntentBubble(true /* isValid */, mUser);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
assertTrue(r.canBubble());
@@ -369,11 +390,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_false_noIntentInvalidShortcut() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpShortcutBubble(false /* isValid */);
+ setUpShortcutBubble(false /* isValid */, mUser);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
r.setShortcutInfo(null);
mBubbleExtractor.process(r);
@@ -386,11 +408,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_false_invalidIntentNoShortcut() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpIntentBubble(false /* isValid */);
+ setUpIntentBubble(false /* isValid */, mUser);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
r.setShortcutInfo(null);
mBubbleExtractor.process(r);
@@ -403,11 +426,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_false_noIntentNoShortcut() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
// Shortcut here is for the notification not the bubble
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
assertFalse(r.canBubble());
@@ -419,10 +443,11 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_false_noMetadata() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- NotificationRecord r = getNotificationRecord(false /* bubble */);
+ NotificationRecord r = getNotificationRecord(false /* bubble */, mUser);
mBubbleExtractor.process(r);
assertFalse(r.canBubble());
@@ -434,11 +459,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_false_noShortcut() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpIntentBubble(true /* isValid */);
+ setUpIntentBubble(true /* isValid */, mUser);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
r.setShortcutInfo(null);
r.getNotification().extras.putString(Notification.EXTRA_TEMPLATE, null);
@@ -453,11 +479,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_false_notConversation() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(false);
- setUpIntentBubble(true /* isValid */);
+ setUpIntentBubble(true /* isValid */, mUser);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
r.userDemotedAppFromConvoSpace(true);
r.getNotification().extras.putString(Notification.EXTRA_TEMPLATE, null);
@@ -472,11 +499,12 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_false_lowRamDevice() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(true);
- setUpIntentBubble(true /* isValid */);
+ setUpIntentBubble(true /* isValid */, mUser);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
assertFalse(r.canBubble());
@@ -488,12 +516,13 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_false_noIntent() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(true);
- setUpIntentBubble(true /* isValid */);
+ setUpIntentBubble(true /* isValid */, mUser);
when(mPendingIntent.getIntent()).thenReturn(null);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
assertFalse(r.canBubble());
@@ -505,13 +534,15 @@ public class BubbleExtractorTest extends UiServiceTestCase {
public void testFlagBubble_false_noActivityInfo() {
setUpBubblesEnabled(true /* feature */,
BUBBLE_PREFERENCE_ALL /* app */,
- DEFAULT_ALLOW_BUBBLE /* channel */);
+ DEFAULT_ALLOW_BUBBLE /* channel */,
+ mUser);
when(mActivityManager.isLowRamDevice()).thenReturn(true);
- setUpIntentBubble(true /* isValid */);
+ setUpIntentBubble(true /* isValid */, mUser);
when(mPendingIntent.getIntent()).thenReturn(mIntent);
- when(mIntent.resolveActivityInfo(any(), anyInt())).thenReturn(null);
+ when(mPackageManager.resolveActivityAsUser(eq(mIntent), eq(0), eq(mUser.getIdentifier())))
+ .thenReturn(null);
- NotificationRecord r = getNotificationRecord(true /* bubble */);
+ NotificationRecord r = getNotificationRecord(true /* bubble */, mUser);
mBubbleExtractor.process(r);
assertFalse(r.canBubble());
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
index 6a1140cc84e9..196bc47572ba 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationManagerServiceTest.java
@@ -1255,7 +1255,7 @@ public class NotificationManagerServiceTest extends UiServiceTestCase {
info.resizeMode = RESIZE_MODE_RESIZEABLE;
ResolveInfo ri = new ResolveInfo();
ri.activityInfo = info;
- when(mPackageManagerClient.resolveActivity(any(), anyInt())).thenReturn(ri);
+ when(mPackageManagerClient.resolveActivityAsUser(any(), anyInt(), anyInt())).thenReturn(ri);
return new Notification.BubbleMetadata.Builder(
mActivityIntent,
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java b/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
index f572e7aa1706..50a5f658f059 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/NotificationRecordTest.java
@@ -62,6 +62,8 @@ import android.content.res.Resources;
import android.graphics.Color;
import android.graphics.drawable.Icon;
import android.media.AudioAttributes;
+import android.media.RingtoneManager;
+import android.media.Utils;
import android.metrics.LogMaker;
import android.net.Uri;
import android.os.Build;
@@ -69,6 +71,7 @@ import android.os.Bundle;
import android.os.UserHandle;
import android.os.VibrationEffect;
import android.os.Vibrator;
+import android.os.VibratorInfo;
import android.platform.test.annotations.EnableFlags;
import android.platform.test.flag.junit.SetFlagsRule;
import android.provider.Settings;
@@ -93,6 +96,9 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
import java.util.ArrayList;
@SmallTest
@@ -141,6 +147,7 @@ public class NotificationRecordTest extends UiServiceTestCase {
when(mMockContext.getSystemService(eq(Vibrator.class))).thenReturn(mVibrator);
when(mVibrator.areVibrationFeaturesSupported(any())).thenReturn(true);
+ when(mVibrator.getInfo()).thenReturn(VibratorInfo.EMPTY_VIBRATOR_INFO);
final Resources res = mContext.getResources();
when(mMockContext.getResources()).thenReturn(res);
when(mMockContext.getPackageManager()).thenReturn(mPm);
@@ -511,6 +518,51 @@ public class NotificationRecordTest extends UiServiceTestCase {
}
@Test
+ @EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_VIBRATION_IN_SOUND_URI)
+ public void testVibration_customVibrationForSound_withoutVibrationUri() {
+ // prepare testing data
+ Uri backupDefaultUri = RingtoneManager.getActualDefaultRingtoneUri(mMockContext,
+ RingtoneManager.TYPE_NOTIFICATION);
+ RingtoneManager.setActualDefaultRingtoneUri(mMockContext, RingtoneManager.TYPE_NOTIFICATION,
+ Settings.System.DEFAULT_NOTIFICATION_URI);
+ defaultChannel.enableVibration(true);
+ defaultChannel.setSound(Settings.System.DEFAULT_NOTIFICATION_URI, CUSTOM_ATTRIBUTES);
+ StatusBarNotification sbn = getNotification(
+ /* channelVibrationPattern= */ null,
+ /* channelVibrationEffect= */ null,
+ /* insistent= */ false);
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
+
+ try {
+ assertEquals(
+ new VibratorHelper(mMockContext).createDefaultVibration(false),
+ record.getVibration());
+ } finally {
+ // restore the data
+ RingtoneManager.setActualDefaultRingtoneUri(mMockContext,
+ RingtoneManager.TYPE_NOTIFICATION,
+ backupDefaultUri);
+ }
+ }
+
+ @Test
+ @EnableFlags(com.android.server.notification.Flags.FLAG_NOTIFICATION_VIBRATION_IN_SOUND_URI)
+ public void testVibration_customVibrationForSound_withVibrationUri() throws IOException {
+ defaultChannel.enableVibration(true);
+ VibrationInfo vibration = getTestingVibration(mVibrator);
+ Uri uriWithVibration = getVibrationUriAppended(
+ Settings.System.DEFAULT_NOTIFICATION_URI, vibration.mUri);
+ defaultChannel.setSound(uriWithVibration, CUSTOM_ATTRIBUTES);
+ StatusBarNotification sbn = getNotification(
+ /* channelVibrationPattern= */ null,
+ /* channelVibrationEffect= */ null,
+ /* insistent= */ false);
+ NotificationRecord record = new NotificationRecord(mMockContext, sbn, defaultChannel);
+
+ assertEquals(vibration.mVibrationEffect, record.getVibration());
+ }
+
+ @Test
public void testImportance_preUpgrade() {
StatusBarNotification sbn = getNotification(PKG_N_MR1, true /* noisy */,
true /* defaultSound */, false /* buzzy */, false /* defaultBuzz */,
@@ -1594,4 +1646,39 @@ public class NotificationRecordTest extends UiServiceTestCase {
assertThat(record.getAudioAttributes().getUsage()).isEqualTo(USAGE_ALARM);
}
+
+ static class VibrationInfo {
+ public VibrationEffect mVibrationEffect;
+ public Uri mUri;
+ VibrationInfo(VibrationEffect vibrationEffect, Uri uri) {
+ mVibrationEffect = vibrationEffect;
+ mUri = uri;
+ }
+ }
+
+ private static VibrationInfo getTestingVibration(Vibrator vibrator) throws IOException {
+ File tempVibrationFile = File.createTempFile("test_vibration_file", ".xml");
+ FileWriter writer = new FileWriter(tempVibrationFile);
+ writer.write("<vibration-effect>\n"
+ + " <waveform-effect>\n"
+ + " <!-- PRIMING -->\n"
+ + " <waveform-entry durationMs=\"0\" amplitude=\"0\"/>\n"
+ + " <waveform-entry durationMs=\"12\" amplitude=\"255\"/>\n"
+ + " <waveform-entry durationMs=\"250\" amplitude=\"0\"/>\n"
+ + " <waveform-entry durationMs=\"12\" amplitude=\"255\"/>\n"
+ + " <waveform-entry durationMs=\"500\" amplitude=\"0\"/>\n"
+ + " </waveform-effect>\n"
+ + "</vibration-effect>"); // Your test XML content
+ writer.close();
+ Uri vibrationUri = Uri.parse(tempVibrationFile.toURI().toString());
+
+ VibrationEffect vibrationEffect = Utils.parseVibrationEffect(vibrator, vibrationUri);
+ return new VibrationInfo(vibrationEffect, vibrationUri);
+ }
+
+ private static Uri getVibrationUriAppended(Uri audioUri, Uri vibrationUri) {
+ Uri.Builder builder = audioUri.buildUpon();
+ builder.appendQueryParameter(Utils.VIBRATION_URI_PARAM, vibrationUri.toString());
+ return builder.build();
+ }
}
diff --git a/services/tests/uiservicestests/src/com/android/server/notification/VibratorHelperTest.java b/services/tests/uiservicestests/src/com/android/server/notification/VibratorHelperTest.java
index 0993bec42c6a..4d2396c78d16 100644
--- a/services/tests/uiservicestests/src/com/android/server/notification/VibratorHelperTest.java
+++ b/services/tests/uiservicestests/src/com/android/server/notification/VibratorHelperTest.java
@@ -22,8 +22,12 @@ import static junit.framework.Assert.assertTrue;
import static org.mockito.Mockito.when;
+import android.media.Utils;
+import android.net.Uri;
import android.os.VibrationEffect;
import android.os.Vibrator;
+import android.os.VibratorInfo;
+import android.provider.Settings;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
@@ -36,6 +40,10 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
@SmallTest
@RunWith(AndroidJUnit4.class)
public class VibratorHelperTest extends UiServiceTestCase {
@@ -86,7 +94,34 @@ public class VibratorHelperTest extends UiServiceTestCase {
}
@Test
+ public void createVibrationEffectFromSoundUri_nullInput() {
+ assertNull(mVibratorHelper.createVibrationEffectFromSoundUri(null));
+ }
+
+ @Test
+ public void createVibrationEffectFromSoundUri_emptyUri() {
+ assertNull(mVibratorHelper.createVibrationEffectFromSoundUri(Uri.EMPTY));
+ }
+
+ @Test
+ public void createVibrationEffectFromSoundUri_uriWithoutRequiredQueryParameter() {
+ Uri uri = Settings.System.DEFAULT_NOTIFICATION_URI;
+ assertNull(mVibratorHelper.createVibrationEffectFromSoundUri(uri));
+ }
+
+ @Test
+ public void createVibrationEffectFromSoundUri_uriWithVibrationUri() throws IOException {
+ // prepare the uri with vibration
+ when(mVibrator.getInfo()).thenReturn(VibratorInfo.EMPTY_VIBRATOR_INFO);
+ Uri validUri = getVibrationUriAppended(Settings.System.DEFAULT_NOTIFICATION_URI);
+
+ assertSingleVibration(mVibratorHelper.createVibrationEffectFromSoundUri(validUri));
+ }
+
+ @Test
public void createVibration_insistent_createsRepeatingVibration() {
+ when(mVibrator.getInfo()).thenReturn(VibratorInfo.EMPTY_VIBRATOR_INFO);
+
when(mVibrator.hasFrequencyControl()).thenReturn(false);
assertRepeatingVibration(mVibratorHelper.createDefaultVibration(/* insistent= */ true));
assertRepeatingVibration(mVibratorHelper.createFallbackVibration(/* insistent= */ true));
@@ -98,6 +133,8 @@ public class VibratorHelperTest extends UiServiceTestCase {
@Test
public void createVibration_nonInsistent_createsSingleShotVibration() {
+ when(mVibrator.getInfo()).thenReturn(VibratorInfo.EMPTY_VIBRATOR_INFO);
+
when(mVibrator.hasFrequencyControl()).thenReturn(false);
assertSingleVibration(mVibratorHelper.createDefaultVibration(/* insistent= */ false));
assertSingleVibration(mVibratorHelper.createFallbackVibration(/* insistent= */ false));
@@ -120,4 +157,26 @@ public class VibratorHelperTest extends UiServiceTestCase {
effect instanceof VibrationEffect.Composed);
return ((VibrationEffect.Composed) effect).getRepeatIndex();
}
+
+ private static Uri getVibrationUriAppended(Uri baseUri) throws IOException {
+ File tempVibrationFile = File.createTempFile("test_vibration_file", ".xml");
+ FileWriter writer = new FileWriter(tempVibrationFile);
+ writer.write("<vibration-effect>\n"
+ + " <waveform-effect>\n"
+ + " <!-- PRIMING -->\n"
+ + " <waveform-entry durationMs=\"0\" amplitude=\"0\"/>\n"
+ + " <waveform-entry durationMs=\"12\" amplitude=\"255\"/>\n"
+ + " <waveform-entry durationMs=\"250\" amplitude=\"0\"/>\n"
+ + " <waveform-entry durationMs=\"12\" amplitude=\"255\"/>\n"
+ + " <waveform-entry durationMs=\"500\" amplitude=\"0\"/>\n"
+ + " </waveform-effect>\n"
+ + "</vibration-effect>"); // Your test XML content
+ writer.close();
+
+ Uri.Builder builder = baseUri.buildUpon();
+ builder.appendQueryParameter(
+ Utils.VIBRATION_URI_PARAM,
+ tempVibrationFile.toURI().toString());
+ return builder.build();
+ }
}
diff --git a/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorControllerProvider.java b/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorControllerProvider.java
index 031d1c29a215..946e1eaa5666 100644
--- a/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorControllerProvider.java
+++ b/services/tests/vibrator/utils/com/android/server/vibrator/FakeVibratorControllerProvider.java
@@ -68,6 +68,9 @@ public final class FakeVibratorControllerProvider {
private int[] mSupportedPrimitives;
private int mCompositionSizeMax;
private int mPwleSizeMax;
+ private int mMaxEnvelopeEffectSize;
+ private int mMinEnvelopeEffectControlPointDurationMillis;
+ private int mMaxEnvelopeEffectControlPointDurationMillis;
private float mMinFrequency = Float.NaN;
private float mResonantFrequency = Float.NaN;
private float mFrequencyResolution = Float.NaN;
@@ -217,6 +220,11 @@ public final class FakeVibratorControllerProvider {
infoBuilder.setQFactor(mQFactor);
infoBuilder.setFrequencyProfile(new VibratorInfo.FrequencyProfile(
mResonantFrequency, mMinFrequency, mFrequencyResolution, mMaxAmplitudes));
+ infoBuilder.setMaxEnvelopeEffectSize(mMaxEnvelopeEffectSize);
+ infoBuilder.setMinEnvelopeEffectControlPointDurationMillis(
+ mMinEnvelopeEffectControlPointDurationMillis);
+ infoBuilder.setMaxEnvelopeEffectControlPointDurationMillis(
+ mMaxEnvelopeEffectControlPointDurationMillis);
return mIsInfoLoadSuccessful;
}
@@ -358,6 +366,26 @@ public final class FakeVibratorControllerProvider {
}
/**
+ * Set the maximum number of envelope effects control points supported in fake vibrator
+ * hardware.
+ */
+ public void setMaxEnvelopeEffectSize(int envelopeEffectControlPointsMax) {
+ mMaxEnvelopeEffectSize = envelopeEffectControlPointsMax;
+ }
+
+ /** Set the envelope effect minimum segment duration in fake vibrator hardware. */
+ public void setMinEnvelopeEffectControlPointDurationMillis(
+ int minEnvelopeEffectControlPointDurationMillis) {
+ mMinEnvelopeEffectControlPointDurationMillis = minEnvelopeEffectControlPointDurationMillis;
+ }
+
+ /** Set the envelope effect maximum segment duration in fake vibrator hardware. */
+ public void setMaxEnvelopeEffectControlPointDurationMillis(
+ int maxEnvelopeEffectControlPointDurationMillis) {
+ mMaxEnvelopeEffectControlPointDurationMillis = maxEnvelopeEffectControlPointDurationMillis;
+ }
+
+ /**
* Return the amplitudes set by this controller, including zeroes for each time the vibrator was
* turned off.
*/
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java b/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java
index a7a08b25fba2..8227ed915c8e 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppCompatActivityRobot.java
@@ -139,11 +139,6 @@ class AppCompatActivityRobot {
/* isUnresizable */ true);
}
- void activateCameraInPolicy(boolean isCameraActive) {
- doReturn(isCameraActive).when(mDisplayContent.mAppCompatCameraPolicy)
- .isCameraActive(any(ActivityRecord.class), anyBoolean());
- }
-
void setDisplayNaturalOrientation(@Configuration.Orientation int naturalOrientation) {
doReturn(naturalOrientation).when(mDisplayContent).getNaturalOrientation();
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppCompatCameraOverridesTest.java b/services/tests/wmtests/src/com/android/server/wm/AppCompatCameraOverridesTest.java
index ba2a7335824c..d66c21a77fcd 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppCompatCameraOverridesTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppCompatCameraOverridesTest.java
@@ -267,7 +267,6 @@ public class AppCompatCameraOverridesTest extends WindowTestsBase {
robot.conf().enableCameraCompatSplitScreenAspectRatio(true);
robot.applyOnActivity((a) -> {
a.createActivityWithComponentInNewTask();
- a.activateCameraInPolicy(true);
a.setShouldCreateCompatDisplayInsets(false);
});
@@ -276,27 +275,12 @@ public class AppCompatCameraOverridesTest extends WindowTestsBase {
}
@Test
- public void testIsCameraActive() {
- runTestScenario((robot) -> {
- robot.applyOnActivity((a) -> {
- a.createActivityWithComponent();
- a.activateCameraInPolicy(/* isCameraActive */ false);
- robot.checkIsCameraActive(/* active */ false);
- a.activateCameraInPolicy(/* isCameraActive */ true);
- robot.checkIsCameraActive(/* active */ true);
- });
- });
- }
-
-
- @Test
@EnableCompatChanges({OVERRIDE_MIN_ASPECT_RATIO_ONLY_FOR_CAMERA})
public void shouldOverrideMinAspectRatioForCamera_overrideEnabled_returnsTrue() {
runTestScenario((robot) -> {
robot.activity().createActivityWithComponent();
- robot.activity().activateCameraInPolicy(/* isCameraActive */ true);
- robot.checkShouldOverrideMinAspectRatioForCamera(/* expected */ true);
+ robot.checkIsOverrideMinAspectRatioForCameraEnabled(/* expected */ true);
});
}
@@ -306,21 +290,8 @@ public class AppCompatCameraOverridesTest extends WindowTestsBase {
runTestScenario((robot) -> {
robot.prop().enable(PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE);
robot.activity().createActivityWithComponent();
- robot.activity().activateCameraInPolicy(/* isCameraActive */ true);
- robot.checkShouldOverrideMinAspectRatioForCamera(/* expected */ true);
- });
- }
-
- @Test
- @EnableCompatChanges({OVERRIDE_MIN_ASPECT_RATIO_ONLY_FOR_CAMERA})
- public void shouldOverrideMinAspectRatioForCamera_propertyTrue_overrideEnabled_returnsFalse() {
- runTestScenario((robot) -> {
- robot.prop().enable(PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE);
- robot.activity().createActivityWithComponent();
- robot.activity().activateCameraInPolicy(/* isCameraActive */ false);
-
- robot.checkShouldOverrideMinAspectRatioForCamera(/* expected */ false);
+ robot.checkIsOverrideMinAspectRatioForCameraEnabled(/* expected */ true);
});
}
@@ -330,9 +301,8 @@ public class AppCompatCameraOverridesTest extends WindowTestsBase {
runTestScenario((robot) -> {
robot.prop().enable(PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE);
robot.activity().createActivityWithComponent();
- robot.activity().activateCameraInPolicy(/* isCameraActive */ true);
- robot.checkShouldOverrideMinAspectRatioForCamera(/* expected */ false);
+ robot.checkIsOverrideMinAspectRatioForCameraEnabled(/* expected */ false);
});
}
@@ -341,9 +311,8 @@ public class AppCompatCameraOverridesTest extends WindowTestsBase {
public void shouldOverrideMinAspectRatioForCamera_overrideDisabled_returnsFalse() {
runTestScenario((robot) -> {
robot.activity().createActivityWithComponent();
- robot.activity().activateCameraInPolicy(/* isCameraActive */ true);
- robot.checkShouldOverrideMinAspectRatioForCamera(/* expected */ false);
+ robot.checkIsOverrideMinAspectRatioForCameraEnabled(/* expected */ false);
});
}
@@ -354,7 +323,7 @@ public class AppCompatCameraOverridesTest extends WindowTestsBase {
robot.prop().disable(PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE);
robot.activity().createActivityWithComponent();
- robot.checkShouldOverrideMinAspectRatioForCamera(/* expected */ false);
+ robot.checkIsOverrideMinAspectRatioForCameraEnabled(/* expected */ false);
});
}
@@ -364,9 +333,8 @@ public class AppCompatCameraOverridesTest extends WindowTestsBase {
runTestScenario((robot) -> {
robot.prop().disable(PROPERTY_COMPAT_ALLOW_MIN_ASPECT_RATIO_OVERRIDE);
robot.activity().createActivityWithComponent();
- robot.activity().activateCameraInPolicy(/* isCameraActive */ true);
- robot.checkShouldOverrideMinAspectRatioForCamera(/* expected */ false);
+ robot.checkIsOverrideMinAspectRatioForCameraEnabled(/* expected */ false);
});
}
@@ -412,13 +380,9 @@ public class AppCompatCameraOverridesTest extends WindowTestsBase {
.shouldApplyFreeformTreatmentForCameraCompat(), expected);
}
- void checkShouldOverrideMinAspectRatioForCamera(boolean expected) {
+ void checkIsOverrideMinAspectRatioForCameraEnabled(boolean expected) {
Assert.assertEquals(getAppCompatCameraOverrides()
- .shouldOverrideMinAspectRatioForCamera(), expected);
- }
-
- void checkIsCameraActive(boolean active) {
- Assert.assertEquals(getAppCompatCameraOverrides().isCameraActive(), active);
+ .isOverrideMinAspectRatioForCameraEnabled(), expected);
}
private AppCompatCameraOverrides getAppCompatCameraOverrides() {
diff --git a/services/tests/wmtests/src/com/android/server/wm/AppCompatCameraPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/AppCompatCameraPolicyTest.java
index 2ae23f88812a..d91b38efd40b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/AppCompatCameraPolicyTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/AppCompatCameraPolicyTest.java
@@ -16,6 +16,8 @@
package com.android.server.wm;
+import static android.content.pm.ActivityInfo.OVERRIDE_MIN_ASPECT_RATIO_ONLY_FOR_CAMERA;
+
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.window.flags.Flags.FLAG_CAMERA_COMPAT_FOR_FREEFORM;
@@ -31,6 +33,9 @@ import android.platform.test.annotations.Presubmit;
import androidx.annotation.NonNull;
+import libcore.junit.util.compat.CoreCompatChangeRule.DisableCompatChanges;
+import libcore.junit.util.compat.CoreCompatChangeRule.EnableCompatChanges;
+
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TestRule;
@@ -186,16 +191,6 @@ public class AppCompatCameraPolicyTest extends WindowTestsBase {
});
}
- /**
- * Runs a test scenario providing a Robot.
- */
- void runTestScenario(@NonNull Consumer<AppCompatCameraPolicyRobotTest> consumer) {
- spyOn(mWm.mAppCompatConfiguration);
- final AppCompatCameraPolicyRobotTest robot =
- new AppCompatCameraPolicyRobotTest(mWm, mAtm, mSupervisor);
- consumer.accept(robot);
- }
-
@Test
public void testIsCameraCompatTreatmentActive_whenTreatmentForTopActivityIsEnabled() {
runTestScenario((robot) -> {
@@ -220,6 +215,58 @@ public class AppCompatCameraPolicyTest extends WindowTestsBase {
});
}
+ @Test
+ @EnableCompatChanges(OVERRIDE_MIN_ASPECT_RATIO_ONLY_FOR_CAMERA)
+ public void testShouldOverrideMinAspectRatioForCamera_whenCameraIsNotRunning() {
+ runTestScenario((robot) -> {
+ robot.applyOnActivity((a)-> {
+ robot.conf().enableCameraCompatTreatmentAtBuildTime(/* enabled= */ true);
+ a.createActivityWithComponentInNewTaskAndDisplay();
+ a.setTopActivityCameraActive(/* active */ false);
+ });
+
+ robot.checkShouldOverrideMinAspectRatioForCamera(/* active */ false);
+ });
+ }
+
+ @Test
+ @DisableCompatChanges(OVERRIDE_MIN_ASPECT_RATIO_ONLY_FOR_CAMERA)
+ public void testShouldOverrideMinAspectRatioForCamera_whenCameraIsRunning_overrideDisabled() {
+ runTestScenario((robot) -> {
+ robot.applyOnActivity((a)-> {
+ robot.conf().enableCameraCompatTreatmentAtBuildTime(/* enabled= */ true);
+ a.createActivityWithComponentInNewTaskAndDisplay();
+ a.setTopActivityCameraActive(/* active */ true);
+ });
+
+ robot.checkShouldOverrideMinAspectRatioForCamera(/* active */ false);
+ });
+ }
+
+ @Test
+ @EnableCompatChanges(OVERRIDE_MIN_ASPECT_RATIO_ONLY_FOR_CAMERA)
+ public void testShouldOverrideMinAspectRatioForCamera_whenCameraIsRunning_overrideEnabled() {
+ runTestScenario((robot) -> {
+ robot.applyOnActivity((a)-> {
+ robot.conf().enableCameraCompatTreatmentAtBuildTime(/* enabled= */ true);
+ a.createActivityWithComponentInNewTaskAndDisplay();
+ a.setTopActivityCameraActive(/* active */ true);
+ });
+
+ robot.checkShouldOverrideMinAspectRatioForCamera(/* active */ true);
+ });
+ }
+
+ /**
+ * Runs a test scenario providing a Robot.
+ */
+ void runTestScenario(@NonNull Consumer<AppCompatCameraPolicyRobotTest> consumer) {
+ final AppCompatCameraPolicyRobotTest robot =
+ new AppCompatCameraPolicyRobotTest(mWm, mAtm, mSupervisor);
+ consumer.accept(robot);
+ }
+
+
private static class AppCompatCameraPolicyRobotTest extends AppCompatRobotBase {
AppCompatCameraPolicyRobotTest(@NonNull WindowManagerService wm,
@NonNull ActivityTaskManagerService atm,
@@ -230,7 +277,14 @@ public class AppCompatCameraPolicyTest extends WindowTestsBase {
@Override
void onPostDisplayContentCreation(@NonNull DisplayContent displayContent) {
super.onPostDisplayContentCreation(displayContent);
+
spyOn(displayContent.mAppCompatCameraPolicy);
+ if (displayContent.mAppCompatCameraPolicy.mDisplayRotationCompatPolicy != null) {
+ spyOn(displayContent.mAppCompatCameraPolicy.mDisplayRotationCompatPolicy);
+ }
+ if (displayContent.mAppCompatCameraPolicy.mCameraCompatFreeformPolicy != null) {
+ spyOn(displayContent.mAppCompatCameraPolicy.mCameraCompatFreeformPolicy);
+ }
}
void checkTopActivityHasDisplayRotationCompatPolicy(boolean exists) {
@@ -268,6 +322,11 @@ public class AppCompatCameraPolicyTest extends WindowTestsBase {
.isTreatmentEnabledForActivity(activity().top()), active);
}
+ void checkShouldOverrideMinAspectRatioForCamera(boolean expected) {
+ assertEquals(getTopAppCompatCameraPolicy()
+ .shouldOverrideMinAspectRatioForCamera(activity().top()), expected);
+ }
+
// TODO(b/350460645): Create Desktop Windowing Robot to reuse common functionalities.
void allowEnterDesktopMode(boolean isAllowed) {
doReturn(isAllowed).when(() ->
diff --git a/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java b/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java
index e57e36d36621..1f3aa350b5b2 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DimmerTests.java
@@ -52,39 +52,14 @@ import org.junit.runner.RunWith;
@RunWith(WindowTestRunner.class)
public class DimmerTests extends WindowTestsBase {
- private static class TestWindowContainer extends WindowContainer<TestWindowContainer> {
- final SurfaceControl mControl = mock(SurfaceControl.class);
- final SurfaceControl.Transaction mPendingTransaction = spy(StubTransaction.class);
- final SurfaceControl.Transaction mSyncTransaction = spy(StubTransaction.class);
-
- TestWindowContainer(WindowManagerService wm) {
- super(wm);
- setVisibleRequested(true);
- }
-
- @Override
- public SurfaceControl getSurfaceControl() {
- return mControl;
- }
-
- @Override
- public SurfaceControl.Transaction getSyncTransaction() {
- return mSyncTransaction;
- }
-
- @Override
- public SurfaceControl.Transaction getPendingTransaction() {
- return mPendingTransaction;
- }
- }
-
- private static class MockSurfaceBuildingContainer extends WindowContainer<TestWindowContainer> {
+ private static class MockSurfaceBuildingContainer extends WindowContainer<WindowState> {
final SurfaceSession mSession = new SurfaceSession();
final SurfaceControl mHostControl = mock(SurfaceControl.class);
final SurfaceControl.Transaction mHostTransaction = spy(StubTransaction.class);
MockSurfaceBuildingContainer(WindowManagerService wm) {
super(wm);
+ mVisibleRequested = true;
}
class MockSurfaceBuilder extends SurfaceControl.Builder {
@@ -129,28 +104,41 @@ public class DimmerTests extends WindowTestsBase {
}
}
- private MockSurfaceBuildingContainer mHost;
private Dimmer mDimmer;
private SurfaceControl.Transaction mTransaction;
- private TestWindowContainer mChild;
+ private WindowState mChild1;
+ private WindowState mChild2;
private static AnimationAdapter sTestAnimation;
@Before
public void setUp() throws Exception {
- mHost = new MockSurfaceBuildingContainer(mWm);
- mTransaction = spy(StubTransaction.class);
- mChild = new TestWindowContainer(mWm);
+ MockSurfaceBuildingContainer host = new MockSurfaceBuildingContainer(mWm);
+ mTransaction = host.getSyncTransaction();
+
+ final SurfaceControl mControl1 = mock(SurfaceControl.class);
+ final SurfaceControl mControl2 = mock(SurfaceControl.class);
+
+ SurfaceAnimator animator = mock(SurfaceAnimator.class);
+ when(animator.getAnimation()).thenReturn(null);
+
+ mChild1 = mock(WindowState.class);
+ when(mChild1.getSurfaceControl()).thenReturn(mControl1);
+
+ mChild2 = mock(WindowState.class);
+ when(mChild2.getSurfaceControl()).thenReturn(mControl2);
+
+ host.addChild(mChild1, 0);
+ host.addChild(mChild2, 1);
+
sTestAnimation = spy(new MockAnimationAdapter());
- mDimmer = new Dimmer(mHost, new MockAnimationAdapterFactory());
+ mDimmer = new Dimmer(host, new MockAnimationAdapterFactory());
}
@Test
@RequiresFlagsDisabled(Flags.FLAG_USE_TASKS_DIM_ONLY)
public void testUpdateDimsAppliesCrop() {
- mHost.addChild(mChild, 0);
-
- mDimmer.adjustAppearance(mChild, 1, 1);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, 1, 1);
+ mDimmer.adjustPosition(mChild1, mChild1);
int width = 100;
int height = 300;
@@ -165,9 +153,8 @@ public class DimmerTests extends WindowTestsBase {
public void testDimBelowWithChildSurfaceCreatesSurfaceBelowChild() {
final float alpha = 0.7f;
final int blur = 50;
- mHost.addChild(mChild, 0);
- mDimmer.adjustAppearance(mChild, alpha, blur);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, alpha, blur);
+ mDimmer.adjustPosition(mChild1, mChild1);
SurfaceControl dimLayer = mDimmer.getDimLayer();
assertNotNull("Dimmer should have created a surface", dimLayer);
@@ -175,25 +162,23 @@ public class DimmerTests extends WindowTestsBase {
mDimmer.updateDims(mTransaction);
verify(sTestAnimation).startAnimation(eq(dimLayer), eq(mTransaction),
anyInt(), any(SurfaceAnimator.OnAnimationFinishedCallback.class));
- verify(mTransaction).setRelativeLayer(dimLayer, mChild.mControl, -1);
+ verify(mTransaction).setRelativeLayer(dimLayer, mChild1.getSurfaceControl(), -1);
verify(mTransaction, lastCall()).setAlpha(dimLayer, alpha);
verify(mTransaction).setBackgroundBlurRadius(dimLayer, blur);
}
@Test
public void testDimBelowWithChildSurfaceDestroyedWhenReset() {
- mHost.addChild(mChild, 0);
-
final float alpha = 0.8f;
final int blur = 50;
// Dim once
- mDimmer.adjustAppearance(mChild, alpha, blur);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, alpha, blur);
+ mDimmer.adjustPosition(mChild1, mChild1);
SurfaceControl dimLayer = mDimmer.getDimLayer();
mDimmer.updateDims(mTransaction);
// Reset, and don't dim
mDimmer.resetDimStates();
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustPosition(mChild1, mChild1);
mDimmer.updateDims(mTransaction);
verify(mTransaction).show(dimLayer);
verify(mTransaction).remove(dimLayer);
@@ -201,19 +186,17 @@ public class DimmerTests extends WindowTestsBase {
@Test
public void testDimBelowWithChildSurfaceNotDestroyedWhenPersisted() {
- mHost.addChild(mChild, 0);
-
final float alpha = 0.8f;
final int blur = 20;
// Dim once
- mDimmer.adjustAppearance(mChild, alpha, blur);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, alpha, blur);
+ mDimmer.adjustPosition(mChild1, mChild1);
SurfaceControl dimLayer = mDimmer.getDimLayer();
mDimmer.updateDims(mTransaction);
// Reset and dim again
mDimmer.resetDimStates();
- mDimmer.adjustAppearance(mChild, alpha, blur);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, alpha, blur);
+ mDimmer.adjustPosition(mChild1, mChild1);
mDimmer.updateDims(mTransaction);
verify(mTransaction).show(dimLayer);
verify(mTransaction, never()).remove(dimLayer);
@@ -222,10 +205,9 @@ public class DimmerTests extends WindowTestsBase {
@Test
@RequiresFlagsDisabled(Flags.FLAG_USE_TASKS_DIM_ONLY)
public void testDimUpdateWhileDimming() {
- mHost.addChild(mChild, 0);
final float alpha = 0.8f;
- mDimmer.adjustAppearance(mChild, alpha, 20);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, alpha, 20);
+ mDimmer.adjustPosition(mChild1, mChild1);
final Rect bounds = mDimmer.getDimBounds();
SurfaceControl dimLayer = mDimmer.getDimLayer();
@@ -243,9 +225,8 @@ public class DimmerTests extends WindowTestsBase {
@Test
public void testRemoveDimImmediately() {
- mHost.addChild(mChild, 0);
- mDimmer.adjustAppearance(mChild, 1, 2);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, 1, 2);
+ mDimmer.adjustPosition(mChild1, mChild1);
SurfaceControl dimLayer = mDimmer.getDimLayer();
mDimmer.updateDims(mTransaction);
verify(mTransaction, times(1)).show(dimLayer);
@@ -266,22 +247,20 @@ public class DimmerTests extends WindowTestsBase {
*/
@Test
public void testContainerDimsOpeningAnimationByItself() {
- mHost.addChild(mChild, 0);
-
mDimmer.resetDimStates();
- mDimmer.adjustAppearance(mChild, 0.1f, 0);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, 0.1f, 0);
+ mDimmer.adjustPosition(mChild1, mChild1);
SurfaceControl dimLayer = mDimmer.getDimLayer();
mDimmer.updateDims(mTransaction);
mDimmer.resetDimStates();
- mDimmer.adjustAppearance(mChild, 0.2f, 0);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, 0.2f, 0);
+ mDimmer.adjustPosition(mChild1, mChild1);
mDimmer.updateDims(mTransaction);
mDimmer.resetDimStates();
- mDimmer.adjustAppearance(mChild, 0.3f, 0);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, 0.3f, 0);
+ mDimmer.adjustPosition(mChild1, mChild1);
mDimmer.updateDims(mTransaction);
verify(mTransaction).setAlpha(dimLayer, 0.2f);
@@ -297,22 +276,20 @@ public class DimmerTests extends WindowTestsBase {
*/
@Test
public void testContainerDimsClosingAnimationByItself() {
- mHost.addChild(mChild, 0);
-
mDimmer.resetDimStates();
- mDimmer.adjustAppearance(mChild, 0.2f, 0);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, 0.2f, 0);
+ mDimmer.adjustPosition(mChild1, mChild1);
SurfaceControl dimLayer = mDimmer.getDimLayer();
mDimmer.updateDims(mTransaction);
mDimmer.resetDimStates();
- mDimmer.adjustAppearance(mChild, 0.1f, 0);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, 0.1f, 0);
+ mDimmer.adjustPosition(mChild1, mChild1);
mDimmer.updateDims(mTransaction);
mDimmer.resetDimStates();
- mDimmer.adjustAppearance(mChild, 0f, 0);
- mDimmer.adjustPosition(mChild, mChild, -1);
+ mDimmer.adjustAppearance(mChild1, 0f, 0);
+ mDimmer.adjustPosition(mChild1, mChild1);
mDimmer.updateDims(mTransaction);
mDimmer.resetDimStates();
@@ -325,19 +302,14 @@ public class DimmerTests extends WindowTestsBase {
*/
@Test
public void testMultipleContainersDimmingConsecutively() {
- TestWindowContainer first = mChild;
- TestWindowContainer second = new TestWindowContainer(mWm);
- mHost.addChild(first, 0);
- mHost.addChild(second, 1);
-
- mDimmer.adjustAppearance(first, 0.5f, 0);
- mDimmer.adjustPosition(mChild, first, -1);
+ mDimmer.adjustAppearance(mChild1, 0.5f, 0);
+ mDimmer.adjustPosition(mChild1, mChild1);
SurfaceControl dimLayer = mDimmer.getDimLayer();
mDimmer.updateDims(mTransaction);
mDimmer.resetDimStates();
- mDimmer.adjustAppearance(second, 0.9f, 0);
- mDimmer.adjustPosition(mChild, second, -1);
+ mDimmer.adjustAppearance(mChild2, 0.9f, 0);
+ mDimmer.adjustPosition(mChild1, mChild2);
mDimmer.updateDims(mTransaction);
verify(sTestAnimation, times(2)).startAnimation(
@@ -353,16 +325,11 @@ public class DimmerTests extends WindowTestsBase {
*/
@Test
public void testMultipleContainersDimmingAtTheSameTime() {
- TestWindowContainer first = mChild;
- TestWindowContainer second = new TestWindowContainer(mWm);
- mHost.addChild(first, 0);
- mHost.addChild(second, 1);
-
- mDimmer.adjustAppearance(first, 0.5f, 0);
- mDimmer.adjustPosition(mChild, first, -1);
+ mDimmer.adjustAppearance(mChild1, 0.5f, 0);
+ mDimmer.adjustPosition(mChild1, mChild1);
SurfaceControl dimLayer = mDimmer.getDimLayer();
- mDimmer.adjustAppearance(second, 0.9f, 0);
- mDimmer.adjustPosition(mChild, second, -1);
+ mDimmer.adjustAppearance(mChild2, 0.9f, 0);
+ mDimmer.adjustPosition(mChild1, mChild2);
mDimmer.updateDims(mTransaction);
verify(sTestAnimation, times(1)).startAnimation(
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java
index 2e488d8127bb..09fe75da18cb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationTests.java
@@ -22,6 +22,7 @@ import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_NOSENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_PORTRAIT;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_SENSOR;
import static android.content.pm.ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.DisplayCutout.NO_CUTOUT;
import static android.view.IWindowManager.FIXED_TO_USER_ROTATION_DEFAULT;
import static android.view.IWindowManager.FIXED_TO_USER_ROTATION_DISABLED;
@@ -78,7 +79,6 @@ import androidx.test.filters.SmallTest;
import com.android.internal.R;
import com.android.internal.util.test.FakeSettingsProvider;
-import com.android.server.LocalServices;
import com.android.server.UiThread;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.statusbar.StatusBarManagerInternal;
@@ -86,7 +86,6 @@ import com.android.server.testutils.OffsettableClock;
import com.android.server.testutils.TestHandler;
import com.android.server.wm.DisplayContent.FixedRotationTransitionListener;
-import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
@@ -168,25 +167,10 @@ public class DisplayRotationTests {
public void setUp() {
FakeSettingsProvider.clearSettingsProvider();
- mPreviousStatusBarManagerInternal = LocalServices.getService(
- StatusBarManagerInternal.class);
- LocalServices.removeServiceForTest(StatusBarManagerInternal.class);
- mMockStatusBarManagerInternal = mock(StatusBarManagerInternal.class);
- LocalServices.addService(StatusBarManagerInternal.class, mMockStatusBarManagerInternal);
mDisplayRotationImmersiveAppCompatPolicyMock = null;
mBuilder = new DisplayRotationBuilder();
}
- @After
- public void tearDown() {
- LocalServices.removeServiceForTest(StatusBarManagerInternal.class);
- if (mPreviousStatusBarManagerInternal != null) {
- LocalServices.addService(StatusBarManagerInternal.class,
- mPreviousStatusBarManagerInternal);
- mPreviousStatusBarManagerInternal = null;
- }
- }
-
// ================================
// Display Settings Related Tests
// ================================
@@ -677,7 +661,8 @@ public class DisplayRotationTests {
mOrientationSensorListener.onSensorChanged(createSensorEvent(Surface.ROTATION_90));
assertTrue(waitForUiHandler());
- verify(mMockStatusBarManagerInternal).onProposedRotationChanged(Surface.ROTATION_90, true);
+ verify(mMockStatusBarManagerInternal).onProposedRotationChanged(DEFAULT_DISPLAY,
+ Surface.ROTATION_90, true);
}
@Test
@@ -697,7 +682,8 @@ public class DisplayRotationTests {
mOrientationSensorListener.onSensorChanged(createSensorEvent(Surface.ROTATION_90));
assertTrue(waitForUiHandler());
- verify(mMockStatusBarManagerInternal).onProposedRotationChanged(Surface.ROTATION_90, true);
+ verify(mMockStatusBarManagerInternal).onProposedRotationChanged(DEFAULT_DISPLAY,
+ Surface.ROTATION_90, true);
// An imaginary ActivityRecord.setRequestedOrientation call disables immersive mode:
when(mDisplayRotationImmersiveAppCompatPolicyMock.isRotationLockEnforced(
@@ -728,7 +714,7 @@ public class DisplayRotationTests {
assertTrue(waitForUiHandler());
verify(mMockStatusBarManagerInternal)
- .onProposedRotationChanged(Surface.ROTATION_180, true);
+ .onProposedRotationChanged(DEFAULT_DISPLAY, Surface.ROTATION_180, true);
}
@Test
@@ -746,7 +732,7 @@ public class DisplayRotationTests {
assertTrue(waitForUiHandler());
verify(mMockStatusBarManagerInternal)
- .onProposedRotationChanged(Surface.ROTATION_180, false);
+ .onProposedRotationChanged(DEFAULT_DISPLAY, Surface.ROTATION_180, false);
}
@Test
@@ -773,7 +759,7 @@ public class DisplayRotationTests {
assertTrue(waitForUiHandler());
verify(mMockStatusBarManagerInternal)
- .onProposedRotationChanged(Surface.ROTATION_180, false);
+ .onProposedRotationChanged(DEFAULT_DISPLAY, Surface.ROTATION_180, false);
}
@Test
@@ -1526,6 +1512,7 @@ public class DisplayRotationTests {
mMockDisplayContent = mock(DisplayContent.class);
when(mMockDisplayContent.getDisplay()).thenReturn(mock(Display.class));
+ when(mMockDisplayContent.getDisplayId()).thenReturn(DEFAULT_DISPLAY);
mMockDisplayContent.isDefaultDisplay = mIsDefaultDisplay;
when(mMockDisplayContent.calculateDisplayCutoutForRotation(anyInt()))
.thenReturn(NO_CUTOUT);
@@ -1541,6 +1528,9 @@ public class DisplayRotationTests {
field.set(mMockDisplayContent, mock(FixedRotationTransitionListener.class));
mMockDisplayPolicy = mock(DisplayPolicy.class);
+ mMockStatusBarManagerInternal = mock(StatusBarManagerInternal.class);
+ when(mMockDisplayPolicy.getStatusBarManagerInternal()).thenReturn(
+ mMockStatusBarManagerInternal);
mMockRes = mock(Resources.class);
when(mMockContext.getResources()).thenReturn((mMockRes));
diff --git a/services/tests/wmtests/src/com/android/server/wm/LockTaskControllerTest.java b/services/tests/wmtests/src/com/android/server/wm/LockTaskControllerTest.java
index 1d14dc31fa26..bef4531c9f28 100644
--- a/services/tests/wmtests/src/com/android/server/wm/LockTaskControllerTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/LockTaskControllerTest.java
@@ -219,7 +219,7 @@ public class LockTaskControllerTest {
mLockTaskController.startLockTaskMode(tr, false, TEST_UID);
// THEN a pinning request should be shown
- verify(mStatusBarManagerInternal).showScreenPinningRequest(anyInt());
+ verify(mStatusBarManagerInternal).showScreenPinningRequest(anyInt(), anyInt());
}
@Test
@@ -769,9 +769,11 @@ public class LockTaskControllerTest {
private Task getTask(Intent intent, int lockTaskAuth) {
Task tr = mock(Task.class);
+ DisplayContent dc = mock(DisplayContent.class);
tr.mLockTaskAuth = lockTaskAuth;
tr.intent = intent;
tr.mUserId = TEST_USER_ID;
+ tr.mDisplayContent = dc;
return tr;
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
index 52a80b01971d..adf878c389dd 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
@@ -51,6 +51,7 @@ import static com.android.dx.mockito.inline.extended.ExtendedMockito.doNothing;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn;
import static com.android.dx.mockito.inline.extended.ExtendedMockito.spyOn;
import static com.android.server.wm.WindowContainer.POSITION_TOP;
+import static com.android.server.wm.WindowManagerService.UPDATE_FOCUS_NORMAL;
import static com.android.window.flags.Flags.explicitRefreshRateHints;
import static org.junit.Assert.assertEquals;
@@ -140,8 +141,7 @@ public class TransitionTests extends WindowTestsBase {
}
private Transition createTestTransition(int transitType) {
- final TransitionController controller = new TestTransitionController(
- mock(ActivityTaskManagerService.class));
+ final TransitionController controller = new TestTransitionController(mAtm);
mSyncEngine = createTestBLASTSyncEngine();
controller.setSyncEngine(mSyncEngine);
@@ -1590,10 +1590,10 @@ public class TransitionTests extends WindowTestsBase {
});
assertTrue(activity1.isVisible());
doReturn(false).when(task1).isTranslucent(null);
- doReturn(false).when(task1).isTranslucentForTransition();
+ doReturn(false).when(task1).isTranslucentAndVisible();
assertTrue(controller.canApplyDim(task1));
doReturn(true).when(task1).isTranslucent(null);
- doReturn(true).when(task1).isTranslucentForTransition();
+ doReturn(true).when(task1).isTranslucentAndVisible();
assertFalse(controller.canApplyDim(task1));
controller.finishTransition(ActionChain.testFinish(closeTransition));
@@ -2357,7 +2357,7 @@ public class TransitionTests extends WindowTestsBase {
}
@Test
- public void testMoveToTopWhileVisible() {
+ public void testMoveTaskToTopWhileVisible() {
final Transition transition = createTestTransition(TRANSIT_OPEN);
final ArrayMap<WindowContainer, Transition.ChangeInfo> changes = transition.mChanges;
final ArraySet<WindowContainer> participants = transition.mParticipants;
@@ -2392,6 +2392,55 @@ public class TransitionTests extends WindowTestsBase {
assertEquals(TRANSIT_CHANGE, info.getChanges().get(0).getMode());
}
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_DISPLAY_FOCUS_IN_SHELL_TRANSITIONS)
+ public void testMoveDisplayToTop() {
+ // Set up two displays, each of which has a task.
+ DisplayContent otherDisplay = createNewDisplay();
+ final Consumer<DisplayContent> setUpTask = (DisplayContent dc) -> {
+ final Task task = createTask(dc);
+ final ActivityRecord act = createActivityRecord(task);
+ final TestWindowState win = createWindowState(
+ new WindowManager.LayoutParams(TYPE_BASE_APPLICATION), act);
+ act.addWindow(win);
+ act.setVisibleRequested(true);
+ };
+ setUpTask.accept(mDisplayContent);
+ setUpTask.accept(otherDisplay);
+ mWm.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true /* updateImWindows */);
+
+ final Transition transition = createTestTransition(TRANSIT_OPEN);
+ final ArrayMap<WindowContainer, Transition.ChangeInfo> changes = transition.mChanges;
+ final ArraySet<WindowContainer> participants = transition.mParticipants;
+
+ // Emulate WindowManagerService#moveDisplayToTopInternal().
+ transition.recordTaskOrder(mDefaultDisplay);
+ mDefaultDisplay.getParent().positionChildAt(WindowContainer.POSITION_TOP,
+ mDefaultDisplay, true /* includingParents */);
+ mWm.updateFocusedWindowLocked(UPDATE_FOCUS_NORMAL, true /* updateImWindows */);
+ transition.setReady(mDefaultDisplay, true /* ready */);
+
+ // Test has order changes, a shallow check of order changes.
+ assertTrue(transition.hasOrderChanges());
+
+ // We just moved a display to top, so there shouldn't be any changes.
+ ArrayList<Transition.ChangeInfo> targets = Transition.calculateTargets(
+ participants, changes);
+ assertTrue(targets.isEmpty());
+
+ // After collecting order changes, the task on the newly focused display should be
+ // considered to get moved to top.
+ transition.collectOrderChanges(true);
+ targets = Transition.calculateTargets(participants, changes);
+ assertEquals(1, targets.size());
+
+ // Make sure the flag is set
+ final TransitionInfo info = Transition.calculateTransitionInfo(
+ transition.mType, 0 /* flags */, targets, mMockT);
+ assertTrue((info.getChanges().get(0).getFlags() & TransitionInfo.FLAG_MOVED_TO_TOP) != 0);
+ assertEquals(TRANSIT_CHANGE, info.getChanges().get(0).getMode());
+ }
+
private class OrderChangeTestSetup {
final TransitionController mController;
final TestTransitionPlayer mPlayer;
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java
index 916c2373ac97..6111a658a048 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowManagerServiceTests.java
@@ -554,6 +554,14 @@ public class WindowManagerServiceTests extends WindowTestsBase {
verify(mWm.mWindowContextListenerController, never()).registerWindowContainerListener(any(),
any(), any(), anyInt(), any(), anyBoolean());
+ // Even if the given display id is INVALID_DISPLAY, the specified params.token should be
+ // able to map the corresponding display.
+ final int result = mWm.addWindow(
+ session, new TestIWindow(), params, View.VISIBLE, INVALID_DISPLAY,
+ UserHandle.USER_SYSTEM, WindowInsets.Type.defaultVisible(), null, new InsetsState(),
+ new InsetsSourceControl.Array(), new Rect(), new float[1]);
+ assertThat(result).isAtLeast(WindowManagerGlobal.ADD_OKAY);
+
assertTrue(parentWin.hasChild());
assertTrue(parentWin.isAttached());
session.binderDied();
diff --git a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
index 112471b2af57..c85374e0b660 100644
--- a/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
+++ b/telecomm/java/com/android/internal/telecom/ITelecomService.aidl
@@ -376,7 +376,8 @@ interface ITelecomService {
*/
void requestLogMark(in String message);
- void setTestPhoneAcctSuggestionComponent(String flattenedComponentName);
+ void setTestPhoneAcctSuggestionComponent(String flattenedComponentName,
+ in UserHandle userHandle);
void setTestDefaultCallScreeningApp(String packageName);
diff --git a/telephony/java/android/telephony/CarrierConfigManager.java b/telephony/java/android/telephony/CarrierConfigManager.java
index aca0941cbcc5..41223db750c0 100644
--- a/telephony/java/android/telephony/CarrierConfigManager.java
+++ b/telephony/java/android/telephony/CarrierConfigManager.java
@@ -5030,6 +5030,18 @@ public class CarrierConfigManager {
public static final String KEY_ES_SUPL_DATA_PLANE_ONLY_ROAMING_PLMN_STRING_ARRAY =
KEY_PREFIX + "es_supl_data_plane_only_roaming_plmn_string_array";
+ /**
+ * Determine whether to enable Net Initiated SUPL (NI SUPL) message injection.
+ * If enabled, the GnssLocationProvider will monitor for WAP PUSH or MT SMS NI SUPL intents
+ * and subsequently inject the NI SUPL packet into the GNSS HAL.
+ * {@code false} - Disable NI SUPL message injection. This is default.
+ * {@code true} - Enable NI SUPL message injection.
+ */
+ @FlaggedApi(android.location.flags.Flags
+ .FLAG_ENABLE_NI_SUPL_MESSAGE_INJECTION_BY_CARRIER_CONFIG)
+ public static final String KEY_ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL =
+ KEY_PREFIX + "enable_ni_supl_message_injection_bool";
+
private static PersistableBundle getDefaults() {
PersistableBundle defaults = new PersistableBundle();
defaults.putBoolean(KEY_PERSIST_LPP_MODE_BOOL, true);
@@ -5047,6 +5059,9 @@ public class CarrierConfigManager {
defaults.putInt(KEY_ES_SUPL_CONTROL_PLANE_SUPPORT_INT,
SUPL_EMERGENCY_MODE_TYPE_CP_ONLY);
defaults.putStringArray(KEY_ES_SUPL_DATA_PLANE_ONLY_ROAMING_PLMN_STRING_ARRAY, null);
+ if (android.location.flags.Flags.enableNiSuplMessageInjectionByCarrierConfig()) {
+ defaults.putBoolean(KEY_ENABLE_NI_SUPL_MESSAGE_INJECTION_BOOL, false);
+ }
return defaults;
}
}
diff --git a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/GameActivity.java b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/GameActivity.java
index ef75d4ddcdcd..93254f7247b6 100644
--- a/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/GameActivity.java
+++ b/tests/FlickerTests/test-apps/flickerapp/src/com/android/server/wm/flicker/testapp/GameActivity.java
@@ -71,7 +71,7 @@ public class GameActivity extends Activity implements SurfaceHolder.Callback {
windowInsetsController.setSystemBarsBehavior(
WindowInsetsControllerCompat.BEHAVIOR_SHOW_TRANSIENT_BARS_BY_SWIPE
);
- // Hide both the status bar and the navigation bar.
- windowInsetsController.hide(WindowInsetsCompat.Type.systemBars());
+ // Hide status bar only to avoid flakiness on gesture quick switch cases.
+ windowInsetsController.hide(WindowInsetsCompat.Type.statusBars());
}
}
diff --git a/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewControllerTests.java b/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewControllerTests.java
index c7ebd3a27a2e..5875520cd259 100644
--- a/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewControllerTests.java
+++ b/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewControllerTests.java
@@ -38,6 +38,7 @@ import android.view.WindowMetrics;
import androidx.test.platform.app.InstrumentationRegistry;
import com.android.server.input.InputManagerService;
+import com.android.server.input.TouchpadHardwareProperties;
import org.junit.Before;
import org.junit.Rule;
@@ -87,6 +88,9 @@ public class TouchpadDebugViewControllerTests {
mTestableLooper = TestableLooper.get(this);
mTestableContext.addMockSystemService(InputManager.class, mInputManagerMock);
+ when(mInputManagerServiceMock.getTouchpadHardwareProperties(DEVICE_ID)).thenReturn(
+ new TouchpadHardwareProperties.Builder(-100f, 100f, -100f, 100f, 45f, 45f, -5f, 5f,
+ (short) 10, true, false).build());
mTouchpadDebugViewController = new TouchpadDebugViewController(mTestableContext,
mTestableLooper.getLooper(), mInputManagerServiceMock);
diff --git a/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java b/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java
index 0f08be215033..99e04cce64f4 100644
--- a/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java
+++ b/tests/Input/src/com/android/server/input/debug/TouchpadDebugViewTest.java
@@ -43,6 +43,7 @@ import androidx.test.runner.AndroidJUnit4;
import com.android.cts.input.MotionEventBuilder;
import com.android.cts.input.PointerBuilder;
import com.android.server.input.TouchpadFingerState;
+import com.android.server.input.TouchpadHardwareProperties;
import com.android.server.input.TouchpadHardwareState;
import org.junit.Before;
@@ -83,7 +84,10 @@ public class TouchpadDebugViewTest {
when(mWindowManager.getCurrentWindowMetrics()).thenReturn(mWindowMetrics);
- mTouchpadDebugView = new TouchpadDebugView(mTestableContext, TOUCHPAD_DEVICE_ID);
+ mTouchpadDebugView = new TouchpadDebugView(mTestableContext, TOUCHPAD_DEVICE_ID,
+ new TouchpadHardwareProperties.Builder(500f, 500f, 500f,
+ 500f, 0f, 0f, -5f, 5f, (short) 10, true,
+ true).build());
mTouchpadDebugView.measure(
View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED),
@@ -296,33 +300,31 @@ public class TouchpadDebugViewTest {
@Test
public void testTouchpadClick() {
- View child;
+ View child = mTouchpadDebugView.getChildAt(0);
mTouchpadDebugView.updateHardwareState(
new TouchpadHardwareState(0, 1 /* buttonsDown */, 0, 0,
- new TouchpadFingerState[0]));
+ new TouchpadFingerState[0]), TOUCHPAD_DEVICE_ID);
- for (int i = 0; i < mTouchpadDebugView.getChildCount(); i++) {
- child = mTouchpadDebugView.getChildAt(i);
- assertEquals(((ColorDrawable) child.getBackground()).getColor(), Color.BLUE);
- }
+ assertEquals(((ColorDrawable) child.getBackground()).getColor(), Color.BLUE);
mTouchpadDebugView.updateHardwareState(
new TouchpadHardwareState(0, 0 /* buttonsDown */, 0, 0,
- new TouchpadFingerState[0]));
+ new TouchpadFingerState[0]), TOUCHPAD_DEVICE_ID);
- for (int i = 0; i < mTouchpadDebugView.getChildCount(); i++) {
- child = mTouchpadDebugView.getChildAt(i);
- assertEquals(((ColorDrawable) child.getBackground()).getColor(), Color.RED);
- }
+ assertEquals(((ColorDrawable) child.getBackground()).getColor(), Color.RED);
mTouchpadDebugView.updateHardwareState(
new TouchpadHardwareState(0, 1 /* buttonsDown */, 0, 0,
- new TouchpadFingerState[0]));
+ new TouchpadFingerState[0]), TOUCHPAD_DEVICE_ID);
- for (int i = 0; i < mTouchpadDebugView.getChildCount(); i++) {
- child = mTouchpadDebugView.getChildAt(i);
- assertEquals(((ColorDrawable) child.getBackground()).getColor(), Color.BLUE);
- }
+ assertEquals(((ColorDrawable) child.getBackground()).getColor(), Color.BLUE);
+
+ // Color should not change because hardware state of a different touchpad
+ mTouchpadDebugView.updateHardwareState(
+ new TouchpadHardwareState(0, 0 /* buttonsDown */, 0, 0,
+ new TouchpadFingerState[0]), TOUCHPAD_DEVICE_ID + 1);
+
+ assertEquals(((ColorDrawable) child.getBackground()).getColor(), Color.BLUE);
}
}
diff --git a/tests/Internal/src/com/android/internal/protolog/PerfettoProtoLogImplTest.java b/tests/Internal/src/com/android/internal/protolog/PerfettoProtoLogImplTest.java
index 189de6bdb44a..e841d9ea0880 100644
--- a/tests/Internal/src/com/android/internal/protolog/PerfettoProtoLogImplTest.java
+++ b/tests/Internal/src/com/android/internal/protolog/PerfettoProtoLogImplTest.java
@@ -399,16 +399,12 @@ public class PerfettoProtoLogImplTest {
TestProtoLogGroup.TEST_GROUP.setLogToLogcat(true);
TestProtoLogGroup.TEST_GROUP.setLogToProto(false);
- var assertion = assertThrows(RuntimeException.class, () -> implSpy.log(
- LogLevel.INFO, TestProtoLogGroup.TEST_GROUP, 1234, 4321,
- new Object[]{5}));
+ implSpy.log(LogLevel.INFO, TestProtoLogGroup.TEST_GROUP, 1234, 4321,
+ new Object[]{5});
- verify(implSpy, never()).passToLogcat(eq(TestProtoLogGroup.TEST_GROUP.getTag()), eq(
- LogLevel.INFO), any());
+ verify(implSpy).passToLogcat(eq(TestProtoLogGroup.TEST_GROUP.getTag()), eq(
+ LogLevel.INFO), eq("UNKNOWN MESSAGE args = (5)"));
verify(sReader).getViewerString(eq(1234L));
-
- Truth.assertThat(assertion).hasMessageThat()
- .contains("Failed to get log message with hash 1234 and args (5)");
}
@Test
@@ -866,19 +862,6 @@ public class PerfettoProtoLogImplTest {
.isEqualTo("This message should also be logged 567");
}
- @Test
- public void throwsOnLogToLogcatForProcessedMessageMissingLoadedDefinition() {
- TestProtoLogGroup.TEST_GROUP.setLogToLogcat(true);
- var protolog = new PerfettoProtoLogImpl(TestProtoLogGroup.values());
-
- var exception = assertThrows(RuntimeException.class, () -> {
- protolog.log(LogLevel.DEBUG, TestProtoLogGroup.TEST_GROUP, 123, 0, new Object[0]);
- });
-
- Truth.assertThat(exception).hasMessageThat()
- .contains("Failed to get log message with hash 123");
- }
-
private enum TestProtoLogGroup implements IProtoLogGroup {
TEST_GROUP(true, true, false, "TEST_TAG");
diff --git a/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java b/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java
index 0439d5f54e23..edad67896e8e 100644
--- a/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java
+++ b/tests/vcn/java/com/android/server/vcn/routeselection/NetworkEvaluationTestBase.java
@@ -123,7 +123,6 @@ public abstract class NetworkEvaluationTestBase {
mSetFlagsRule.enableFlags(Flags.FLAG_VALIDATE_NETWORK_ON_IPSEC_LOSS);
mSetFlagsRule.enableFlags(Flags.FLAG_EVALUATE_IPSEC_LOSS_ON_LP_NC_CHANGE);
mSetFlagsRule.enableFlags(Flags.FLAG_HANDLE_SEQ_NUM_LEAP);
- mSetFlagsRule.enableFlags(Flags.FLAG_ALLOW_DISABLE_IPSEC_LOSS_DETECTOR);
when(mNetwork.getNetId()).thenReturn(-1);