summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--core/api/current.txt4
-rw-r--r--core/api/system-current.txt1
-rw-r--r--core/api/test-current.txt6
-rw-r--r--core/java/android/app/Notification.java4
-rw-r--r--core/java/android/companion/virtual/VirtualDeviceManager.java6
-rw-r--r--core/java/android/credentials/flags.aconfig10
-rw-r--r--core/java/android/credentials/selection/IntentFactory.java88
-rw-r--r--core/java/android/hardware/contexthub/HubEndpoint.java8
-rw-r--r--core/java/android/net/http/X509TrustManagerExtensions.java4
-rw-r--r--core/java/android/os/CombinedMessageQueue/MessageQueue.java15
-rw-r--r--core/java/android/os/ConcurrentMessageQueue/MessageQueue.java24
-rw-r--r--core/java/android/os/LegacyMessageQueue/MessageQueue.java4
-rw-r--r--core/java/android/os/UserManager.java6
-rw-r--r--core/java/android/view/Display.java15
-rw-r--r--core/java/android/view/inputmethod/InputMethodManager.java2
-rw-r--r--core/java/android/window/WindowContainerTransaction.java115
-rw-r--r--core/java/android/window/flags/lse_desktop_experience.aconfig17
-rw-r--r--core/java/android/window/flags/windowing_frontend.aconfig11
-rw-r--r--core/java/com/android/internal/inputmethod/InputMethodDebug.java6
-rw-r--r--core/java/com/android/internal/inputmethod/SoftInputShowHideReason.java28
-rw-r--r--core/res/res/values/attrs_manifest.xml4
-rw-r--r--core/res/res/values/config.xml4
-rw-r--r--core/res/res/values/symbols.xml3
-rw-r--r--libs/WindowManager/Shell/shared/Android.bp2
-rw-r--r--libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/Utils.java46
-rw-r--r--libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java28
-rw-r--r--libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/split/SplitScreenConstants.java20
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/apptoweb/AppToWebUtils.kt9
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/back/BackAnimationController.java6
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java5
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/split/DividerSnapAlgorithm.java4
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitLayout.java39
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitSpec.java183
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitState.java18
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java10
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java4
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt3
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopUserRepositories.kt7
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java8
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/splitscreen/StageCoordinator.java48
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedTransition.java19
-rw-r--r--libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java8
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/back/BackAnimationControllerTest.java8
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopActivityOrientationChangeHandlerTest.kt3
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopImmersiveControllerTest.kt2
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt3
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksLimiterTest.kt3
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopUserRepositoriesTest.kt14
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/persistence/DesktopRepositoryInitializerTest.kt9
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopHeaderManageWindowsMenuTest.kt1
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTests.kt48
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTestsBase.kt3
-rw-r--r--libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java64
-rw-r--r--packages/SettingsLib/ActionButtonsPreference/res/values-v35/styles_expressive.xml5
-rw-r--r--packages/SettingsLib/CardPreference/res/layout/settingslib_expressive_preference_card.xml5
-rw-r--r--packages/SettingsLib/CardPreference/res/values/styles_expressive.xml6
-rw-r--r--packages/SettingsLib/CollapsingToolbarBaseActivity/res/drawable-v35/settingslib_expressive_icon_back.xml25
-rw-r--r--packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-night-v35/themes.xml2
-rw-r--r--packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v35/styles_expressive.xml6
-rw-r--r--packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v35/themes.xml2
-rw-r--r--packages/SettingsLib/IntroPreference/res/layout/settingslib_expressive_preference_intro.xml1
-rw-r--r--packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java31
-rw-r--r--packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceMetadata.kt21
-rw-r--r--packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceTypes.kt12
-rw-r--r--packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceScreenBindingHelper.kt10
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant12.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant17.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant22.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant24.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant4.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant6.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant87.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant92.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant94.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant96.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant98.xml20
-rw-r--r--packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_check.xml (renamed from packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_check.xml)0
-rw-r--r--packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_close.xml (renamed from packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_close.xml)0
-rw-r--r--packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_switch_thumb_icon.xml (renamed from packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_switch_thumb_icon.xml)0
-rw-r--r--packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_collapsable_textview.xml2
-rw-r--r--packages/SettingsLib/SettingsTheme/res/layout/settingslib_expressive_preference_text_frame.xml (renamed from packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_preference_text_frame.xml)6
-rw-r--r--packages/SettingsLib/SettingsTheme/res/layout/settingslib_preference_category_no_title.xml (renamed from packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_preference_category_no_title.xml)0
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-night-v31/colors.xml35
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-night-v34/colors.xml35
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-night-v35/colors.xml33
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-night/colors.xml53
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-v31/colors.xml47
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-v31/config.xml2
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-v31/styles_expressive.xml129
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-v33/styles_expressive.xml306
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-v34/colors.xml47
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-v35/colors.xml45
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-v35/styles_expressive.xml275
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values-v35/themes_expressive.xml4
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values/attrs_expressive.xml (renamed from packages/SettingsLib/SettingsTheme/res/values-v35/attrs_expressive.xml)0
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values/colors.xml79
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values/config.xml3
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values/dimens_expressive.xml (renamed from packages/SettingsLib/SettingsTheme/res/values-v35/dimens_expressive.xml)0
-rw-r--r--packages/SettingsLib/SettingsTheme/res/values/styles_expressive.xml253
-rw-r--r--packages/SettingsLib/StatusBannerPreference/res/layout/settingslib_expressive_preference_statusbanner.xml4
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/AmbientVolumeController.java415
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java9
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java3
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidDeviceManager.java8
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidInfo.java5
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingDeviceLocalDataManager.java36
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/AmbientVolumeControllerTest.java318
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java17
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/HearingAidDeviceManagerTest.java9
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/HearingDeviceLocalDataManagerTest.java13
-rw-r--r--packages/SystemUI/checks/src/com/android/internal/systemui/lint/ShadeDisplayAwareDetector.kt9
-rw-r--r--packages/SystemUI/checks/tests/com/android/internal/systemui/lint/ShadeDisplayAwareDetectorTest.kt14
-rw-r--r--packages/SystemUI/compose/scene/src/com/android/compose/animation/scene/SwipeAnimation.kt15
-rw-r--r--packages/SystemUI/compose/scene/tests/src/com/android/compose/animation/scene/DraggableHandlerTest.kt23
-rw-r--r--packages/SystemUI/lint-baseline.xml1
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/DragToInteractAnimationControllerTest.java8
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepositoryTest.java26
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuItemAccessibilityDelegateTest.java3
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuListViewTouchHandlerTest.java8
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuViewTest.java8
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/shade/display/StatusBarTouchShadeDisplayPolicyTest.kt55
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractorTest.kt145
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt31
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java379
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.kt385
-rw-r--r--packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt146
-rw-r--r--packages/SystemUI/res/values/strings.xml15
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/Task.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java25
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewModel.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/BiometricNotificationBroadcastReceiver.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/BiometricNotificationService.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/FingerprintPropertyInteractor.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsSensorInteractor.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/bouncer/data/repository/EmergencyServicesRepository.kt5
-rw-r--r--packages/SystemUI/src/com/android/systemui/common/ui/ConfigurationModule.kt26
-rw-r--r--packages/SystemUI/src/com/android/systemui/common/ui/data/repository/ConfigurationRepository.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/dagger/GlobalModule.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt9
-rw-r--r--packages/SystemUI/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModel.kt10
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt93
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/EditTileListState.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSeekBar.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt25
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/StatusBarLongPressGestureDetector.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/shade/display/StatusBarTouchShadeDisplayPolicy.kt35
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractor.kt28
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/model/NotificationChipModel.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/ColorsModel.kt23
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarConfigurationControllerStore.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImpl.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconBuilder.kt3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/PromotedNotificationContentExtractor.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/shared/model/PromotedNotificationContentModel.kt7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerStartable.kt6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileContentDescriptionViewBinder.kt30
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt14
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/model/MobileContentDescription.kt43
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt68
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/dagger/StatusBarPolicyModule.java9
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuAnimationControllerTest.java9
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerTest.java3
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModelTest.kt30
-rw-r--r--services/core/java/com/android/server/am/BatteryStatsService.java6
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java33
-rw-r--r--services/core/java/com/android/server/display/DisplayManagerService.java11
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerController.java2
-rw-r--r--services/core/java/com/android/server/display/DisplayPowerProximityStateController.java57
-rw-r--r--services/core/java/com/android/server/display/LogicalDisplayMapper.java8
-rw-r--r--services/core/java/com/android/server/display/VirtualDisplayAdapter.java24
-rw-r--r--services/core/java/com/android/server/display/feature/DisplayManagerFlags.java9
-rw-r--r--services/core/java/com/android/server/display/mode/DisplayModeDirector.java5
-rw-r--r--services/core/java/com/android/server/display/mode/ModeChangeObserver.java108
-rw-r--r--services/core/java/com/android/server/display/mode/RejectedModesVote.java40
-rw-r--r--services/core/java/com/android/server/display/mode/Vote.java43
-rw-r--r--services/core/java/com/android/server/display/mode/VoteSummary.java26
-rw-r--r--services/core/java/com/android/server/media/quality/MediaQualityService.java104
-rw-r--r--services/core/java/com/android/server/media/quality/OWNERS3
-rw-r--r--services/core/java/com/android/server/pm/InstallDependencyHelper.java23
-rw-r--r--services/core/java/com/android/server/pm/InstallRequest.java16
-rw-r--r--services/core/java/com/android/server/pm/InstallingSession.java9
-rw-r--r--services/core/java/com/android/server/pm/PackageInstallerSession.java38
-rw-r--r--services/core/java/com/android/server/pm/PackageMetrics.java55
-rw-r--r--services/core/java/com/android/server/pm/VerifyingSession.java7
-rw-r--r--services/core/java/com/android/server/power/PowerManagerService.java4
-rw-r--r--services/core/java/com/android/server/power/stats/BatteryUsageStatsProvider.java43
-rw-r--r--services/core/java/com/android/server/power/stats/processor/PowerStatsAggregator.java14
-rw-r--r--services/core/java/com/android/server/wm/ActivityRecord.java43
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java21
-rw-r--r--services/core/java/com/android/server/wm/DisplayWindowSettings.java6
-rw-r--r--services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java3
-rw-r--r--services/core/java/com/android/server/wm/RootWindowContainer.java75
-rw-r--r--services/core/java/com/android/server/wm/TaskFragment.java207
-rw-r--r--services/core/java/com/android/server/wm/Transition.java8
-rw-r--r--services/core/java/com/android/server/wm/WindowOrganizerController.java106
-rw-r--r--services/credentials/java/com/android/server/credentials/CredentialManagerUi.java6
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java2
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/VirtualDisplayAdapterTest.java20
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/mode/RejectedModesVoteTest.kt58
-rw-r--r--services/tests/displayservicetests/src/com/android/server/display/mode/VoteSummaryTest.kt38
-rw-r--r--services/tests/dreamservicetests/src/com/android/server/dreams/DreamControllerTest.java19
-rw-r--r--services/tests/mockingservicestests/src/com/android/server/pm/InstallDependencyHelperTest.java31
-rw-r--r--services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsProviderTest.java205
-rw-r--r--services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsRule.java8
-rw-r--r--services/tests/powerstatstests/src/com/android/server/power/stats/MockBatteryStatsImpl.java12
-rw-r--r--services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsAggregatorTest.java28
-rw-r--r--services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsExporterTest.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java12
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java1
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/BackNavigationControllerTests.java8
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayAreaGroupTest.java1
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java1
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java9
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java4
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/DualDisplayAreaGroupPolicyTest.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java2
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java37
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java232
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java94
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TaskTests.java4
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TransitionTests.java1
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java1
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java45
-rw-r--r--services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java19
-rw-r--r--telephony/java/android/telephony/Annotation.java1
-rw-r--r--telephony/java/android/telephony/CellIdentityCdma.java70
-rw-r--r--telephony/java/android/telephony/CellSignalStrengthCdma.java29
-rw-r--r--telephony/java/android/telephony/RadioAccessFamily.java9
-rw-r--r--telephony/java/android/telephony/ServiceState.java26
-rw-r--r--telephony/java/android/telephony/TelephonyManager.java41
-rw-r--r--tests/FlickerTests/Android.bp1
-rw-r--r--tests/FlickerTests/Notification/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTest.kt29
240 files changed, 5862 insertions, 1840 deletions
diff --git a/core/api/current.txt b/core/api/current.txt
index 5efa74779c06..3821b8a5c307 100644
--- a/core/api/current.txt
+++ b/core/api/current.txt
@@ -29956,7 +29956,7 @@ package android.net.http {
public class X509TrustManagerExtensions {
ctor public X509TrustManagerExtensions(javax.net.ssl.X509TrustManager) throws java.lang.IllegalArgumentException;
method public java.util.List<java.security.cert.X509Certificate> checkServerTrusted(java.security.cert.X509Certificate[], String, String) throws java.security.cert.CertificateException;
- method @FlaggedApi("android.net.platform.flags.x509_extensions_certificate_transparency") @NonNull public java.util.List<java.security.cert.X509Certificate> checkServerTrusted(@NonNull java.security.cert.X509Certificate[], @Nullable byte[], @Nullable byte[], @NonNull String, @NonNull String) throws java.security.cert.CertificateException;
+ method @FlaggedApi("android.security.certificate_transparency_configuration") @NonNull public java.util.List<java.security.cert.X509Certificate> checkServerTrusted(@NonNull java.security.cert.X509Certificate[], @Nullable byte[], @Nullable byte[], @NonNull String, @NonNull String) throws java.security.cert.CertificateException;
method public boolean isSameTrustConfiguration(String, String);
method public boolean isUserAddedCertificate(java.security.cert.X509Certificate);
}
@@ -47463,7 +47463,6 @@ package android.telephony {
field public static final long NETWORK_TYPE_BITMASK_IWLAN = 131072L; // 0x20000L
field public static final long NETWORK_TYPE_BITMASK_LTE = 4096L; // 0x1000L
field @Deprecated public static final long NETWORK_TYPE_BITMASK_LTE_CA = 262144L; // 0x40000L
- field @FlaggedApi("com.android.internal.telephony.flags.satellite_system_apis") public static final long NETWORK_TYPE_BITMASK_NB_IOT_NTN = 1048576L; // 0x100000L
field public static final long NETWORK_TYPE_BITMASK_NR = 524288L; // 0x80000L
field public static final long NETWORK_TYPE_BITMASK_TD_SCDMA = 65536L; // 0x10000L
field public static final long NETWORK_TYPE_BITMASK_UMTS = 4L; // 0x4L
@@ -47483,7 +47482,6 @@ package android.telephony {
field @Deprecated public static final int NETWORK_TYPE_IDEN = 11; // 0xb
field public static final int NETWORK_TYPE_IWLAN = 18; // 0x12
field public static final int NETWORK_TYPE_LTE = 13; // 0xd
- field @FlaggedApi("com.android.internal.telephony.flags.satellite_system_apis") public static final int NETWORK_TYPE_NB_IOT_NTN = 21; // 0x15
field public static final int NETWORK_TYPE_NR = 20; // 0x14
field public static final int NETWORK_TYPE_TD_SCDMA = 17; // 0x11
field public static final int NETWORK_TYPE_UMTS = 3; // 0x3
diff --git a/core/api/system-current.txt b/core/api/system-current.txt
index 9590e1ab19c9..e5dcc7d8ba7f 100644
--- a/core/api/system-current.txt
+++ b/core/api/system-current.txt
@@ -5088,6 +5088,7 @@ package android.hardware.contexthub {
field public static final int REASON_ENDPOINT_STOPPED = 6; // 0x6
field public static final int REASON_FAILURE = 0; // 0x0
field public static final int REASON_OPEN_ENDPOINT_SESSION_REQUEST_REJECTED = 3; // 0x3
+ field public static final int REASON_PERMISSION_DENIED = 9; // 0x9
}
public static final class HubEndpoint.Builder {
diff --git a/core/api/test-current.txt b/core/api/test-current.txt
index 6230a59a62c0..8594caee32c5 100644
--- a/core/api/test-current.txt
+++ b/core/api/test-current.txt
@@ -1402,9 +1402,9 @@ package android.credentials.selection {
method @NonNull public android.credentials.selection.GetCredentialProviderData.Builder setRemoteEntry(@Nullable android.credentials.selection.Entry);
}
- @FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") public class IntentFactory {
- method @NonNull public static android.content.Intent createCancelUiIntent(@NonNull android.content.Context, @NonNull android.os.IBinder, boolean, @NonNull String);
- method @NonNull public static android.content.Intent createCredentialSelectorIntent(@NonNull android.content.Context, @NonNull android.credentials.selection.RequestInfo, @NonNull java.util.ArrayList<android.credentials.selection.ProviderData>, @NonNull java.util.ArrayList<android.credentials.selection.DisabledProviderData>, @NonNull android.os.ResultReceiver);
+ @FlaggedApi("android.credentials.flags.propagate_user_context_for_intent_creation") public class IntentFactory {
+ method @NonNull public static android.content.Intent createCancelUiIntent(@NonNull android.content.Context, @NonNull android.os.IBinder, boolean, @NonNull String, int);
+ method @NonNull public static android.content.Intent createCredentialSelectorIntent(@NonNull android.content.Context, @NonNull android.credentials.selection.RequestInfo, @NonNull java.util.ArrayList<android.credentials.selection.ProviderData>, @NonNull java.util.ArrayList<android.credentials.selection.DisabledProviderData>, @NonNull android.os.ResultReceiver, int);
}
@FlaggedApi("android.credentials.flags.configurable_selector_ui_enabled") public abstract class ProviderData implements android.os.Parcelable {
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index f2d6c6ad81e5..aa2ada5372af 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -6024,8 +6024,9 @@ public class Notification implements Parcelable
/**
* @param isHeader If the notification is a notification header
* @return An instance of mColors after resolving the palette
+ * @hide
*/
- private Colors getColors(boolean isHeader) {
+ public Colors getColors(boolean isHeader) {
mColors.resolvePalette(mContext, mN.color, !isHeader && mN.isColorized(), mInNightMode);
return mColors;
}
@@ -14765,7 +14766,6 @@ public class Notification implements Parcelable
* A utility which stores and calculates the palette of colors used to color notifications.
* @hide
*/
- @VisibleForTesting
public static class Colors {
private int mPaletteIsForRawColor = COLOR_INVALID;
private boolean mPaletteIsForColorized = false;
diff --git a/core/java/android/companion/virtual/VirtualDeviceManager.java b/core/java/android/companion/virtual/VirtualDeviceManager.java
index b3f09a98d623..ed2fd99c55c5 100644
--- a/core/java/android/companion/virtual/VirtualDeviceManager.java
+++ b/core/java/android/companion/virtual/VirtualDeviceManager.java
@@ -1290,7 +1290,11 @@ public final class VirtualDeviceManager {
@NonNull UserHandle user) {}
/**
- * Called when a window with a secure surface is no longer shown on the device.
+ * Called when there is no longer any window with a secure surface shown on the device.
+ *
+ * <p>This is only called once there are no more secure windows shown on the device. If
+ * there are multiple secure windows shown on the device, this callback will be called only
+ * once all of them are hidden.</p>
*
* @param displayId The display ID on which the window was shown before.
*
diff --git a/core/java/android/credentials/flags.aconfig b/core/java/android/credentials/flags.aconfig
index d8d4e161006c..9c811fb84da3 100644
--- a/core/java/android/credentials/flags.aconfig
+++ b/core/java/android/credentials/flags.aconfig
@@ -124,3 +124,13 @@ flag {
purpose: PURPOSE_BUGFIX
}
}
+
+flag {
+ namespace: "credential_manager"
+ name: "settings_w_fixes"
+ description: "Settings improvements for credential manager"
+ bug: "373711451"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
diff --git a/core/java/android/credentials/selection/IntentFactory.java b/core/java/android/credentials/selection/IntentFactory.java
index c521b96fd8ee..59539c40d636 100644
--- a/core/java/android/credentials/selection/IntentFactory.java
+++ b/core/java/android/credentials/selection/IntentFactory.java
@@ -16,7 +16,7 @@
package android.credentials.selection;
-import static android.credentials.flags.Flags.FLAG_CONFIGURABLE_SELECTOR_UI_ENABLED;
+import static android.credentials.flags.Flags.FLAG_PROPAGATE_USER_CONTEXT_FOR_INTENT_CREATION;
import static android.credentials.flags.Flags.configurableSelectorUiEnabled;
import android.annotation.FlaggedApi;
@@ -24,6 +24,8 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
import android.annotation.TestApi;
+import android.annotation.UserIdInt;
+import android.app.AppGlobals;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -32,6 +34,7 @@ import android.content.pm.PackageManager;
import android.content.res.Resources;
import android.os.IBinder;
import android.os.Parcel;
+import android.os.RemoteException;
import android.os.ResultReceiver;
import android.text.TextUtils;
import android.util.Slog;
@@ -46,7 +49,7 @@ import java.util.ArrayList;
* @hide
*/
@TestApi
-@FlaggedApi(FLAG_CONFIGURABLE_SELECTOR_UI_ENABLED)
+@FlaggedApi(FLAG_PROPAGATE_USER_CONTEXT_FOR_INTENT_CREATION)
public class IntentFactory {
/**
@@ -65,9 +68,10 @@ public class IntentFactory {
@SuppressLint("ConcreteCollection") // Concrete collection needed for marshalling.
@NonNull
ArrayList<DisabledProviderData> disabledProviderDataList,
- @NonNull ResultReceiver resultReceiver) {
+ @NonNull ResultReceiver resultReceiver,
+ @UserIdInt int userId) {
return createCredentialSelectorIntentInternal(context, requestInfo,
- disabledProviderDataList, resultReceiver);
+ disabledProviderDataList, resultReceiver, userId);
}
/**
@@ -96,9 +100,10 @@ public class IntentFactory {
@SuppressLint("ConcreteCollection") // Concrete collection needed for marshalling.
@NonNull
ArrayList<DisabledProviderData> disabledProviderDataList,
- @NonNull ResultReceiver resultReceiver) {
+ @NonNull ResultReceiver resultReceiver,
+ @UserIdInt int userId) {
IntentCreationResult result = createCredentialSelectorIntentInternal(context, requestInfo,
- disabledProviderDataList, resultReceiver);
+ disabledProviderDataList, resultReceiver, userId);
result.getIntent().putParcelableArrayListExtra(
ProviderData.EXTRA_ENABLED_PROVIDER_DATA_LIST, enabledProviderDataList);
return result;
@@ -130,9 +135,10 @@ public class IntentFactory {
@SuppressLint("ConcreteCollection") // Concrete collection needed for marshalling.
@NonNull
ArrayList<DisabledProviderData> disabledProviderDataList,
- @NonNull ResultReceiver resultReceiver) {
+ @NonNull ResultReceiver resultReceiver, @UserIdInt int userId) {
return createCredentialSelectorIntentForCredMan(context, requestInfo,
- enabledProviderDataList, disabledProviderDataList, resultReceiver).getIntent();
+ enabledProviderDataList, disabledProviderDataList, resultReceiver,
+ userId).getIntent();
}
/**
@@ -142,10 +148,10 @@ public class IntentFactory {
@NonNull
public static Intent createCancelUiIntent(@NonNull Context context,
@NonNull IBinder requestToken, boolean shouldShowCancellationUi,
- @NonNull String appPackageName) {
+ @NonNull String appPackageName, @UserIdInt int userId) {
Intent intent = new Intent();
IntentCreationResult.Builder intentResultBuilder = new IntentCreationResult.Builder(intent);
- setCredentialSelectorUiComponentName(context, intent, intentResultBuilder);
+ setCredentialSelectorUiComponentName(context, intent, intentResultBuilder, userId);
intent.putExtra(CancelSelectionRequest.EXTRA_CANCEL_UI_REQUEST,
new CancelSelectionRequest(new RequestToken(requestToken), shouldShowCancellationUi,
appPackageName));
@@ -162,10 +168,10 @@ public class IntentFactory {
@SuppressLint("ConcreteCollection") // Concrete collection needed for marshalling.
@NonNull
ArrayList<DisabledProviderData> disabledProviderDataList,
- @NonNull ResultReceiver resultReceiver) {
+ @NonNull ResultReceiver resultReceiver, @UserIdInt int userId) {
Intent intent = new Intent();
IntentCreationResult.Builder intentResultBuilder = new IntentCreationResult.Builder(intent);
- setCredentialSelectorUiComponentName(context, intent, intentResultBuilder);
+ setCredentialSelectorUiComponentName(context, intent, intentResultBuilder, userId);
intent.putParcelableArrayListExtra(
ProviderData.EXTRA_DISABLED_PROVIDER_DATA_LIST, disabledProviderDataList);
intent.putExtra(RequestInfo.EXTRA_REQUEST_INFO, requestInfo);
@@ -175,9 +181,11 @@ public class IntentFactory {
}
private static void setCredentialSelectorUiComponentName(@NonNull Context context,
- @NonNull Intent intent, @NonNull IntentCreationResult.Builder intentResultBuilder) {
+ @NonNull Intent intent, @NonNull IntentCreationResult.Builder intentResultBuilder,
+ @UserIdInt int userId) {
if (configurableSelectorUiEnabled()) {
- ComponentName componentName = getOemOverrideComponentName(context, intentResultBuilder);
+ ComponentName componentName = getOemOverrideComponentName(context,
+ intentResultBuilder, userId);
ComponentName fallbackUiComponentName = null;
try {
@@ -210,7 +218,7 @@ public class IntentFactory {
*/
@Nullable
private static ComponentName getOemOverrideComponentName(@NonNull Context context,
- @NonNull IntentCreationResult.Builder intentResultBuilder) {
+ @NonNull IntentCreationResult.Builder intentResultBuilder, @UserIdInt int userId) {
ComponentName result = null;
String oemComponentString =
Resources.getSystem()
@@ -228,35 +236,43 @@ public class IntentFactory {
if (oemComponentName != null) {
try {
intentResultBuilder.setOemUiPackageName(oemComponentName.getPackageName());
- ActivityInfo info = context.getPackageManager().getActivityInfo(
- oemComponentName,
- PackageManager.ComponentInfoFlags.of(
- PackageManager.MATCH_SYSTEM_ONLY));
- boolean oemComponentEnabled = info.enabled;
- int runtimeComponentEnabledState = context.getPackageManager()
+ ActivityInfo info;
+ if (android.credentials.flags.Flags.propagateUserContextForIntentCreation()) {
+ info = context.getPackageManager().getActivityInfo(oemComponentName,
+ PackageManager.ComponentInfoFlags.of(
+ PackageManager.MATCH_SYSTEM_ONLY));
+ } else {
+ info = AppGlobals.getPackageManager().getActivityInfo(
+ oemComponentName, 0, userId);
+ }
+ boolean oemComponentEnabled = false;
+ if (info != null) {
+ oemComponentEnabled = info.enabled;
+ int runtimeComponentEnabledState = context.getPackageManager()
.getComponentEnabledSetting(oemComponentName);
- if (runtimeComponentEnabledState == PackageManager
+ if (runtimeComponentEnabledState == PackageManager
.COMPONENT_ENABLED_STATE_ENABLED) {
- oemComponentEnabled = true;
- } else if (runtimeComponentEnabledState == PackageManager
+ oemComponentEnabled = true;
+ } else if (runtimeComponentEnabledState == PackageManager
.COMPONENT_ENABLED_STATE_DISABLED) {
oemComponentEnabled = false;
- }
- if (oemComponentEnabled && info.exported) {
+ }
+ if (oemComponentEnabled && info.exported) {
intentResultBuilder.setOemUiUsageStatus(IntentCreationResult
- .OemUiUsageStatus.SUCCESS);
+ .OemUiUsageStatus.SUCCESS);
Slog.i(TAG,
- "Found enabled oem CredMan UI component."
- + oemComponentString);
+ "Found enabled oem CredMan UI component."
+ + oemComponentString);
result = oemComponentName;
- } else {
- intentResultBuilder.setOemUiUsageStatus(IntentCreationResult
- .OemUiUsageStatus.OEM_UI_CONFIG_SPECIFIED_FOUND_BUT_NOT_ENABLED);
- Slog.i(TAG,
- "Found enabled oem CredMan UI component but it was not "
- + "enabled.");
+ } else {
+ intentResultBuilder.setOemUiUsageStatus(IntentCreationResult
+ .OemUiUsageStatus.OEM_UI_CONFIG_SPECIFIED_FOUND_BUT_NOT_ENABLED);
+ Slog.i(TAG,
+ "Found enabled oem CredMan UI component but it was not "
+ + "enabled.");
+ }
}
- } catch (PackageManager.NameNotFoundException e) {
+ } catch (RemoteException | PackageManager.NameNotFoundException e) {
intentResultBuilder.setOemUiUsageStatus(IntentCreationResult.OemUiUsageStatus
.OEM_UI_CONFIG_SPECIFIED_BUT_NOT_FOUND);
Slog.i(TAG, "Unable to find oem CredMan UI component: "
diff --git a/core/java/android/hardware/contexthub/HubEndpoint.java b/core/java/android/hardware/contexthub/HubEndpoint.java
index 1f12bbf4d074..ee4675c6a46f 100644
--- a/core/java/android/hardware/contexthub/HubEndpoint.java
+++ b/core/java/android/hardware/contexthub/HubEndpoint.java
@@ -66,13 +66,14 @@ public class HubEndpoint {
REASON_CLOSE_ENDPOINT_SESSION_REQUESTED,
REASON_ENDPOINT_INVALID,
REASON_ENDPOINT_STOPPED,
+ REASON_PERMISSION_DENIED,
})
public @interface Reason {}
/** Unclassified failure */
public static final int REASON_FAILURE = 0;
- // The values 1 and 2 are reserved at the Context Hub HAL but not exposed to apps.
+ // The values 1-2 are reserved at the Context Hub HAL but not exposed to apps.
/** The peer rejected the request to open this endpoint session. */
public static final int REASON_OPEN_ENDPOINT_SESSION_REQUEST_REJECTED = 3;
@@ -83,6 +84,11 @@ public class HubEndpoint {
/** The peer endpoint is invalid. */
public static final int REASON_ENDPOINT_INVALID = 5;
+ // The values 6-8 are reserved at the Context Hub HAL but not exposed to apps.
+
+ /** The endpoint did not have the required permissions. */
+ public static final int REASON_PERMISSION_DENIED = 9;
+
/**
* The endpoint is now stopped. The app should retrieve the endpoint info using {@link
* android.hardware.location.ContextHubManager#findEndpoints} or register updates through
diff --git a/core/java/android/net/http/X509TrustManagerExtensions.java b/core/java/android/net/http/X509TrustManagerExtensions.java
index b44f75a585d5..3425b77be954 100644
--- a/core/java/android/net/http/X509TrustManagerExtensions.java
+++ b/core/java/android/net/http/X509TrustManagerExtensions.java
@@ -22,7 +22,7 @@ import android.annotation.FlaggedApi;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.SuppressLint;
-import android.net.platform.flags.Flags;
+import android.security.Flags;
import android.security.net.config.UserCertificateSource;
import com.android.org.conscrypt.TrustManagerImpl;
@@ -152,7 +152,7 @@ public class X509TrustManagerExtensions {
* @throws IllegalArgumentException if the TrustManager is not compatible.
* @return the properly ordered chain used for verification as a list of X509Certificates.
*/
- @FlaggedApi(Flags.FLAG_X509_EXTENSIONS_CERTIFICATE_TRANSPARENCY)
+ @FlaggedApi(Flags.FLAG_CERTIFICATE_TRANSPARENCY_CONFIGURATION)
@NonNull
public List<X509Certificate> checkServerTrusted(
@SuppressLint("ArrayReturn") @NonNull X509Certificate[] chain,
diff --git a/core/java/android/os/CombinedMessageQueue/MessageQueue.java b/core/java/android/os/CombinedMessageQueue/MessageQueue.java
index b509c7a441d3..230fa3fec930 100644
--- a/core/java/android/os/CombinedMessageQueue/MessageQueue.java
+++ b/core/java/android/os/CombinedMessageQueue/MessageQueue.java
@@ -1355,14 +1355,21 @@ public final class MessageQueue {
/**
* @return true if we are blocked on a sync barrier
+ *
+ * Calls to this method must not be allowed to race with `next`.
+ * Specifically, the Looper thread must be paused before calling this method,
+ * and may not be resumed until after returning from this method.
*/
boolean isBlockedOnSyncBarrier() {
throwIfNotTest();
if (mUseConcurrent) {
+ // Call nextMessage to get the stack drained into our priority queues
+ nextMessage(true);
+
Iterator<MessageNode> queueIter = mPriorityQueue.iterator();
MessageNode queueNode = iterateNext(queueIter);
- if (queueNode.isBarrier()) {
+ if (queueNode != null && queueNode.isBarrier()) {
long now = SystemClock.uptimeMillis();
/* Look for a deliverable async node. If one exists we are not blocked. */
@@ -1375,14 +1382,12 @@ public final class MessageQueue {
* Look for a deliverable sync node. In this case, if one exists we are blocked
* since the barrier prevents delivery of the Message.
*/
- while (queueNode.isBarrier()) {
+ while (queueNode != null && queueNode.isBarrier()) {
queueNode = iterateNext(queueIter);
}
if (queueNode != null && now >= queueNode.getWhen()) {
return true;
}
-
- return false;
}
} else {
Message msg = mMessages;
@@ -1409,10 +1414,8 @@ public final class MessageQueue {
if (iter != null && now >= iter.when) {
return true;
}
- return false;
}
}
- /* No barrier was found. */
return false;
}
diff --git a/core/java/android/os/ConcurrentMessageQueue/MessageQueue.java b/core/java/android/os/ConcurrentMessageQueue/MessageQueue.java
index de0259eb1e36..d7d8e4199b33 100644
--- a/core/java/android/os/ConcurrentMessageQueue/MessageQueue.java
+++ b/core/java/android/os/ConcurrentMessageQueue/MessageQueue.java
@@ -19,6 +19,7 @@ package android.os;
import android.annotation.FlaggedApi;
import android.annotation.IntDef;
import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.annotation.TestApi;
import android.app.ActivityThread;
import android.app.Instrumentation;
@@ -784,7 +785,7 @@ public final class MessageQueue {
mMessageDirectlyQueued = false;
nativePollOnce(ptr, mNextPollTimeoutMillis);
- Message msg = nextMessage();
+ Message msg = nextMessage(false);
if (msg != null) {
msg.markInUse();
return msg;
@@ -1087,7 +1088,6 @@ public final class MessageQueue {
*
* Caller must ensure that this doesn't race 'next' from the Looper thread.
*/
- @SuppressLint("VisiblySynchronized") // Legacy MessageQueue synchronizes on this
Long peekWhenForTest() {
throwIfNotTest();
Message ret = nextMessage(true);
@@ -1100,7 +1100,6 @@ public final class MessageQueue {
*
* Caller must ensure that this doesn't race 'next' from the Looper thread.
*/
- @SuppressLint("VisiblySynchronized") // Legacy MessageQueue synchronizes on this
@Nullable
Message pollForTest() {
throwIfNotTest();
@@ -1109,13 +1108,21 @@ public final class MessageQueue {
/**
* @return true if we are blocked on a sync barrier
+ *
+ * Calls to this method must not be allowed to race with `next`.
+ * Specifically, the Looper thread must be paused before calling this method,
+ * and may not be resumed until after returning from this method.
*/
boolean isBlockedOnSyncBarrier() {
throwIfNotTest();
+
+ // Call nextMessage to get the stack drained into our priority queues
+ nextMessage(true);
+
Iterator<MessageNode> queueIter = mPriorityQueue.iterator();
MessageNode queueNode = iterateNext(queueIter);
- if (queueNode.isBarrier()) {
+ if (queueNode != null && queueNode.isBarrier()) {
long now = SystemClock.uptimeMillis();
/* Look for a deliverable async node. If one exists we are not blocked. */
@@ -1128,15 +1135,14 @@ public final class MessageQueue {
* Look for a deliverable sync node. In this case, if one exists we are blocked
* since the barrier prevents delivery of the Message.
*/
- while (queueNode.isBarrier()) {
+ while (queueNode != null && queueNode.isBarrier()) {
queueNode = iterateNext(queueIter);
}
if (queueNode != null && now >= queueNode.getWhen()) {
return true;
}
-
- return false;
}
+ return false;
}
private StateNode getStateNode(StackNode node) {
@@ -1193,7 +1199,7 @@ public final class MessageQueue {
MessageNode p = (MessageNode) top;
while (true) {
- if (compare.compareMessage(p.mMessage, h, what, object, r, when)) {
+ if (compare.compareMessage(p, h, what, object, r, when)) {
found = true;
if (DEBUG) {
Log.w(TAG, "stackHasMessages node matches");
@@ -1238,7 +1244,7 @@ public final class MessageQueue {
while (iterator.hasNext()) {
MessageNode msg = iterator.next();
- if (compare.compareMessage(msg.mMessage, h, what, object, r, when)) {
+ if (compare.compareMessage(msg, h, what, object, r, when)) {
if (removeMatches) {
found = true;
if (queue.remove(msg)) {
diff --git a/core/java/android/os/LegacyMessageQueue/MessageQueue.java b/core/java/android/os/LegacyMessageQueue/MessageQueue.java
index 5e1e1fdca5c8..c0333e914b4d 100644
--- a/core/java/android/os/LegacyMessageQueue/MessageQueue.java
+++ b/core/java/android/os/LegacyMessageQueue/MessageQueue.java
@@ -814,6 +814,10 @@ public final class MessageQueue {
/**
* @return true if we are blocked on a sync barrier
+ *
+ * Calls to this method must not be allowed to race with `next`.
+ * Specifically, the Looper thread must be paused before calling this method,
+ * and may not be resumed until after returning from this method.
*/
boolean isBlockedOnSyncBarrier() {
throwIfNotTest();
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index 7e73a5d04866..b9f2cfcd8ca8 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -6501,7 +6501,11 @@ public class UserManager {
* @hide
*/
public static final void invalidateCacheOnUserDataChanged() {
- if (android.multiuser.Flags.cacheProfilesReadOnly()) {
+ if (android.multiuser.Flags.cacheProfilesReadOnly()
+ || android.multiuser.Flags.cacheUserInfoReadOnly()) {
+ // TODO(b/383175685): Rename the invalidation call to make it clearer that it
+ // invalidates the caches for both getProfiles and getUserInfo (since they both use the
+ // same user_manager_user_data CachedProperty.api).
UserManagerCache.invalidateProfiles();
}
}
diff --git a/core/java/android/view/Display.java b/core/java/android/view/Display.java
index 802bddd76e30..1ea226b013d6 100644
--- a/core/java/android/view/Display.java
+++ b/core/java/android/view/Display.java
@@ -19,6 +19,7 @@ package android.view;
import static android.Manifest.permission.CONFIGURE_DISPLAY_COLOR_MODE;
import static android.Manifest.permission.CONTROL_DISPLAY_BRIGHTNESS;
import static android.hardware.flags.Flags.FLAG_OVERLAYPROPERTIES_CLASS_API;
+import static android.util.TypedValue.COMPLEX_UNIT_DIP;
import static com.android.server.display.feature.flags.Flags.FLAG_ENABLE_GET_SUPPORTED_REFRESH_RATES;
import static com.android.server.display.feature.flags.Flags.FLAG_HIGHEST_HDR_SDR_RATIO_API;
@@ -58,6 +59,7 @@ import android.os.SystemClock;
import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.Log;
+import android.util.TypedValue;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
@@ -1048,6 +1050,19 @@ public final class Display {
}
/**
+ * Returns the smallest size of the display in dp
+ * @hide
+ */
+ public float getMinSizeDimensionDp() {
+ synchronized (mLock) {
+ updateDisplayInfoLocked();
+ mDisplayInfo.getAppMetrics(mTempMetrics);
+ return TypedValue.deriveDimension(COMPLEX_UNIT_DIP,
+ Math.min(mDisplayInfo.logicalWidth, mDisplayInfo.logicalHeight), mTempMetrics);
+ }
+ }
+
+ /**
* @deprecated Use {@link WindowMetrics#getBounds#width()} instead.
*/
@Deprecated
diff --git a/core/java/android/view/inputmethod/InputMethodManager.java b/core/java/android/view/inputmethod/InputMethodManager.java
index 6d89f3d89077..f82e5f984f5d 100644
--- a/core/java/android/view/inputmethod/InputMethodManager.java
+++ b/core/java/android/view/inputmethod/InputMethodManager.java
@@ -948,7 +948,7 @@ public final class InputMethodManager {
// requestedVisibleTypes of WindowInsetsController by hiding the IME
final var statsToken = ImeTracker.forLogging().onStart(
ImeTracker.TYPE_HIDE, ImeTracker.ORIGIN_CLIENT,
- SoftInputShowHideReason.REASON_HIDE_WINDOW_LOST_FOCUS,
+ SoftInputShowHideReason.HIDE_WINDOW_LOST_FOCUS,
false /* fromUser */);
if (DEBUG) {
Log.d(TAG, "onWindowLostFocus, hiding IME because "
diff --git a/core/java/android/window/WindowContainerTransaction.java b/core/java/android/window/WindowContainerTransaction.java
index a88a17283482..c8001198bdf6 100644
--- a/core/java/android/window/WindowContainerTransaction.java
+++ b/core/java/android/window/WindowContainerTransaction.java
@@ -486,7 +486,7 @@ public final class WindowContainerTransaction implements Parcelable {
}
/**
- * Sets to containers adjacent to each other. Containers below two visible adjacent roots will
+ * Sets two containers adjacent to each other. Containers below two visible adjacent roots will
* be made invisible. This currently only applies to TaskFragment containers created by
* organizer.
* @param root1 the first root.
@@ -495,9 +495,64 @@ public final class WindowContainerTransaction implements Parcelable {
@NonNull
public WindowContainerTransaction setAdjacentRoots(
@NonNull WindowContainerToken root1, @NonNull WindowContainerToken root2) {
- mHierarchyOps.add(HierarchyOp.createForAdjacentRoots(
- root1.asBinder(),
- root2.asBinder()));
+ if (!Flags.allowMultipleAdjacentTaskFragments()) {
+ mHierarchyOps.add(HierarchyOp.createForAdjacentRoots(
+ root1.asBinder(),
+ root2.asBinder()));
+ return this;
+ }
+ return setAdjacentRootSet(root1, root2);
+ }
+
+ /**
+ * Sets multiple containers adjacent to each other. Containers below the visible adjacent roots
+ * will be made invisible. This currently only applies to Task containers created by organizer.
+ *
+ * To remove one container from the adjacent roots, one can call {@link #clearAdjacentRoots}
+ * with the target container.
+ * To remove all containers from the adjacent roots, one much call {@link #clearAdjacentRoots}
+ * on each container if there were more than two containers in the set.
+ *
+ * For non-Task TaskFragment, use {@link #setAdjacentTaskFragments} instead.
+ *
+ * @param roots the Tasks that should be adjacent to each other.
+ * @throws IllegalArgumentException if roots have size < 2.
+ * @hide // TODO(b/373709676) Rename to setAdjacentRoots and update CTS.
+ */
+ @NonNull
+ public WindowContainerTransaction setAdjacentRootSet(
+ @NonNull WindowContainerToken... roots) {
+ if (!Flags.allowMultipleAdjacentTaskFragments()) {
+ throw new IllegalArgumentException("allowMultipleAdjacentTaskFragments is not enabled."
+ + " Use #setAdjacentRoots instead.");
+ }
+ if (roots.length < 2) {
+ throw new IllegalArgumentException("setAdjacentRootSet must have size >= 2");
+ }
+ final IBinder[] rootTokens = new IBinder[roots.length];
+ for (int i = 0; i < roots.length; i++) {
+ rootTokens[i] = roots[i].asBinder();
+ }
+ mHierarchyOps.add(
+ new HierarchyOp.Builder(HierarchyOp.HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS)
+ .setContainers(rootTokens)
+ .build());
+ return this;
+ }
+
+ /**
+ * Clears container adjacent.
+ * If {@link #setAdjacentRootSet} is called with more than 2 roots, calling this will only
+ * remove the given root from the adjacent set. The rest of roots will stay adjacent to each
+ * other.
+ *
+ * @param root the root container to clear the adjacent roots for.
+ * @hide
+ */
+ @NonNull
+ public WindowContainerTransaction clearAdjacentRoots(
+ @NonNull WindowContainerToken root) {
+ mHierarchyOps.add(HierarchyOp.createForClearAdjacentRoots(root.asBinder()));
return this;
}
@@ -967,18 +1022,6 @@ public final class WindowContainerTransaction implements Parcelable {
}
/**
- * Clears container adjacent.
- * @param root the root container to clear the adjacent roots for.
- * @hide
- */
- @NonNull
- public WindowContainerTransaction clearAdjacentRoots(
- @NonNull WindowContainerToken root) {
- mHierarchyOps.add(HierarchyOp.createForClearAdjacentRoots(root.asBinder()));
- return this;
- }
-
- /**
* Sets/removes the reparent leaf task flag for this {@code windowContainer}.
* When this is set, the server side will try to reparent the leaf task to task display area
* if there is an existing activity in history during the activity launch. This operation only
@@ -1520,6 +1563,9 @@ public final class WindowContainerTransaction implements Parcelable {
@Nullable
private IBinder mContainer;
+ @Nullable
+ private IBinder[] mContainers;
+
// If this is same as mContainer, then only change position, don't reparent.
@Nullable
private IBinder mReparent;
@@ -1704,6 +1750,7 @@ public final class WindowContainerTransaction implements Parcelable {
public HierarchyOp(@NonNull HierarchyOp copy) {
mType = copy.mType;
mContainer = copy.mContainer;
+ mContainers = copy.mContainers;
mBounds = copy.mBounds;
mIncludingParents = copy.mIncludingParents;
mReparent = copy.mReparent;
@@ -1729,6 +1776,7 @@ public final class WindowContainerTransaction implements Parcelable {
protected HierarchyOp(Parcel in) {
mType = in.readInt();
mContainer = in.readStrongBinder();
+ mContainers = in.createBinderArray();
mBounds = in.readTypedObject(Rect.CREATOR);
mIncludingParents = in.readBoolean();
mReparent = in.readStrongBinder();
@@ -1780,6 +1828,13 @@ public final class WindowContainerTransaction implements Parcelable {
}
@NonNull
+ public IBinder[] getContainers() {
+ return mContainers;
+ }
+
+ /** @deprecated b/373709676 replace with {@link #getContainers()}. */
+ @Deprecated
+ @NonNull
public IBinder getAdjacentRoot() {
return mReparent;
}
@@ -1869,7 +1924,7 @@ public final class WindowContainerTransaction implements Parcelable {
case HIERARCHY_OP_TYPE_REORDER: return "reorder";
case HIERARCHY_OP_TYPE_CHILDREN_TASKS_REPARENT: return "childrenTasksReparent";
case HIERARCHY_OP_TYPE_SET_LAUNCH_ROOT: return "setLaunchRoot";
- case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS: return "setAdjacentRoot";
+ case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS: return "setAdjacentRoots";
case HIERARCHY_OP_TYPE_LAUNCH_TASK: return "launchTask";
case HIERARCHY_OP_TYPE_SET_LAUNCH_ADJACENT_FLAG_ROOT: return "setAdjacentFlagRoot";
case HIERARCHY_OP_TYPE_SET_DISABLE_LAUNCH_ADJACENT:
@@ -1883,7 +1938,7 @@ public final class WindowContainerTransaction implements Parcelable {
case HIERARCHY_OP_TYPE_SET_ALWAYS_ON_TOP: return "setAlwaysOnTop";
case HIERARCHY_OP_TYPE_REMOVE_TASK: return "removeTask";
case HIERARCHY_OP_TYPE_FINISH_ACTIVITY: return "finishActivity";
- case HIERARCHY_OP_TYPE_CLEAR_ADJACENT_ROOTS: return "clearAdjacentRoot";
+ case HIERARCHY_OP_TYPE_CLEAR_ADJACENT_ROOTS: return "clearAdjacentRoots";
case HIERARCHY_OP_TYPE_SET_REPARENT_LEAF_TASK_IF_RELAUNCH:
return "setReparentLeafTaskIfRelaunch";
case HIERARCHY_OP_TYPE_ADD_TASK_FRAGMENT_OPERATION:
@@ -1923,8 +1978,18 @@ public final class WindowContainerTransaction implements Parcelable {
sb.append(mContainer).append(" to ").append(mToTop ? "top" : "bottom");
break;
case HIERARCHY_OP_TYPE_SET_ADJACENT_ROOTS:
- sb.append("container=").append(mContainer)
- .append(" adjacentRoot=").append(mReparent);
+ if (Flags.allowMultipleAdjacentTaskFragments()) {
+ for (IBinder container : mContainers) {
+ if (container == mContainers[0]) {
+ sb.append("adjacentRoots=").append(container);
+ } else {
+ sb.append(", ").append(container);
+ }
+ }
+ } else {
+ sb.append("container=").append(mContainer)
+ .append(" adjacentRoot=").append(mReparent);
+ }
break;
case HIERARCHY_OP_TYPE_LAUNCH_TASK:
sb.append(mLaunchOptions);
@@ -1997,6 +2062,7 @@ public final class WindowContainerTransaction implements Parcelable {
public void writeToParcel(Parcel dest, int flags) {
dest.writeInt(mType);
dest.writeStrongBinder(mContainer);
+ dest.writeBinderArray(mContainers);
dest.writeTypedObject(mBounds, flags);
dest.writeBoolean(mIncludingParents);
dest.writeStrongBinder(mReparent);
@@ -2044,6 +2110,9 @@ public final class WindowContainerTransaction implements Parcelable {
private IBinder mContainer;
@Nullable
+ private IBinder[] mContainers;
+
+ @Nullable
private IBinder mReparent;
@Nullable
@@ -2104,6 +2173,11 @@ public final class WindowContainerTransaction implements Parcelable {
return this;
}
+ Builder setContainers(@Nullable IBinder[] containers) {
+ mContainers = containers;
+ return this;
+ }
+
Builder setReparentContainer(@Nullable IBinder reparentContainer) {
mReparent = reparentContainer;
return this;
@@ -2209,6 +2283,7 @@ public final class WindowContainerTransaction implements Parcelable {
HierarchyOp build() {
final HierarchyOp hierarchyOp = new HierarchyOp(mType);
hierarchyOp.mContainer = mContainer;
+ hierarchyOp.mContainers = mContainers;
hierarchyOp.mReparent = mReparent;
hierarchyOp.mWindowingModes = mWindowingModes != null
? Arrays.copyOf(mWindowingModes, mWindowingModes.length)
diff --git a/core/java/android/window/flags/lse_desktop_experience.aconfig b/core/java/android/window/flags/lse_desktop_experience.aconfig
index a05d003b2faf..6caa20e29c17 100644
--- a/core/java/android/window/flags/lse_desktop_experience.aconfig
+++ b/core/java/android/window/flags/lse_desktop_experience.aconfig
@@ -414,6 +414,16 @@ flag {
}
flag {
+ name: "enable_desktop_recents_transitions_corners_bugfix"
+ namespace: "lse_desktop_experience"
+ description: "Enables rounded corners bugfix for Recents transitions."
+ bug: "383079261"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "enable_move_to_next_display_shortcut"
namespace: "lse_desktop_experience"
description: "Add new keyboard shortcut of moving a task into next display"
@@ -500,4 +510,11 @@ flag {
metadata {
purpose: PURPOSE_BUGFIX
}
+}
+
+flag {
+ name: "enable_per_display_desktop_wallpaper_activity"
+ namespace: "lse_desktop_experience"
+ description: "Enables having a DesktopWallpaperActivity at a per-display level."
+ bug: "381935663"
} \ No newline at end of file
diff --git a/core/java/android/window/flags/windowing_frontend.aconfig b/core/java/android/window/flags/windowing_frontend.aconfig
index 30f0c7371270..1c27515b06f0 100644
--- a/core/java/android/window/flags/windowing_frontend.aconfig
+++ b/core/java/android/window/flags/windowing_frontend.aconfig
@@ -455,6 +455,17 @@ flag {
}
flag {
+ name: "remove_defer_hiding_client"
+ namespace: "windowing_frontend"
+ description: "Remove mDeferHidingClient since everything is in shell-transition."
+ is_fixed_read_only: true
+ bug: "382485959"
+ metadata {
+ purpose: PURPOSE_BUGFIX
+ }
+}
+
+flag {
name: "relative_insets"
namespace: "windowing_frontend"
description: "Support insets definition and calculation relative to task bounds."
diff --git a/core/java/com/android/internal/inputmethod/InputMethodDebug.java b/core/java/com/android/internal/inputmethod/InputMethodDebug.java
index 2a5593f6d584..4d5e67ab8fde 100644
--- a/core/java/com/android/internal/inputmethod/InputMethodDebug.java
+++ b/core/java/com/android/internal/inputmethod/InputMethodDebug.java
@@ -299,6 +299,12 @@ public final class InputMethodDebug {
return "SHOW_SOFT_INPUT_IMM_DEPRECATION";
case SoftInputShowHideReason.CONTROL_WINDOW_INSETS_ANIMATION:
return "CONTROL_WINDOW_INSETS_ANIMATION";
+ case SoftInputShowHideReason.SHOW_INPUT_TARGET_CHANGED:
+ return "SHOW_INPUT_TARGET_CHANGED";
+ case SoftInputShowHideReason.HIDE_INPUT_TARGET_CHANGED:
+ return "HIDE_INPUT_TARGET_CHANGED";
+ case SoftInputShowHideReason.HIDE_WINDOW_LOST_FOCUS:
+ return "HIDE_WINDOW_LOST_FOCUS";
default:
return "Unknown=" + reason;
}
diff --git a/core/java/com/android/internal/inputmethod/SoftInputShowHideReason.java b/core/java/com/android/internal/inputmethod/SoftInputShowHideReason.java
index 592ea9e5e600..cf0580c2f021 100644
--- a/core/java/com/android/internal/inputmethod/SoftInputShowHideReason.java
+++ b/core/java/com/android/internal/inputmethod/SoftInputShowHideReason.java
@@ -91,7 +91,7 @@ import java.lang.annotation.Retention;
SoftInputShowHideReason.CONTROL_WINDOW_INSETS_ANIMATION,
SoftInputShowHideReason.SHOW_INPUT_TARGET_CHANGED,
SoftInputShowHideReason.HIDE_INPUT_TARGET_CHANGED,
- SoftInputShowHideReason.REASON_HIDE_WINDOW_LOST_FOCUS,
+ SoftInputShowHideReason.HIDE_WINDOW_LOST_FOCUS,
})
public @interface SoftInputShowHideReason {
/** Default, undefined reason. */
@@ -340,18 +340,6 @@ public @interface SoftInputShowHideReason {
int HIDE_WINDOW_LEGACY_DIRECT = ImeProtoEnums.REASON_HIDE_WINDOW_LEGACY_DIRECT;
/**
- * Show soft input because the input target changed
- * {@link com.android.server.wm.ImeInsetsSourceProvider#onInputTargetChanged}.
- */
- int SHOW_INPUT_TARGET_CHANGED = ImeProtoEnums.REASON_SHOW_INPUT_TARGET_CHANGED;
-
- /**
- * Hide soft input because the input target changed by
- * {@link com.android.server.wm.ImeInsetsSourceProvider#onInputTargetChanged}.
- */
- int HIDE_INPUT_TARGET_CHANGED = ImeProtoEnums.REASON_HIDE_INPUT_TARGET_CHANGED;
-
- /**
* Show / Hide soft input by
* {@link android.inputmethodservice.InputMethodService#resetStateForNewConfiguration}.
*/
@@ -420,6 +408,18 @@ public @interface SoftInputShowHideReason {
*/
int CONTROL_WINDOW_INSETS_ANIMATION = ImeProtoEnums.REASON_CONTROL_WINDOW_INSETS_ANIMATION;
+ /**
+ * Show soft input because the input target changed
+ * {@link com.android.server.wm.ImeInsetsSourceProvider#onInputTargetChanged}.
+ */
+ int SHOW_INPUT_TARGET_CHANGED = ImeProtoEnums.REASON_SHOW_INPUT_TARGET_CHANGED;
+
+ /**
+ * Hide soft input because the input target changed by
+ * {@link com.android.server.wm.ImeInsetsSourceProvider#onInputTargetChanged}.
+ */
+ int HIDE_INPUT_TARGET_CHANGED = ImeProtoEnums.REASON_HIDE_INPUT_TARGET_CHANGED;
+
/** Hide soft input when the window lost focus. */
- int REASON_HIDE_WINDOW_LOST_FOCUS = ImeProtoEnums.REASON_HIDE_WINDOW_LOST_FOCUS;
+ int HIDE_WINDOW_LOST_FOCUS = ImeProtoEnums.REASON_HIDE_WINDOW_LOST_FOCUS;
}
diff --git a/core/res/res/values/attrs_manifest.xml b/core/res/res/values/attrs_manifest.xml
index 00c59c6c0edc..a06d184fd147 100644
--- a/core/res/res/values/attrs_manifest.xml
+++ b/core/res/res/values/attrs_manifest.xml
@@ -2572,7 +2572,9 @@
against a development branch, in which case it will only work against
the development builds. -->
<attr name="minSdkVersion" format="integer|string" />
- <!-- @FlaggedApi(android.sdk.Flags.FLAG_MAJOR_MINOR_VERSIONING_SCHEME) -->
+ <!-- This is the minimum SDK major and minor version (e.g. "36.1") that
+ the application requires. Verified independently of minSdkVersion.
+ @FlaggedApi(android.sdk.Flags.FLAG_MAJOR_MINOR_VERSIONING_SCHEME) -->
<attr name="minSdkVersionFull" format="string" />
<!-- This is the SDK version number that the application is targeting.
It is able to run on older versions (down to minSdkVersion), but
diff --git a/core/res/res/values/config.xml b/core/res/res/values/config.xml
index 53b47622e8ae..89184bcc3721 100644
--- a/core/res/res/values/config.xml
+++ b/core/res/res/values/config.xml
@@ -7212,10 +7212,6 @@
screen. -->
<bool name="config_dragToMaximizeInDesktopMode">false</bool>
- <!-- Whether showing the app handle is supported on this device.
- If config_isDesktopModeSupported, then this has no effect -->
- <bool name="config_enableAppHandle">false</bool>
-
<!-- Frame rate compatibility value for Wallpaper
FRAME_RATE_COMPATIBILITY_MIN (102) is used by default for lower power consumption -->
<integer name="config_wallpaperFrameRateCompatibility">102</integer>
diff --git a/core/res/res/values/symbols.xml b/core/res/res/values/symbols.xml
index 71532bbbe725..6c01994b3c93 100644
--- a/core/res/res/values/symbols.xml
+++ b/core/res/res/values/symbols.xml
@@ -5681,9 +5681,6 @@
screen. -->
<java-symbol type="bool" name="config_dragToMaximizeInDesktopMode" />
- <!-- Whether showing the app handle is supported on this device -->
- <java-symbol type="bool" name="config_enableAppHandle" />
-
<!-- Frame rate compatibility value for Wallpaper -->
<java-symbol type="integer" name="config_wallpaperFrameRateCompatibility" />
diff --git a/libs/WindowManager/Shell/shared/Android.bp b/libs/WindowManager/Shell/shared/Android.bp
index 5113d980fb7d..5bbda95c466f 100644
--- a/libs/WindowManager/Shell/shared/Android.bp
+++ b/libs/WindowManager/Shell/shared/Android.bp
@@ -26,6 +26,7 @@ filegroup {
name: "wm_shell-shared-utils",
srcs: [
"src/com/android/wm/shell/shared/TransitionUtil.java",
+ "src/com/android/wm/shell/shared/Utils.java",
],
}
@@ -71,6 +72,7 @@ java_library {
srcs: [
"**/desktopmode/*.java",
"**/desktopmode/*.kt",
+ ":wm_shell-shared-utils",
],
static_libs: [
"com.android.window.flags.window-aconfig-java",
diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/Utils.java b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/Utils.java
new file mode 100644
index 000000000000..e19027a352f7
--- /dev/null
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/Utils.java
@@ -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.wm.shell.shared;
+
+import android.annotation.NonNull;
+
+import java.util.function.Supplier;
+
+/**
+ * This class provides generic utility methods and classes for shell
+ */
+public class Utils {
+
+ /**
+ * Lazily returns object from a supplier with caching
+ * @param <T> type of object to get
+ */
+ public static class Lazy<T> {
+ private T mInstance;
+
+ /**
+ * @param supplier the supplier to use, when the instance has not yet been initialized
+ * @return the cached value or the value from the supplier
+ */
+ public final T get(@NonNull Supplier<T> supplier) {
+ if (mInstance == null) {
+ mInstance = supplier.get();
+ }
+ return mInstance;
+ }
+ }
+}
diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java
index 4c77eaf80a29..a5d698aff2a2 100644
--- a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/desktopmode/DesktopModeStatus.java
@@ -16,16 +16,23 @@
package com.android.wm.shell.shared.desktopmode;
+import static android.hardware.display.DisplayManager.DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED;
+
import android.annotation.NonNull;
import android.content.Context;
+import android.hardware.display.DisplayManager;
import android.os.SystemProperties;
+import android.view.Display;
+import android.view.WindowManager;
import android.window.DesktopModeFlags;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.window.flags.Flags;
+import com.android.wm.shell.shared.Utils.Lazy;
import java.io.PrintWriter;
+import java.util.Arrays;
/**
* Constants for desktop mode feature
@@ -35,6 +42,8 @@ public class DesktopModeStatus {
private static final String TAG = "DesktopModeStatus";
+ private static Lazy<Boolean> sIsLargeScreenDevice = new Lazy<>();
+
/**
* Flag to indicate whether task resizing is veiled.
*/
@@ -227,13 +236,12 @@ public class DesktopModeStatus {
* necessarily enabling desktop mode
*/
public static boolean overridesShowAppHandle(@NonNull Context context) {
- return Flags.showAppHandleLargeScreens()
- && context.getResources().getBoolean(R.bool.config_enableAppHandle);
+ return Flags.showAppHandleLargeScreens() && deviceHasLargeScreen(context);
}
/**
* @return {@code true} if the app handle should be shown because desktop mode is enabled or
- * the device is overriding {@code R.bool.config_enableAppHandle}
+ * the device has a large screen
*/
public static boolean canEnterDesktopModeOrShowAppHandle(@NonNull Context context) {
return canEnterDesktopMode(context) || overridesShowAppHandle(context);
@@ -276,6 +284,18 @@ public class DesktopModeStatus {
}
/**
+ * @return {@code true} if this device has an internal large screen
+ */
+ private static boolean deviceHasLargeScreen(@NonNull Context context) {
+ return sIsLargeScreenDevice.get(() -> Arrays.stream(
+ context.getSystemService(DisplayManager.class)
+ .getDisplays(DISPLAY_CATEGORY_ALL_INCLUDING_DISABLED))
+ .filter(display -> display.getType() == Display.TYPE_INTERNAL)
+ .anyMatch(display -> display.getMinSizeDimensionDp()
+ >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP));
+ }
+
+ /**
* Return {@code true} if a display should enter desktop mode by default when the windowing mode
* of the display's root [TaskDisplayArea] is set to WINDOWING_MODE_FREEFORM.
*/
@@ -315,6 +335,6 @@ public class DesktopModeStatus {
pw.println(maxTaskLimitHandle == null ? "null" : maxTaskLimitHandle.getInt(/* def= */ -1));
pw.print(innerPrefix); pw.print("showAppHandle config override=");
- pw.print(context.getResources().getBoolean(R.bool.config_enableAppHandle));
+ pw.print(overridesShowAppHandle(context));
}
}
diff --git a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/split/SplitScreenConstants.java b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/split/SplitScreenConstants.java
index f9f43bc8dfae..86be0d4a4ea5 100644
--- a/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/split/SplitScreenConstants.java
+++ b/libs/WindowManager/Shell/shared/src/com/android/wm/shell/shared/split/SplitScreenConstants.java
@@ -159,7 +159,8 @@ public class SplitScreenConstants {
* {@link PersistentSnapPosition} + {@link #NOT_IN_SPLIT}.
*/
@IntDef(value = {
- NOT_IN_SPLIT,
+ NOT_IN_SPLIT, // user is not in split screen
+ SNAP_TO_NONE, // in "free snap mode," where apps are fully resizable
SNAP_TO_2_33_66,
SNAP_TO_2_50_50,
SNAP_TO_2_66_33,
@@ -171,6 +172,23 @@ public class SplitScreenConstants {
})
public @interface SplitScreenState {}
+ /** Converts a {@link SplitScreenState} to a human-readable string. */
+ public static String stateToString(@SplitScreenState int state) {
+ return switch (state) {
+ case NOT_IN_SPLIT -> "NOT_IN_SPLIT";
+ case SNAP_TO_NONE -> "SNAP_TO_NONE";
+ case SNAP_TO_2_33_66 -> "SNAP_TO_2_33_66";
+ case SNAP_TO_2_50_50 -> "SNAP_TO_2_50_50";
+ case SNAP_TO_2_66_33 -> "SNAP_TO_2_66_33";
+ case SNAP_TO_2_90_10 -> "SNAP_TO_2_90_10";
+ case SNAP_TO_2_10_90 -> "SNAP_TO_2_10_90";
+ case SNAP_TO_3_33_33_33 -> "SNAP_TO_3_33_33_33";
+ case SNAP_TO_3_45_45_10 -> "SNAP_TO_3_45_45_10";
+ case SNAP_TO_3_10_45_45 -> "SNAP_TO_3_10_45_45";
+ default -> "UNKNOWN";
+ };
+ }
+
/**
* Checks if the snapPosition in question is a {@link PersistentSnapPosition}.
*/
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/apptoweb/AppToWebUtils.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/apptoweb/AppToWebUtils.kt
index 7243ea36b137..68c42d6a2648 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/apptoweb/AppToWebUtils.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/apptoweb/AppToWebUtils.kt
@@ -18,6 +18,8 @@
package com.android.wm.shell.apptoweb
+import android.app.assist.AssistContent
+import android.app.assist.AssistContent.EXTRA_SESSION_TRANSFER_WEB_URI
import android.content.Context
import android.content.Intent
import android.content.Intent.ACTION_VIEW
@@ -102,3 +104,10 @@ fun getDomainVerificationUserState(
return null
}
}
+
+/**
+ * Returns the web uri from the given [AssistContent].
+ */
+fun AssistContent.getSessionWebUri(): Uri? {
+ return extras.getParcelable(EXTRA_SESSION_TRANSFER_WEB_URI) ?: webUri
+}
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 60a52a808a54..56efdb885512 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
@@ -1314,7 +1314,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
}
}
- if (handlePrepareTransition(info, st, ft, finishCallback)) {
+ if (handlePrepareTransition(transition, info, st, ft, finishCallback)) {
if (checkTakeoverFlags()) {
mTakeoverHandler = mTransitions.getHandlerForTakeover(transition, info);
}
@@ -1630,7 +1630,7 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
* happen when core make an activity become visible.
*/
@VisibleForTesting
- boolean handlePrepareTransition(
+ boolean handlePrepareTransition(@NonNull IBinder transition,
@NonNull TransitionInfo info,
@NonNull SurfaceControl.Transaction st,
@NonNull SurfaceControl.Transaction ft,
@@ -1678,6 +1678,8 @@ public class BackAnimationController implements RemoteCallable<BackAnimationCont
}
}
st.apply();
+ // In case other transition handler took the handleRequest before this class.
+ mPrepareOpenTransition = transition;
mFinishOpenTransaction = ft;
mFinishOpenTransitionCallback = finishCallback;
mOpenTransitionInfo = info;
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java
index 5129d83cdd8b..c74bf53268f9 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/DisplayImeController.java
@@ -338,6 +338,11 @@ public class DisplayImeController implements DisplayController.OnDisplaysChanged
// Make mImeSourceControl point to the new control before starting the animation.
if (hadImeSourceControl && mImeSourceControl != imeSourceControl) {
mImeSourceControl.release(SurfaceControl::release);
+ if (android.view.inputmethod.Flags.refactorInsetsController()
+ && !hasImeLeash && mAnimation != null) {
+ // In case of losing the leash, the animation should be cancelled.
+ mAnimation.cancel();
+ }
}
mImeSourceControl = imeSourceControl;
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 813772f20a8a..2f5afcaa907b 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
@@ -352,8 +352,8 @@ public class DividerSnapAlgorithm {
? mPinnedTaskbarInsets.right : mPinnedTaskbarInsets.bottom;
float ratio = areOffscreenRatiosSupported()
- ? SplitLayout.OFFSCREEN_ASYMMETRIC_RATIO
- : SplitLayout.ONSCREEN_ONLY_ASYMMETRIC_RATIO;
+ ? SplitSpec.OFFSCREEN_ASYMMETRIC_RATIO
+ : SplitSpec.ONSCREEN_ONLY_ASYMMETRIC_RATIO;
int size = (int) (ratio * (end - start)) - mDividerSize / 2;
int leftTopPosition = start + pinnedTaskbarShiftStart + size;
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 e6b6ef737f6e..88c91db27bf3 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
@@ -112,11 +112,6 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
private static final int FLING_EXIT_DURATION = 450;
private static final int FLING_OFFSCREEN_DURATION = 500;
- /** A split ratio used on larger screens, where we can fit both apps onscreen. */
- public static final float ONSCREEN_ONLY_ASYMMETRIC_RATIO = 0.33f;
- /** A split ratio used on smaller screens, where we place one app mostly offscreen. */
- public static final float OFFSCREEN_ASYMMETRIC_RATIO = 0.1f;
-
// Here are some (arbitrarily decided) layer definitions used during animations to make sure the
// layers stay in order. (During transitions, everything is reparented onto a transition root
// and can be freely relayered.)
@@ -236,7 +231,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
updateDividerConfig(mContext);
mRootBounds.set(configuration.windowConfiguration.getBounds());
- mDividerSnapAlgorithm = getSnapAlgorithm(mContext, mRootBounds);
+ updateLayouts();
mInteractionJankMonitor = InteractionJankMonitor.getInstance();
resetDividerPosition();
updateInvisibleRect();
@@ -490,7 +485,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
mIsLargeScreen = configuration.smallestScreenWidthDp >= 600;
mIsLeftRightSplit = SplitScreenUtils.isLeftRightSplit(mAllowLeftRightSplitInPortrait,
configuration);
- mDividerSnapAlgorithm = getSnapAlgorithm(mContext, mRootBounds);
+ updateLayouts();
updateDividerConfig(mContext);
initDividerPosition(mTempRect, wasLeftRightSplit);
updateInvisibleRect();
@@ -518,7 +513,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
mRootBounds.set(tmpRect);
mIsLeftRightSplit = SplitScreenUtils.isLeftRightSplit(mAllowLeftRightSplitInPortrait,
mIsLargeScreen, mRootBounds.width() >= mRootBounds.height());
- mDividerSnapAlgorithm = getSnapAlgorithm(mContext, mRootBounds);
+ updateLayouts();
initDividerPosition(mTempRect, wasLeftRightSplit);
}
@@ -652,7 +647,7 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
if (!mPinnedTaskbarInsets.equals(pinnedTaskbarInsets)) {
mPinnedTaskbarInsets = pinnedTaskbarInsets;
// Refresh the DividerSnapAlgorithm.
- mDividerSnapAlgorithm = getSnapAlgorithm(mContext, mRootBounds);
+ updateLayouts();
// If the divider is no longer placed on a snap point, animate it to the nearest one.
DividerSnapAlgorithm.SnapTarget snapTarget =
findSnapTarget(mDividerPosition, 0, false /* hardDismiss */);
@@ -824,8 +819,22 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
return mDividerSnapAlgorithm.calculateSnapTarget(position, velocity, hardDismiss);
}
- private DividerSnapAlgorithm getSnapAlgorithm(Context context, Rect rootBounds) {
- final Rect insets = getDisplayStableInsets(context);
+ /**
+ * (Re)calculates the split screen logic for this particular display/orientation. Refreshes the
+ * DividerSnapAlgorithm, which controls divider snap points, and populates a map in SplitState
+ * with bounds for all valid split layouts.
+ */
+ private void updateLayouts() {
+ // Update SplitState map
+
+ if (Flags.enableFlexibleTwoAppSplit()) {
+ mSplitState.populateLayouts(
+ mRootBounds, mDividerSize, mIsLeftRightSplit, mPinnedTaskbarInsets.toRect());
+ }
+
+ // Get new DividerSnapAlgorithm
+
+ final Rect insets = getDisplayStableInsets(mContext);
// Make split axis insets value same as the larger one to avoid bounds1 and bounds2
// have difference for avoiding size-compat mode when switching unresizable apps in
@@ -835,10 +844,10 @@ public final class SplitLayout implements DisplayInsetsController.OnInsetsChange
insets.set(insets.left, largerInsets, insets.right, largerInsets);
}
- return new DividerSnapAlgorithm(
- context.getResources(),
- rootBounds.width(),
- rootBounds.height(),
+ mDividerSnapAlgorithm = new DividerSnapAlgorithm(
+ mContext.getResources(),
+ mRootBounds.width(),
+ mRootBounds.height(),
mDividerSize,
mIsLeftRightSplit,
insets,
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitSpec.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitSpec.java
new file mode 100644
index 000000000000..9c951bd89876
--- /dev/null
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitSpec.java
@@ -0,0 +1,183 @@
+/*
+ * 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.common.split;
+
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_10_90;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_33_66;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_50_50;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_66_33;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_2_90_10;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_3_10_45_45;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_3_33_33_33;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.SNAP_TO_3_45_45_10;
+import static com.android.wm.shell.shared.split.SplitScreenConstants.stateToString;
+
+import android.graphics.Rect;
+import android.graphics.RectF;
+import android.util.Log;
+
+import com.android.wm.shell.shared.split.SplitScreenConstants.SplitScreenState;
+
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+/**
+ * A reference class that stores the split layouts available in this device/orientation. Layouts are
+ * available as lists of RectFs, where each RectF represents the bounds of an app.
+ */
+public class SplitSpec {
+ private static final String TAG = "SplitSpec";
+ private static final boolean DEBUG = true;
+
+ /** A split ratio used on larger screens, where we can fit both apps onscreen. */
+ public static final float ONSCREEN_ONLY_ASYMMETRIC_RATIO = 0.33f;
+ /** A split ratio used on smaller screens, where we place one app mostly offscreen. */
+ public static final float OFFSCREEN_ASYMMETRIC_RATIO = 0.1f;
+ /** A 50-50 split ratio. */
+ public static final float MIDDLE_RATIO = 0.5f;
+
+ private final boolean mIsLeftRightSplit;
+ /** The usable display area, considering insets that affect split bounds. */
+ private final RectF mUsableArea;
+ /** Half the divider size. */
+ private final float mHalfDiv;
+
+ /** A large map that stores all valid split layouts. */
+ private final Map<Integer, List<RectF>> mLayouts = new HashMap<>();
+
+ /** Constructor; initializes the layout map. */
+ public SplitSpec(Rect displayBounds, int dividerSize, boolean isLeftRightSplit,
+ Rect pinnedTaskbarInsets) {
+ mIsLeftRightSplit = isLeftRightSplit;
+ mUsableArea = new RectF(displayBounds);
+ mUsableArea.left += pinnedTaskbarInsets.left;
+ mUsableArea.top += pinnedTaskbarInsets.top;
+ mUsableArea.right -= pinnedTaskbarInsets.right;
+ mUsableArea.bottom -= pinnedTaskbarInsets.bottom;
+ mHalfDiv = dividerSize / 2f;
+
+ // The "start" position, considering insets.
+ float s = isLeftRightSplit ? mUsableArea.left : mUsableArea.top;
+ // The "end" position, considering insets.
+ float e = isLeftRightSplit ? mUsableArea.right : mUsableArea.bottom;
+ // The "length" of the usable display (width or height). Apps are arranged along this axis.
+ float l = e - s;
+ float divPos;
+ float divPos2;
+
+ // SNAP_TO_2_10_90
+ divPos = s + (l * OFFSCREEN_ASYMMETRIC_RATIO);
+ createAppLayout(SNAP_TO_2_10_90, divPos);
+
+ // SNAP_TO_2_33_66
+ divPos = s + (l * ONSCREEN_ONLY_ASYMMETRIC_RATIO);
+ createAppLayout(SNAP_TO_2_33_66, divPos);
+
+ // SNAP_TO_2_50_50
+ divPos = s + (l * MIDDLE_RATIO);
+ createAppLayout(SNAP_TO_2_50_50, divPos);
+
+ // SNAP_TO_2_66_33
+ divPos = s + (l * (1 - ONSCREEN_ONLY_ASYMMETRIC_RATIO));
+ createAppLayout(SNAP_TO_2_66_33, divPos);
+
+ // SNAP_TO_2_90_10
+ divPos = s + (l * (1 - OFFSCREEN_ASYMMETRIC_RATIO));
+ createAppLayout(SNAP_TO_2_90_10, divPos);
+
+ // SNAP_TO_3_10_45_45
+ divPos = s + (l * OFFSCREEN_ASYMMETRIC_RATIO);
+ divPos2 = e - ((l * (1 - OFFSCREEN_ASYMMETRIC_RATIO)) / 2f);
+ createAppLayout(SNAP_TO_3_10_45_45, divPos, divPos2);
+
+ // SNAP_TO_3_33_33_33
+ divPos = s + (l * ONSCREEN_ONLY_ASYMMETRIC_RATIO);
+ divPos2 = e - (l * ONSCREEN_ONLY_ASYMMETRIC_RATIO);
+ createAppLayout(SNAP_TO_3_33_33_33, divPos, divPos2);
+
+ // SNAP_TO_3_45_45_10
+ divPos = s + ((l * (1 - OFFSCREEN_ASYMMETRIC_RATIO)) / 2f);
+ divPos2 = e - (l * OFFSCREEN_ASYMMETRIC_RATIO);
+ createAppLayout(SNAP_TO_3_45_45_10, divPos, divPos2);
+
+ if (DEBUG) {
+ dump();
+ }
+ }
+
+ /**
+ * Creates a two-app layout and enters it into the layout map.
+ * @param divPos The position of the divider.
+ */
+ private void createAppLayout(@SplitScreenState int state, float divPos) {
+ List<RectF> list = new ArrayList<>();
+ RectF rect1 = new RectF(mUsableArea);
+ RectF rect2 = new RectF(mUsableArea);
+ if (mIsLeftRightSplit) {
+ rect1.right = divPos - mHalfDiv;
+ rect2.left = divPos + mHalfDiv;
+ } else {
+ rect1.top = divPos - mHalfDiv;
+ rect2.bottom = divPos + mHalfDiv;
+ }
+ list.add(rect1);
+ list.add(rect2);
+ mLayouts.put(state, list);
+ }
+
+ /**
+ * Creates a three-app layout and enters it into the layout map.
+ * @param divPos1 The position of the first divider.
+ * @param divPos2 The position of the second divider.
+ */
+ private void createAppLayout(@SplitScreenState int state, float divPos1, float divPos2) {
+ List<RectF> list = new ArrayList<>();
+ RectF rect1 = new RectF(mUsableArea);
+ RectF rect2 = new RectF(mUsableArea);
+ RectF rect3 = new RectF(mUsableArea);
+ if (mIsLeftRightSplit) {
+ rect1.right = divPos1 - mHalfDiv;
+ rect2.left = divPos1 + mHalfDiv;
+ rect2.right = divPos2 - mHalfDiv;
+ rect3.left = divPos2 + mHalfDiv;
+ } else {
+ rect1.right = divPos1 - mHalfDiv;
+ rect2.left = divPos1 + mHalfDiv;
+ rect3.right = divPos2 - mHalfDiv;
+ rect3.left = divPos2 + mHalfDiv;
+ }
+ list.add(rect1);
+ list.add(rect2);
+ list.add(rect3);
+ mLayouts.put(state, list);
+ }
+
+ /** Logs all calculated layouts */
+ private void dump() {
+ mLayouts.forEach((k, v) -> {
+ Log.d(TAG, stateToString(k));
+ v.forEach(rect -> Log.d(TAG, " - " + rect.toShortString()));
+ });
+ }
+
+ /** Returns the layout associated with a given split state. */
+ List<RectF> getSpec(@SplitScreenState int state) {
+ return mLayouts.get(state);
+ }
+}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitState.java b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitState.java
index 71758e0d2159..d1d133d16ae4 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitState.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/common/split/SplitState.java
@@ -19,11 +19,17 @@ package com.android.wm.shell.common.split;
import static com.android.wm.shell.shared.split.SplitScreenConstants.NOT_IN_SPLIT;
import static com.android.wm.shell.shared.split.SplitScreenConstants.SplitScreenState;
+import android.graphics.Rect;
+import android.graphics.RectF;
+
+import java.util.List;
+
/**
* A class that manages the "state" of split screen. See {@link SplitScreenState} for definitions.
*/
public class SplitState {
private @SplitScreenState int mState = NOT_IN_SPLIT;
+ private SplitSpec mSplitSpec;
/** Updates the current state of split screen on this device. */
public void set(@SplitScreenState int newState) {
@@ -39,4 +45,16 @@ public class SplitState {
public void exit() {
set(NOT_IN_SPLIT);
}
+
+ /** Refresh the valid layouts for this display/orientation. */
+ public void populateLayouts(Rect displayBounds, int dividerSize, boolean isLeftRightSplit,
+ Rect pinnedTaskbarInsets) {
+ mSplitSpec =
+ new SplitSpec(displayBounds, dividerSize, isLeftRightSplit, pinnedTaskbarInsets);
+ }
+
+ /** Returns the layout associated with a given split state. */
+ public List<RectF> getLayout(@SplitScreenState int state) {
+ return mSplitSpec.getSpec(state);
+ }
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
index 9d4b4bbb33de..fe6066c8c4fb 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/compatui/CompatUIController.java
@@ -55,6 +55,7 @@ import com.android.wm.shell.compatui.api.CompatUIHandler;
import com.android.wm.shell.compatui.api.CompatUIInfo;
import com.android.wm.shell.compatui.impl.CompatUIEvents.SizeCompatRestartButtonClicked;
import com.android.wm.shell.desktopmode.DesktopUserRepositories;
+import com.android.wm.shell.shared.desktopmode.DesktopModeStatus;
import com.android.wm.shell.sysui.KeyguardChangeListener;
import com.android.wm.shell.sysui.ShellController;
import com.android.wm.shell.sysui.ShellInit;
@@ -70,7 +71,6 @@ import java.util.Optional;
import java.util.Set;
import java.util.function.Consumer;
import java.util.function.Function;
-import java.util.function.IntPredicate;
import java.util.function.Predicate;
/**
@@ -667,9 +667,10 @@ public class CompatUIController implements OnDisplaysChangedListener,
private void createOrUpdateUserAspectRatioSettingsLayout(@NonNull TaskInfo taskInfo,
@Nullable ShellTaskOrganizer.TaskListener taskListener) {
+ boolean overridesShowAppHandle = DesktopModeStatus.overridesShowAppHandle(mContext);
if (mUserAspectRatioSettingsLayout != null) {
if (mUserAspectRatioSettingsLayout.needsToBeRecreated(taskInfo, taskListener)
- || mIsInDesktopMode) {
+ || mIsInDesktopMode || overridesShowAppHandle) {
mUserAspectRatioSettingsLayout.release();
mUserAspectRatioSettingsLayout = null;
} else {
@@ -682,8 +683,9 @@ public class CompatUIController implements OnDisplaysChangedListener,
return;
}
}
- if (mIsInDesktopMode) {
- // Return if in desktop mode.
+ if (mIsInDesktopMode || overridesShowAppHandle) {
+ // Return if in desktop mode or app handle menu is already showing change aspect ratio
+ // option.
return;
}
// Create a new UI layout.
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java
index 0cd0f4a97bbf..9d2da41725b1 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/dagger/WMShellModule.java
@@ -1025,12 +1025,14 @@ public abstract class WMShellModule {
static DesktopUserRepositories provideDesktopUserRepositories(
Context context,
ShellInit shellInit,
+ ShellController shellController,
DesktopPersistentRepository desktopPersistentRepository,
DesktopRepositoryInitializer desktopRepositoryInitializer,
@ShellMainThread CoroutineScope mainScope,
UserManager userManager
) {
- return new DesktopUserRepositories(context, shellInit, desktopPersistentRepository,
+ return new DesktopUserRepositories(context, shellInit, shellController,
+ desktopPersistentRepository,
desktopRepositoryInitializer,
mainScope, userManager);
}
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt
index 14623cf9e703..606a729305b4 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopModeUtils.kt
@@ -235,8 +235,7 @@ fun isTaskWidthOrHeightEqual(taskBounds: Rect, stableBounds: Rect): Boolean {
/** Returns true if task bound is equal to stable bounds else returns false. */
fun isTaskBoundsEqual(taskBounds: Rect, stableBounds: Rect): Boolean {
- return taskBounds.width() == stableBounds.width() &&
- taskBounds.height() == stableBounds.height()
+ return taskBounds == stableBounds
}
/**
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopUserRepositories.kt b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopUserRepositories.kt
index e5f52839d9f4..8b5d1c502bc9 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopUserRepositories.kt
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/desktopmode/DesktopUserRepositories.kt
@@ -28,6 +28,7 @@ import com.android.wm.shell.desktopmode.persistence.DesktopRepositoryInitializer
import com.android.wm.shell.protolog.ShellProtoLogGroup.WM_SHELL_DESKTOP_MODE
import com.android.wm.shell.shared.annotations.ShellMainThread
import com.android.wm.shell.shared.desktopmode.DesktopModeStatus
+import com.android.wm.shell.sysui.ShellController
import com.android.wm.shell.sysui.ShellInit
import com.android.wm.shell.sysui.UserChangeListener
import kotlinx.coroutines.CoroutineScope
@@ -36,6 +37,7 @@ import kotlinx.coroutines.CoroutineScope
class DesktopUserRepositories(
context: Context,
shellInit: ShellInit,
+ private val shellController: ShellController,
private val persistentRepository: DesktopPersistentRepository,
private val repositoryInitializer: DesktopRepositoryInitializer,
@ShellMainThread private val mainCoroutineScope: CoroutineScope,
@@ -61,15 +63,16 @@ class DesktopUserRepositories(
init {
userId = ActivityManager.getCurrentUser()
if (DesktopModeStatus.canEnterDesktopMode(context)) {
- shellInit.addInitCallback(::initRepoFromPersistentStorage, this)
+ shellInit.addInitCallback(::onInit, this)
}
if (Flags.enableDesktopWindowingHsum()) {
userIdToProfileIdsMap[userId] = userManager.getProfiles(userId).map { it.id }
}
}
- private fun initRepoFromPersistentStorage() {
+ private fun onInit() {
repositoryInitializer.initialize(this)
+ shellController.addUserChangeListener(this)
}
/** Returns [DesktopRepository] for the parent user id. */
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java
index dae3c21b6697..acb5622b041c 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/pip2/phone/PipTransition.java
@@ -124,7 +124,6 @@ public class PipTransition extends PipTransitionController implements
// Internal state and relevant cached info
//
- @Nullable
private Transitions.TransitionFinishCallback mFinishCallback;
private ValueAnimator mTransitionAnimator;
@@ -236,7 +235,6 @@ public class PipTransition extends PipTransitionController implements
@NonNull SurfaceControl.Transaction startTransaction,
@NonNull SurfaceControl.Transaction finishTransaction,
@NonNull Transitions.TransitionFinishCallback finishCallback) {
- mFinishCallback = finishCallback;
if (transition == mEnterTransition || info.getType() == TRANSIT_PIP) {
mEnterTransition = null;
// If we are in swipe PiP to Home transition we are ENTERING_PIP as a jumpcut transition
@@ -282,7 +280,6 @@ public class PipTransition extends PipTransitionController implements
if (isRemovePipTransition(info)) {
return removePipImmediately(info, startTransaction, finishTransaction, finishCallback);
}
- mFinishCallback = null;
return false;
}
@@ -331,6 +328,7 @@ public class PipTransition extends PipTransitionController implements
if (pipChange == null) {
return false;
}
+ mFinishCallback = finishCallback;
// We expect the PiP activity as a separate change in a config-at-end transition;
// only flings are not using config-at-end for resize bounds changes
TransitionInfo.Change pipActivityChange = getDeferConfigActivityChange(info,
@@ -378,6 +376,7 @@ public class PipTransition extends PipTransitionController implements
if (pipActivityChange == null) {
return false;
}
+ mFinishCallback = finishCallback;
final SurfaceControl pipLeash = getLeash(pipChange);
final Rect destinationBounds = pipChange.getEndAbsBounds();
@@ -446,6 +445,7 @@ public class PipTransition extends PipTransitionController implements
if (pipActivityChange == null) {
return false;
}
+ mFinishCallback = finishCallback;
final SurfaceControl pipLeash = getLeash(pipChange);
final Rect startBounds = pipChange.getStartAbsBounds();
@@ -572,6 +572,7 @@ public class PipTransition extends PipTransitionController implements
if (pipChange == null) {
return false;
}
+ mFinishCallback = finishCallback;
Rect destinationBounds = pipChange.getEndAbsBounds();
SurfaceControl pipLeash = mPipTransitionState.getPinnedTaskLeash();
@@ -614,6 +615,7 @@ public class PipTransition extends PipTransitionController implements
return false;
}
}
+ mFinishCallback = finishCallback;
// The parent change if we were in a multi-activity PiP; null if single activity PiP.
final TransitionInfo.Change parentBeforePip = pipChange.getTaskInfo() == null
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 ba724edb9747..e93ca9e0bd72 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
@@ -1969,32 +1969,32 @@ public class StageCoordinator implements SplitLayout.SplitLayoutHandler,
}
}
- int currentSnapPosition = mSplitLayout.calculateCurrentSnapPosition();
-
- if (Flags.enableFlexibleTwoAppSplit()) {
- // Split screen can be laid out in such a way that some of the apps are offscreen.
- // For the purposes of passing SplitBounds up to launcher (for use in thumbnails
- // etc.), we crop the bounds down to the screen size.
- topLeftBounds.left =
- Math.max(topLeftBounds.left, 0);
- topLeftBounds.top =
- Math.max(topLeftBounds.top, 0);
- bottomRightBounds.right =
- Math.min(bottomRightBounds.right, mSplitLayout.getDisplayWidth());
- bottomRightBounds.top =
- Math.min(bottomRightBounds.top, mSplitLayout.getDisplayHeight());
-
- // TODO (b/349828130): Can change to getState() fully after brief soak time.
- if (mSplitState.get() != currentSnapPosition) {
- Log.wtf(TAG, "SplitState is " + mSplitState.get()
- + ", expected " + currentSnapPosition);
- currentSnapPosition = mSplitState.get();
+ // If all stages are filled, create new SplitBounds and update Recents.
+ if (mainStageTopTaskId != INVALID_TASK_ID && sideStageTopTaskId != INVALID_TASK_ID) {
+ int currentSnapPosition = mSplitLayout.calculateCurrentSnapPosition();
+ if (Flags.enableFlexibleTwoAppSplit()) {
+ // Split screen can be laid out in such a way that some of the apps are
+ // offscreen. For the purposes of passing SplitBounds up to launcher (for use in
+ // thumbnails etc.), we crop the bounds down to the screen size.
+ topLeftBounds.left =
+ Math.max(topLeftBounds.left, 0);
+ topLeftBounds.top =
+ Math.max(topLeftBounds.top, 0);
+ bottomRightBounds.right =
+ Math.min(bottomRightBounds.right, mSplitLayout.getDisplayWidth());
+ bottomRightBounds.top =
+ Math.min(bottomRightBounds.top, mSplitLayout.getDisplayHeight());
+
+ // TODO (b/349828130): Can change to getState() fully after brief soak time.
+ if (mSplitState.get() != currentSnapPosition) {
+ Log.wtf(TAG, "SplitState is " + mSplitState.get()
+ + ", expected " + currentSnapPosition);
+ currentSnapPosition = mSplitState.get();
+ }
}
- }
+ SplitBounds splitBounds = new SplitBounds(topLeftBounds, bottomRightBounds,
+ leftTopTaskId, rightBottomTaskId, currentSnapPosition);
- SplitBounds splitBounds = new SplitBounds(topLeftBounds, bottomRightBounds,
- leftTopTaskId, rightBottomTaskId, currentSnapPosition);
- if (mainStageTopTaskId != INVALID_TASK_ID && sideStageTopTaskId != INVALID_TASK_ID) {
// Update the pair for the top tasks
boolean added = recentTasks.addSplitPair(mainStageTopTaskId, sideStageTopTaskId,
splitBounds);
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedTransition.java b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedTransition.java
index 03ded730865e..b0547a2a47b1 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedTransition.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/transition/DefaultMixedTransition.java
@@ -204,6 +204,7 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
ProtoLog.v(ShellProtoLogGroup.WM_SHELL_TRANSITIONS,
"tryAnimateOpenIntentWithRemoteAndPipOrDesktop");
TransitionInfo.Change pipChange = null;
+ TransitionInfo.Change pipActivityChange = null;
for (int i = info.getChanges().size() - 1; i >= 0; --i) {
TransitionInfo.Change change = info.getChanges().get(i);
if (mPipHandler.isEnteringPip(change, info.getType())) {
@@ -213,6 +214,12 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
}
pipChange = change;
info.getChanges().remove(i);
+ } else if (change.getTaskInfo() == null && change.getParent() != null
+ && pipChange != null && change.getParent().equals(pipChange.getContainer())) {
+ // Cache the PiP activity if it's a target and cached pip task change is its parent;
+ // note that we are bottom-to-top, so if such activity has a task
+ // that is also a target, then it must have been cached already as pipChange.
+ pipActivityChange = change;
}
}
TransitionInfo.Change desktopChange = null;
@@ -257,8 +264,16 @@ class DefaultMixedTransition extends DefaultMixedHandler.MixedTransition {
// make a new startTransaction because pip's startEnterAnimation "consumes" it so
// we need a separate one to send over to launcher.
SurfaceControl.Transaction otherStartT = new SurfaceControl.Transaction();
-
- mPipHandler.startEnterAnimation(pipChange, otherStartT, finishTransaction, finishCB);
+ if (pipActivityChange == null) {
+ mPipHandler.startEnterAnimation(pipChange, otherStartT, finishTransaction,
+ finishCB);
+ } else {
+ info.getChanges().remove(pipActivityChange);
+ TransitionInfo pipInfo = subCopy(info, TRANSIT_PIP, false /* withChanges */);
+ pipInfo.getChanges().addAll(List.of(pipChange, pipActivityChange));
+ mPipHandler.startAnimation(mTransition, pipInfo, startTransaction,
+ finishTransaction, finishCB);
+ }
// Dispatch the rest of the transition normally.
if (mLeftoversHandler != null
diff --git a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java
index 4f211c852697..01319fb8c713 100644
--- a/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java
+++ b/libs/WindowManager/Shell/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecoration.java
@@ -557,10 +557,10 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
@Nullable
private Intent getBrowserLink() {
final Uri browserLink;
- if (isCapturedLinkAvailable()) {
- browserLink = mCapturedLink.mUri;
- } else if (mWebUri != null) {
+ if (mWebUri != null) {
browserLink = mWebUri;
+ } else if (isCapturedLinkAvailable()) {
+ browserLink = mCapturedLink.mUri;
} else {
browserLink = mGenericLink;
}
@@ -1317,7 +1317,7 @@ public class DesktopModeWindowDecoration extends WindowDecoration<WindowDecorLin
*/
@VisibleForTesting
void onAssistContentReceived(@Nullable AssistContent assistContent) {
- mWebUri = assistContent == null ? null : assistContent.getWebUri();
+ mWebUri = assistContent == null ? null : AppToWebUtils.getSessionWebUri(assistContent);
loadAppInfoIfNeeded();
updateGenericLink();
final boolean supportsMultiInstance = mMultiInstanceHelper
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 a2afd2c92d3d..47ee7bb20199 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
@@ -718,7 +718,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
tInfo = createTransitionInfo(TRANSIT_PREPARE_BACK_NAVIGATION, open);
callback = mock(Transitions.TransitionFinishCallback.class);
mBackTransitionHandler.startAnimation(mockBinder, tInfo, st, ft, callback);
- verify(mBackTransitionHandler).handlePrepareTransition(
+ verify(mBackTransitionHandler).handlePrepareTransition(eq(mockBinder),
eq(tInfo), eq(st), eq(ft), eq(callback));
mBackTransitionHandler.mCloseTransitionRequested = true;
TransitionInfo tInfo2 = createTransitionInfo(TRANSIT_CLOSE, close);
@@ -750,7 +750,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
null /* remoteTransition */);
mBackTransitionHandler.handleRequest(mockBinder, requestInfo);
mBackTransitionHandler.startAnimation(mockBinder, tInfo, st, ft, callback);
- verify(mBackTransitionHandler).handlePrepareTransition(
+ verify(mBackTransitionHandler).handlePrepareTransition(eq(mockBinder),
eq(tInfo), eq(st), eq(ft), eq(callback));
mBackTransitionHandler.onAnimationFinished();
@@ -801,7 +801,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
canHandle = mBackTransitionHandler.startAnimation(mockBinder,
prepareInfo, st, ft, callback2);
assertTrue("Handle prepare transition" , canHandle);
- verify(mBackTransitionHandler).handlePrepareTransition(
+ verify(mBackTransitionHandler).handlePrepareTransition(eq(mockBinder),
eq(prepareInfo), eq(st), eq(ft), eq(callback2));
final TransitionInfo closeInfo = createTransitionInfo(TRANSIT_CLOSE, close);
Transitions.TransitionFinishCallback mergeCallback =
@@ -819,7 +819,7 @@ public class BackAnimationControllerTest extends ShellTestCase {
canHandle = mBackTransitionHandler.startAnimation(
mockBinder, prepareInfo, st, ft, callback3);
assertTrue("Handle prepare transition" , canHandle);
- verify(mBackTransitionHandler).handlePrepareTransition(
+ verify(mBackTransitionHandler).handlePrepareTransition(eq(mockBinder),
eq(prepareInfo), eq(st), eq(ft), eq(callback3));
final TransitionInfo.Change open2 = createAppChange(
openTaskId2, TRANSIT_OPEN, FLAG_MOVED_TO_TOP);
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopActivityOrientationChangeHandlerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopActivityOrientationChangeHandlerTest.kt
index 41a594a3347a..4cc641cd1d81 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopActivityOrientationChangeHandlerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopActivityOrientationChangeHandlerTest.kt
@@ -36,6 +36,7 @@ import com.android.dx.mockito.inline.extended.ExtendedMockito.never
import com.android.dx.mockito.inline.extended.StaticMockitoSession
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_MODE
import com.android.window.flags.Flags.FLAG_RESPECT_ORIENTATION_CHANGE_FOR_UNRESIZEABLE
+import com.android.wm.shell.sysui.ShellController
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.ShellTestCase
import com.android.wm.shell.common.ShellExecutor
@@ -98,6 +99,7 @@ class DesktopActivityOrientationChangeHandlerTest : ShellTestCase() {
@Mock lateinit var persistentRepository: DesktopPersistentRepository
@Mock lateinit var repositoryInitializer: DesktopRepositoryInitializer
@Mock lateinit var userManager: UserManager
+ @Mock lateinit var shellController: ShellController
private lateinit var mockitoSession: StaticMockitoSession
private lateinit var handler: DesktopActivityOrientationChangeHandler
@@ -123,6 +125,7 @@ class DesktopActivityOrientationChangeHandlerTest : ShellTestCase() {
DesktopUserRepositories(
context,
shellInit,
+ shellController,
persistentRepository,
repositoryInitializer,
testScope,
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopImmersiveControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopImmersiveControllerTest.kt
index 447da8799e35..b87f20023796 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopImmersiveControllerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopImmersiveControllerTest.kt
@@ -89,7 +89,7 @@ class DesktopImmersiveControllerTest : ShellTestCase() {
@Before
fun setUp() {
userRepositories = DesktopUserRepositories(
- context, ShellInit(TestShellExecutor()), mock(), mock(), mock(), mock()
+ context, ShellInit(TestShellExecutor()), mock(), mock(), mock(), mock(), mock()
)
whenever(mockDisplayController.getDisplayLayout(DEFAULT_DISPLAY))
.thenReturn(mockDisplayLayout)
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
index 33c14516d48c..cf16e42a729b 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksControllerTest.kt
@@ -276,6 +276,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
DesktopUserRepositories(
context,
shellInit,
+ shellController,
persistentRepository,
repositoryInitializer,
testScope,
@@ -3907,7 +3908,7 @@ class DesktopTasksControllerTest : ShellTestCase() {
@Test
fun shellController_registersUserChangeListener() {
- verify(shellController, times(1)).addUserChangeListener(any())
+ verify(shellController, times(2)).addUserChangeListener(any())
}
@Test
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksLimiterTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksLimiterTest.kt
index 0712d58166bb..39178cb2cd25 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksLimiterTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopTasksLimiterTest.kt
@@ -42,6 +42,7 @@ import com.android.internal.jank.InteractionJankMonitor
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_BACK_NAVIGATION
import com.android.wm.shell.ShellTaskOrganizer
import com.android.wm.shell.ShellTestCase
+import com.android.wm.shell.sysui.ShellController
import com.android.wm.shell.common.ShellExecutor
import com.android.wm.shell.desktopmode.DesktopTestHelpers.createFreeformTask
import com.android.wm.shell.desktopmode.persistence.DesktopPersistentRepository
@@ -96,6 +97,7 @@ class DesktopTasksLimiterTest : ShellTestCase() {
@Mock lateinit var persistentRepository: DesktopPersistentRepository
@Mock lateinit var repositoryInitializer: DesktopRepositoryInitializer
@Mock lateinit var userManager: UserManager
+ @Mock lateinit var shellController: ShellController
private lateinit var mockitoSession: StaticMockitoSession
private lateinit var desktopTasksLimiter: DesktopTasksLimiter
@@ -117,6 +119,7 @@ class DesktopTasksLimiterTest : ShellTestCase() {
DesktopUserRepositories(
context,
shellInit,
+ shellController,
persistentRepository,
repositoryInitializer,
testScope,
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopUserRepositoriesTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopUserRepositoriesTest.kt
index 5767df4c5a8e..a2e939d86adb 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopUserRepositoriesTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/DesktopUserRepositoriesTest.kt
@@ -24,14 +24,15 @@ import android.platform.test.annotations.EnableFlags
import android.platform.test.flag.junit.SetFlagsRule
import android.testing.AndroidTestingRunner
import androidx.test.filters.SmallTest
-import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
import com.android.dx.mockito.inline.extended.ExtendedMockito.doReturn
+import com.android.dx.mockito.inline.extended.ExtendedMockito.mockitoSession
import com.android.dx.mockito.inline.extended.StaticMockitoSession
import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_HSUM
import com.android.wm.shell.ShellTestCase
import com.android.wm.shell.common.ShellExecutor
import com.android.wm.shell.desktopmode.persistence.DesktopPersistentRepository
import com.android.wm.shell.desktopmode.persistence.DesktopRepositoryInitializer
+import com.android.wm.shell.sysui.ShellController
import com.android.wm.shell.sysui.ShellInit
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CoroutineScope
@@ -66,6 +67,7 @@ class DesktopUserRepositoriesTest : ShellTestCase() {
private val persistentRepository = mock<DesktopPersistentRepository>()
private val repositoryInitializer = mock<DesktopRepositoryInitializer>()
private val userManager = mock<UserManager>()
+ private val shellController = mock<ShellController>()
@Before
fun setUp() {
@@ -86,8 +88,14 @@ class DesktopUserRepositoriesTest : ShellTestCase() {
whenever(userManager.getProfiles(USER_ID_1)).thenReturn(profiles)
userRepositories = DesktopUserRepositories(
- context, shellInit, persistentRepository, repositoryInitializer, datastoreScope,
- userManager)
+ context,
+ shellInit,
+ shellController,
+ persistentRepository,
+ repositoryInitializer,
+ datastoreScope,
+ userManager
+ )
}
@After
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/persistence/DesktopRepositoryInitializerTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/persistence/DesktopRepositoryInitializerTest.kt
index 1c88a290d677..cdf064b075a1 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/persistence/DesktopRepositoryInitializerTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/desktopmode/persistence/DesktopRepositoryInitializerTest.kt
@@ -27,6 +27,7 @@ import com.android.window.flags.Flags.FLAG_ENABLE_DESKTOP_WINDOWING_PERSISTENCE
import com.android.wm.shell.ShellTestCase
import com.android.wm.shell.common.ShellExecutor
import com.android.wm.shell.desktopmode.DesktopUserRepositories
+import com.android.wm.shell.sysui.ShellController
import com.android.wm.shell.sysui.ShellInit
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CoroutineScope
@@ -64,6 +65,7 @@ class DesktopRepositoryInitializerTest : ShellTestCase() {
private val persistentRepository = mock<DesktopPersistentRepository>()
private val userManager = mock<UserManager>()
private val testExecutor = mock<ShellExecutor>()
+ private val shellController = mock<ShellController>()
@Before
fun setUp() {
@@ -74,7 +76,12 @@ class DesktopRepositoryInitializerTest : ShellTestCase() {
DesktopRepositoryInitializerImpl(context, persistentRepository, datastoreScope)
desktopUserRepositories =
DesktopUserRepositories(
- context, shellInit, persistentRepository, repositoryInitializer, datastoreScope,
+ context,
+ shellInit,
+ shellController,
+ persistentRepository,
+ repositoryInitializer,
+ datastoreScope,
userManager
)
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopHeaderManageWindowsMenuTest.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopHeaderManageWindowsMenuTest.kt
index e871711fd25e..cf6c3a5e03a0 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopHeaderManageWindowsMenuTest.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopHeaderManageWindowsMenuTest.kt
@@ -63,6 +63,7 @@ class DesktopHeaderManageWindowsMenuTest : ShellTestCase() {
userRepositories = DesktopUserRepositories(
context = context,
shellInit = ShellInit(TestShellExecutor()),
+ shellController = mock(),
persistentRepository = mock(),
repositoryInitializer = mock(),
mainCoroutineScope = mock(),
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 2ffdcf8d094d..0214da4660ad 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
@@ -388,7 +388,7 @@ class DesktopModeWindowDecorViewModelTests : DesktopModeWindowDecorViewModelTest
}
@Test
- fun testOnDecorMaximizedOrRestored_togglesTaskSize() {
+ fun testOnDecorMaximizedOrRestored_togglesTaskSize_maximize() {
val maxOrRestoreListenerCaptor = forClass(Function0::class.java)
as ArgumentCaptor<Function0<Unit>>
val decor = createOpenTaskDecoration(
@@ -409,6 +409,52 @@ class DesktopModeWindowDecorViewModelTests : DesktopModeWindowDecorViewModelTest
}
@Test
+ fun testOnDecorMaximizedOrRestored_togglesTaskSize_maximizeFromMaximizedSize() {
+ val maxOrRestoreListenerCaptor = forClass(Function0::class.java)
+ as ArgumentCaptor<Function0<Unit>>
+ val decor = createOpenTaskDecoration(
+ windowingMode = WINDOWING_MODE_FREEFORM,
+ onMaxOrRestoreListenerCaptor = maxOrRestoreListenerCaptor
+ )
+ val movedMaximizedBounds = Rect(STABLE_BOUNDS)
+ movedMaximizedBounds.offset(10, 10)
+ decor.mTaskInfo.configuration.windowConfiguration.bounds.set(movedMaximizedBounds)
+
+ maxOrRestoreListenerCaptor.value.invoke()
+
+ verify(mockDesktopTasksController).toggleDesktopTaskSize(
+ decor.mTaskInfo,
+ ToggleTaskSizeInteraction(
+ ToggleTaskSizeInteraction.Direction.MAXIMIZE,
+ ToggleTaskSizeInteraction.Source.MAXIMIZE_MENU_TO_MAXIMIZE,
+ InputMethod.UNKNOWN_INPUT_METHOD
+ )
+ )
+ }
+
+ @Test
+ fun testOnDecorMaximizedOrRestored_togglesTaskSize_restore() {
+ val maxOrRestoreListenerCaptor = forClass(Function0::class.java)
+ as ArgumentCaptor<Function0<Unit>>
+ val decor = createOpenTaskDecoration(
+ windowingMode = WINDOWING_MODE_FREEFORM,
+ onMaxOrRestoreListenerCaptor = maxOrRestoreListenerCaptor
+ )
+ decor.mTaskInfo.configuration.windowConfiguration.bounds.set(STABLE_BOUNDS)
+
+ maxOrRestoreListenerCaptor.value.invoke()
+
+ verify(mockDesktopTasksController).toggleDesktopTaskSize(
+ decor.mTaskInfo,
+ ToggleTaskSizeInteraction(
+ ToggleTaskSizeInteraction.Direction.RESTORE,
+ ToggleTaskSizeInteraction.Source.MAXIMIZE_MENU_TO_RESTORE,
+ InputMethod.UNKNOWN_INPUT_METHOD
+ )
+ )
+ }
+
+ @Test
fun testOnDecorMaximizedOrRestored_closesMenus() {
val maxOrRestoreListenerCaptor = forClass(Function0::class.java)
as ArgumentCaptor<Function0<Unit>>
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTestsBase.kt b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTestsBase.kt
index 6be234ef5ca6..7a37c5eec604 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTestsBase.kt
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorViewModelTestsBase.kt
@@ -149,7 +149,6 @@ open class DesktopModeWindowDecorViewModelTestsBase : ShellTestCase() {
protected val mockCaptionHandleRepository = mock<WindowDecorCaptionHandleRepository>()
protected val mockDesktopRepository: DesktopRepository = mock<DesktopRepository>()
protected val motionEvent = mock<MotionEvent>()
- val displayController = mock<DisplayController>()
val displayLayout = mock<DisplayLayout>()
protected lateinit var spyContext: TestableContext
private lateinit var desktopModeEventLogger: DesktopModeEventLogger
@@ -255,7 +254,7 @@ open class DesktopModeWindowDecorViewModelTestsBase : ShellTestCase() {
argumentCaptor<DesktopModeKeyguardChangeListener>()
verify(mockShellController).addKeyguardChangeListener(keyguardChangedCaptor.capture())
desktopModeOnKeyguardChangedListener = keyguardChangedCaptor.firstValue
- whenever(displayController.getDisplayLayout(anyInt())).thenReturn(displayLayout)
+ whenever(mockDisplayController.getDisplayLayout(anyInt())).thenReturn(displayLayout)
whenever(displayLayout.getStableBounds(any())).thenAnswer { i ->
(i.arguments.first() as Rect).set(STABLE_BOUNDS)
}
diff --git a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java
index 5d5d1f220ae0..db7b1f22768f 100644
--- a/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java
+++ b/libs/WindowManager/Shell/tests/unittest/src/com/android/wm/shell/windowdecor/DesktopModeWindowDecorationTests.java
@@ -20,6 +20,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_MULTI_WINDOW;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
+import static android.app.assist.AssistContent.EXTRA_SESSION_TRANSFER_WEB_URI;
import static android.platform.test.flag.junit.SetFlagsRule.DefaultInitValueType.DEVICE_DEFAULT;
import static android.view.InsetsSource.FLAG_FORCE_CONSUMING;
import static android.view.InsetsSource.FLAG_FORCE_CONSUMING_OPAQUE_CAPTION_BAR;
@@ -157,6 +158,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
private static final Uri TEST_URI1 = Uri.parse("https://www.google.com/");
private static final Uri TEST_URI2 = Uri.parse("https://docs.google.com/");
private static final Uri TEST_URI3 = Uri.parse("https://slides.google.com/");
+ private static final Uri TEST_URI4 = Uri.parse("https://calendar.google.com/");
@Rule public final SetFlagsRule mSetFlagsRule = new SetFlagsRule(DEVICE_DEFAULT);
@@ -1322,11 +1324,11 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
@Test
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB)
- public void capturedLink_handleMenuBrowserLinkSetToCapturedLinkIfValid() {
+ public void capturedLink_CapturedLinkUsedIfValidAndWebUriUnavailable() {
final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(true /* visible */);
final DesktopModeWindowDecoration decor = createWindowDecoration(
- taskInfo, TEST_URI1 /* captured link */, TEST_URI2 /* web uri */,
- TEST_URI3 /* generic link */);
+ taskInfo, TEST_URI1 /* captured link */, null /* web uri */,
+ null /* session transfer uri */, TEST_URI4 /* generic link */);
// Verify handle menu's browser link set as captured link
createHandleMenu(decor);
@@ -1339,7 +1341,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(true /* visible */);
final DesktopModeWindowDecoration decor = createWindowDecoration(
taskInfo, TEST_URI1 /* captured link */, null /* web uri */,
- null /* generic link */);
+ null /* session transfer uri */, null /* generic link */);
final ArgumentCaptor<Function1<Intent, Unit>> openInBrowserCaptor =
ArgumentCaptor.forClass(Function1.class);
@@ -1373,7 +1375,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(true /* visible */);
final DesktopModeWindowDecoration decor = createWindowDecoration(
taskInfo, TEST_URI1 /* captured link */, null /* web uri */,
- null /* generic link */);
+ null /* session transfer uri */, null /* generic link */);
final ArgumentCaptor<Function1<Intent, Unit>> openInBrowserCaptor =
ArgumentCaptor.forClass(Function1.class);
@@ -1406,7 +1408,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(true /* visible */);
final DesktopModeWindowDecoration decor = createWindowDecoration(
taskInfo, TEST_URI1 /* captured link */, null /* web uri */,
- null /* generic link */);
+ null /* session transfer uri */, null /* generic link */);
final ArgumentCaptor<Function1<Intent, Unit>> openInBrowserCaptor =
ArgumentCaptor.forClass(Function1.class);
createHandleMenu(decor);
@@ -1432,11 +1434,23 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
@Test
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB)
- public void webUriLink_webUriLinkUsedWhenCapturedLinkUnavailable() {
+ public void webUriLink_webUriLinkUsedWhenWhenAvailable() {
final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(true /* visible */);
final DesktopModeWindowDecoration decor = createWindowDecoration(
- taskInfo, null /* captured link */, TEST_URI2 /* web uri */,
- TEST_URI3 /* generic link */);
+ taskInfo, TEST_URI1 /* captured link */, TEST_URI2 /* web uri */,
+ TEST_URI3 /* session transfer uri */, TEST_URI4 /* generic link */);
+ // Verify handle menu's browser link set as web uri link when captured link is unavailable
+ createHandleMenu(decor);
+ verifyHandleMenuCreated(TEST_URI3);
+ }
+
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB)
+ public void webUriLink_webUriLinkUsedWhenSessionTransferUriUnavailable() {
+ final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(true /* visible */);
+ final DesktopModeWindowDecoration decor = createWindowDecoration(
+ taskInfo, TEST_URI1 /* captured link */, TEST_URI2 /* web uri */,
+ null /* session transfer uri */, TEST_URI4 /* generic link */);
// Verify handle menu's browser link set as web uri link when captured link is unavailable
createHandleMenu(decor);
verifyHandleMenuCreated(TEST_URI2);
@@ -1448,12 +1462,12 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(true /* visible */);
final DesktopModeWindowDecoration decor = createWindowDecoration(
taskInfo, null /* captured link */, null /* web uri */,
- TEST_URI3 /* generic link */);
+ null /* session transfer uri */, TEST_URI4 /* generic link */);
// Verify handle menu's browser link set as generic link when captured link and web uri link
// are unavailable
createHandleMenu(decor);
- verifyHandleMenuCreated(TEST_URI3);
+ verifyHandleMenuCreated(TEST_URI4);
}
@Test
@@ -1637,7 +1651,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
@Test
@EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB)
- public void browserApp_webUriUsedForBrowserApp() {
+ public void browserApp_transferSessionUriUsedForBrowserAppWhenAvailable() {
// Make {@link AppToWebUtils#isBrowserApp} return true
ResolveInfo resolveInfo = new ResolveInfo();
resolveInfo.handleAllWebDataURI = true;
@@ -1648,7 +1662,7 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(true /* visible */);
final DesktopModeWindowDecoration decor = createWindowDecoration(
taskInfo, TEST_URI1 /* captured link */, TEST_URI2 /* web uri */,
- TEST_URI3 /* generic link */);
+ null /* transfer session uri */, TEST_URI4 /* generic link */);
// Verify web uri used for browser applications
createHandleMenu(decor);
@@ -1656,6 +1670,27 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
}
+ @Test
+ @EnableFlags(Flags.FLAG_ENABLE_DESKTOP_WINDOWING_APP_TO_WEB)
+ public void browserApp_webUriUsedForBrowserAppWhenTransferSessionUriUnavailable() {
+ // Make {@link AppToWebUtils#isBrowserApp} return true
+ ResolveInfo resolveInfo = new ResolveInfo();
+ resolveInfo.handleAllWebDataURI = true;
+ resolveInfo.activityInfo = createActivityInfo();
+ when(mMockPackageManager.queryIntentActivitiesAsUser(any(), anyInt(), anyInt()))
+ .thenReturn(List.of(resolveInfo));
+
+ final ActivityManager.RunningTaskInfo taskInfo = createTaskInfo(true /* visible */);
+ final DesktopModeWindowDecoration decor = createWindowDecoration(
+ taskInfo, TEST_URI1 /* captured link */, TEST_URI2 /* web uri */,
+ TEST_URI3 /* transfer session uri */, TEST_URI4 /* generic link */);
+
+ // Verify web uri used for browser applications
+ createHandleMenu(decor);
+ verifyHandleMenuCreated(TEST_URI3);
+ }
+
+
private void verifyHandleMenuCreated(@Nullable Uri uri) {
verify(mMockHandleMenuFactory).create(any(), any(), anyInt(), any(), any(),
any(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(), anyBoolean(),
@@ -1692,10 +1727,11 @@ public class DesktopModeWindowDecorationTests extends ShellTestCase {
private DesktopModeWindowDecoration createWindowDecoration(
ActivityManager.RunningTaskInfo taskInfo, @Nullable Uri capturedLink,
- @Nullable Uri webUri, @Nullable Uri genericLink) {
+ @Nullable Uri webUri, @Nullable Uri sessionTransferUri, @Nullable Uri genericLink) {
taskInfo.capturedLink = capturedLink;
taskInfo.capturedLinkTimestamp = System.currentTimeMillis();
mAssistContent.setWebUri(webUri);
+ mAssistContent.getExtras().putObject(EXTRA_SESSION_TRANSFER_WEB_URI, sessionTransferUri);
final String genericLinkString = genericLink == null ? null : genericLink.toString();
doReturn(genericLinkString).when(mMockGenericLinksParser).getGenericLink(any());
// Relayout to set captured link
diff --git a/packages/SettingsLib/ActionButtonsPreference/res/values-v35/styles_expressive.xml b/packages/SettingsLib/ActionButtonsPreference/res/values-v35/styles_expressive.xml
index cc948a670382..fd8cecb8536e 100644
--- a/packages/SettingsLib/ActionButtonsPreference/res/values-v35/styles_expressive.xml
+++ b/packages/SettingsLib/ActionButtonsPreference/res/values-v35/styles_expressive.xml
@@ -22,12 +22,13 @@
<item name="iconGravity">textTop</item>
</style>
- <style name="SettingsLibActionButton.Expressive.Label" parent="SettingsLibTextAppearance.Emphasized.Title.Small">
+ <style name="SettingsLibActionButton.Expressive.Label" parent="">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
<item name="android:minWidth">@dimen/settingslib_expressive_space_small3</item>
<item name="android:minHeight">@dimen/settingslib_expressive_space_small3</item>
- <item name="android:textColor">@color/settingslib_materialColorOnSurface</item>
+ <item name="android:textAppearance">@style/TextAppearance.SettingsLib.TitleSmall.Emphasized</item>
+ <item name="android:textColor">@color/settingslib_text_color_primary</item>
<item name="android:layout_gravity">center</item>
</style>
diff --git a/packages/SettingsLib/CardPreference/res/layout/settingslib_expressive_preference_card.xml b/packages/SettingsLib/CardPreference/res/layout/settingslib_expressive_preference_card.xml
index 716ed412eb5c..9018baca79e7 100644
--- a/packages/SettingsLib/CardPreference/res/layout/settingslib_expressive_preference_card.xml
+++ b/packages/SettingsLib/CardPreference/res/layout/settingslib_expressive_preference_card.xml
@@ -40,7 +40,6 @@
<ImageView
android:id="@android:id/icon"
- android:src="@drawable/settingslib_arrow_drop_down"
android:layout_width="@dimen/settingslib_expressive_space_medium3"
android:layout_height="@dimen/settingslib_expressive_space_medium3"
android:scaleType="centerInside"/>
@@ -60,16 +59,12 @@
android:id="@android:id/title"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hyphenationFrequency="normalFast"
- android:lineBreakWordStyle="phrase"
android:textAppearance="@style/TextAppearance.CardTitle.SettingsLib"/>
<TextView
android:id="@android:id/summary"
android:layout_width="match_parent"
android:layout_height="wrap_content"
- android:hyphenationFrequency="normalFast"
- android:lineBreakWordStyle="phrase"
android:textAppearance="@style/TextAppearance.CardSummary.SettingsLib"/>
</LinearLayout>
diff --git a/packages/SettingsLib/CardPreference/res/values/styles_expressive.xml b/packages/SettingsLib/CardPreference/res/values/styles_expressive.xml
index 4cbdea52d439..287b13fa0d50 100644
--- a/packages/SettingsLib/CardPreference/res/values/styles_expressive.xml
+++ b/packages/SettingsLib/CardPreference/res/values/styles_expressive.xml
@@ -17,14 +17,12 @@
<resources>
<style name="TextAppearance.CardTitle.SettingsLib"
- parent="@style/TextAppearance.PreferenceTitle.SettingsLib">
+ parent="@style/TextAppearance.SettingsLib.TitleMedium.Emphasized">
<item name="android:textColor">@color/settingslib_materialColorOnPrimary</item>
- <item name="android:textSize">20sp</item>
</style>
<style name="TextAppearance.CardSummary.SettingsLib"
- parent="@style/TextAppearance.PreferenceSummary.SettingsLib">
+ parent="@style/TextAppearance.SettingsLib.LabelMedium">
<item name="android:textColor">@color/settingslib_materialColorOnSecondary</item>
- <item name="android:textSize">14sp</item>
</style>
</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/drawable-v35/settingslib_expressive_icon_back.xml b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/drawable-v35/settingslib_expressive_icon_back.xml
index ccbe20e1c61f..9986a60250fe 100644
--- a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/drawable-v35/settingslib_expressive_icon_back.xml
+++ b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/drawable-v35/settingslib_expressive_icon_back.xml
@@ -17,12 +17,9 @@
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item
- android:start="16dp"
- android:end="16dp"
- android:top="4dp"
- android:bottom="4dp">
+ android:start="16dp">
<shape>
- <size android:width="32dp" android:height="40dp" />
+ <size android:width="40dp" android:height="40dp" />
<solid android:color="@color/settingslib_materialColorSurfaceContainerHighest" />
<corners
android:radius="100dp" />
@@ -30,23 +27,21 @@
</item>
<item
- android:width="24dp"
- android:height="24dp"
+ android:width="16dp"
+ android:height="16dp"
android:gravity="center"
android:start="16dp"
- android:end="16dp"
- android:top="4dp"
- android:bottom="4dp">
+>
<vector
- android:width="24dp"
- android:height="24dp"
- android:viewportWidth="960"
- android:viewportHeight="960"
+ android:width="16dp"
+ android:height="16dp"
+ android:viewportWidth="16"
+ android:viewportHeight="16"
android:tint="@color/settingslib_materialColorOnSurfaceVariant"
android:autoMirrored="true">
<path
android:fillColor="@android:color/white"
- android:pathData="M313,520L537,744L480,800L160,480L480,160L537,216L313,440L800,440L800,520L313,520Z"/>
+ android:pathData="M3.626,9L8.526,13.9C8.726,14.1 8.817,14.333 8.801,14.6C8.801,14.867 8.701,15.1 8.501,15.3C8.301,15.483 8.067,15.583 7.801,15.6C7.534,15.6 7.301,15.5 7.101,15.3L0.501,8.7C0.401,8.6 0.326,8.492 0.276,8.375C0.242,8.258 0.226,8.133 0.226,8C0.226,7.867 0.242,7.742 0.276,7.625C0.326,7.508 0.401,7.4 0.501,7.3L7.101,0.7C7.284,0.517 7.509,0.425 7.776,0.425C8.059,0.425 8.301,0.517 8.501,0.7C8.701,0.9 8.801,1.142 8.801,1.425C8.801,1.692 8.701,1.925 8.501,2.125L3.626,7H14.801C15.084,7 15.317,7.1 15.501,7.3C15.701,7.483 15.801,7.717 15.801,8C15.801,8.283 15.701,8.525 15.501,8.725C15.317,8.908 15.084,9 14.801,9H3.626Z"/>
</vector>
</item>
</layer-list> \ No newline at end of file
diff --git a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-night-v35/themes.xml b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-night-v35/themes.xml
index e68253e2200d..fadcf7ba8699 100644
--- a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-night-v35/themes.xml
+++ b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-night-v35/themes.xml
@@ -18,7 +18,7 @@
<style name="Theme.CollapsingToolbar.Settings" parent="@style/Theme.MaterialComponents.DayNight">
<item name="elevationOverlayEnabled">true</item>
<item name="elevationOverlayColor">?attr/colorPrimary</item>
- <item name="colorPrimary">@color/settingslib_materialColorInverseOnSurface</item>
+ <item name="colorPrimary">@color/settingslib_materialColorOnSurfaceInverse</item>
<item name="colorAccent">@color/settingslib_materialColorPrimaryFixed</item>
</style>
</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v35/styles_expressive.xml b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v35/styles_expressive.xml
index d58c2c2eeb23..37a78101cc4e 100644
--- a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v35/styles_expressive.xml
+++ b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v35/styles_expressive.xml
@@ -33,12 +33,12 @@
<item name="contentScrim">@color/settingslib_materialColorSurfaceContainer</item>
</style>
- <style name="SettingsLibCollapsingToolbarTitle.Collapsed" parent="@android:style/TextAppearance.DeviceDefault.Headline">
+ <style name="SettingsLibCollapsingToolbarTitle.Collapsed" parent="@style/TextAppearance.SettingsLib.TitleLarge.Emphasized">
<!--set dp because we don't want size adjust when font size change-->
- <item name="android:textSize">20dp</item>
+ <item name="android:textSize">22dp</item>
</style>
- <style name="SettingsLibCollapsingToolbarTitle.Expanded" parent="CollapsingToolbarTitle.Collapsed">
+ <style name="SettingsLibCollapsingToolbarTitle.Expanded" parent="@style/TextAppearance.SettingsLib.DisplaySmall.Emphasized">
<item name="android:textSize">36dp</item>
</style>
</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v35/themes.xml b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v35/themes.xml
index f7c9aac68629..7c9d1a47b7ef 100644
--- a/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v35/themes.xml
+++ b/packages/SettingsLib/CollapsingToolbarBaseActivity/res/values-v35/themes.xml
@@ -18,7 +18,7 @@
<style name="Theme.CollapsingToolbar.Settings" parent="@style/Theme.MaterialComponents.DayNight">
<item name="elevationOverlayEnabled">true</item>
<item name="elevationOverlayColor">?attr/colorPrimary</item>
- <item name="colorPrimary">@color/settingslib_materialColorInverseOnSurface</item>
+ <item name="colorPrimary">@color/settingslib_materialColorOnSurfaceInverse</item>
<item name="colorAccent">@color/settingslib_materialColorPrimary</item>
</style>
</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/IntroPreference/res/layout/settingslib_expressive_preference_intro.xml b/packages/SettingsLib/IntroPreference/res/layout/settingslib_expressive_preference_intro.xml
index 2edc001ccc3f..43cf6aa09109 100644
--- a/packages/SettingsLib/IntroPreference/res/layout/settingslib_expressive_preference_intro.xml
+++ b/packages/SettingsLib/IntroPreference/res/layout/settingslib_expressive_preference_intro.xml
@@ -26,7 +26,6 @@
<ImageView
android:id="@android:id/icon"
- android:src="@drawable/settingslib_arrow_drop_down"
style="@style/SettingsLibEntityHeaderIcon"/>
<TextView
diff --git a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java
index 106802e9d1d1..73728bcd1ff7 100644
--- a/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java
+++ b/packages/SettingsLib/MainSwitchPreference/src/com/android/settingslib/widget/MainSwitchBar.java
@@ -32,6 +32,7 @@ import android.widget.LinearLayout;
import android.widget.TextView;
import androidx.annotation.ColorInt;
+import androidx.annotation.Nullable;
import androidx.annotation.RequiresApi;
import com.android.settingslib.widget.mainswitch.R;
@@ -42,7 +43,7 @@ import java.util.List;
/**
* MainSwitchBar is a View with a customized Switch.
* This component is used as the main switch of the page
- * to enable or disable the prefereces on the page.
+ * to enable or disable the preferences on the page.
*/
public class MainSwitchBar extends LinearLayout implements OnCheckedChangeListener {
@@ -58,6 +59,8 @@ public class MainSwitchBar extends LinearLayout implements OnCheckedChangeListen
protected CompoundButton mSwitch;
private final View mFrameView;
+ private @Nullable PreChangeListener mPreChangeListener;
+
public MainSwitchBar(Context context) {
this(context, null);
}
@@ -138,10 +141,20 @@ public class MainSwitchBar extends LinearLayout implements OnCheckedChangeListen
@Override
public boolean performClick() {
- mSwitch.performClick();
+ if (callPreChangeListener()) {
+ mSwitch.performClick();
+ }
return super.performClick();
}
+ protected boolean callPreChangeListener() {
+ return mPreChangeListener == null || mPreChangeListener.preChange(!mSwitch.isChecked());
+ }
+
+ public void setPreChangeListener(@Nullable PreChangeListener preChangeListener) {
+ mPreChangeListener = preChangeListener;
+ }
+
/**
* Update the switch status
*/
@@ -271,7 +284,7 @@ public class MainSwitchBar extends LinearLayout implements OnCheckedChangeListen
}
}
- static class SavedState extends BaseSavedState {
+ public static class SavedState extends BaseSavedState {
boolean mChecked;
boolean mVisible;
@@ -341,4 +354,16 @@ public class MainSwitchBar extends LinearLayout implements OnCheckedChangeListen
requestLayout();
}
+
+ /**
+ * Listener callback before switch is toggled.
+ */
+ public interface PreChangeListener {
+ /**
+ * Returns if the new value can be set.
+ *
+ * When false is return, the switch toggle is not triggered at all.
+ */
+ boolean preChange(boolean isCheck);
+ }
}
diff --git a/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceMetadata.kt b/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceMetadata.kt
index 6e86fa7312cf..c1edbdc20361 100644
--- a/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceMetadata.kt
+++ b/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceMetadata.kt
@@ -107,20 +107,11 @@ interface PreferenceMetadata {
*
* UI framework normally does not allow user to interact with the preference widget when it is
* disabled.
- *
- * [dependencyOfEnabledState] is provided to support dependency, the [shouldDisableDependents]
- * value of dependent preference is used to decide enabled state.
*/
- fun isEnabled(context: Context): Boolean {
- val dependency = dependencyOfEnabledState(context) ?: return true
- return !dependency.shouldDisableDependents(context)
- }
-
- /** Returns the key of depended preference to decide the enabled state. */
- fun dependencyOfEnabledState(context: Context): PreferenceMetadata? = null
+ fun isEnabled(context: Context): Boolean = true
- /** Returns whether this preference's dependents should be disabled. */
- fun shouldDisableDependents(context: Context): Boolean = !isEnabled(context)
+ /** Returns the keys of depended preferences. */
+ fun dependencies(context: Context): Array<String> = arrayOf()
/** Returns if the preference is persistent in datastore. */
fun isPersistent(context: Context): Boolean = this is PersistentPreference<*>
@@ -174,13 +165,11 @@ interface PreferenceMetadata {
}
/** Metadata of preference group. */
-@AnyThread
-interface PreferenceGroup : PreferenceMetadata
+@AnyThread interface PreferenceGroup : PreferenceMetadata
/** Metadata of preference category. */
@AnyThread
-open class PreferenceCategory(override val key: String, override val title: Int) :
- PreferenceGroup
+open class PreferenceCategory(override val key: String, override val title: Int) : PreferenceGroup
/** Metadata of preference screen. */
@AnyThread
diff --git a/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceTypes.kt b/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceTypes.kt
index 512ea3d874bb..87bd261bf4bd 100644
--- a/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceTypes.kt
+++ b/packages/SettingsLib/Metadata/src/com/android/settingslib/metadata/PreferenceTypes.kt
@@ -16,18 +16,10 @@
package com.android.settingslib.metadata
-import android.content.Context
import androidx.annotation.StringRes
-/**
- * Common base class for preferences that have two selectable states, save a boolean value, and may
- * have dependent preferences that are enabled/disabled based on the current state.
- */
-interface TwoStatePreference : PreferenceMetadata, PersistentPreference<Boolean>, BooleanValue {
-
- override fun shouldDisableDependents(context: Context) =
- storage(context).getBoolean(key) != true || super.shouldDisableDependents(context)
-}
+/** Common base class for preferences that have two selectable states and save a boolean value. */
+interface TwoStatePreference : PreferenceMetadata, PersistentPreference<Boolean>, BooleanValue
/** A preference that provides a two-state toggleable option. */
open class SwitchPreference
diff --git a/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceScreenBindingHelper.kt b/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceScreenBindingHelper.kt
index 31bb62d93d82..a9e20f284a61 100644
--- a/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceScreenBindingHelper.kt
+++ b/packages/SettingsLib/Preference/src/com/android/settingslib/preference/PreferenceScreenBindingHelper.kt
@@ -97,14 +97,14 @@ class PreferenceScreenBindingHelper(
val preferencesBuilder = ImmutableMap.builder<String, PreferenceHierarchyNode>()
val dependenciesBuilder = ImmutableMultimap.builder<String, String>()
val lifecycleAwarePreferences = mutableListOf<PreferenceLifecycleProvider>()
- fun PreferenceMetadata.addDependency(dependency: PreferenceMetadata) {
- dependenciesBuilder.put(key, dependency.key)
- }
fun PreferenceHierarchyNode.addNode() {
metadata.let {
- preferencesBuilder.put(it.key, this)
- it.dependencyOfEnabledState(context)?.addDependency(it)
+ val key = it.key
+ preferencesBuilder.put(key, this)
+ for (dependency in it.dependencies(context)) {
+ dependenciesBuilder.put(dependency, key)
+ }
if (it is PreferenceLifecycleProvider) lifecycleAwarePreferences.add(it)
}
}
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant12.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant12.xml
new file mode 100644
index 000000000000..f125425d1ec9
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant12.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="12"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant17.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant17.xml
new file mode 100644
index 000000000000..36a781954e42
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant17.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="17"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant22.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant22.xml
new file mode 100644
index 000000000000..0ef31d014aa2
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant22.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="22"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant24.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant24.xml
new file mode 100644
index 000000000000..6797f82e4250
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant24.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="24"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant4.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant4.xml
new file mode 100644
index 000000000000..ff7df5543a40
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant4.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="4"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant6.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant6.xml
new file mode 100644
index 000000000000..8da5dafea567
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant6.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="6"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant87.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant87.xml
new file mode 100644
index 000000000000..227baeedd99e
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant87.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="87"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant92.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant92.xml
new file mode 100644
index 000000000000..f4564381eb33
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant92.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="92"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant94.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant94.xml
new file mode 100644
index 000000000000..bb4e03d64307
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant94.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="94"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant96.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant96.xml
new file mode 100644
index 000000000000..949b1961099f
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant96.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="96"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant98.xml b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant98.xml
new file mode 100644
index 000000000000..7e5ee241ffbd
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/color-v31/settingslib_neutral_variant98.xml
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+ <item android:color="@android:color/system_neutral2_600" android:lStar="98"/>
+</selector> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_check.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_check.xml
index 309dbdf1ea96..309dbdf1ea96 100644
--- a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_check.xml
+++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_check.xml
diff --git a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_close.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_close.xml
index e6df8a416922..e6df8a416922 100644
--- a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_icon_close.xml
+++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_icon_close.xml
diff --git a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_switch_thumb_icon.xml b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_switch_thumb_icon.xml
index 342729d7ee5a..342729d7ee5a 100644
--- a/packages/SettingsLib/SettingsTheme/res/drawable-v35/settingslib_expressive_switch_thumb_icon.xml
+++ b/packages/SettingsLib/SettingsTheme/res/drawable/settingslib_expressive_switch_thumb_icon.xml
diff --git a/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_collapsable_textview.xml b/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_collapsable_textview.xml
index ea7baa42a2c7..2261e58a961e 100644
--- a/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_collapsable_textview.xml
+++ b/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_collapsable_textview.xml
@@ -40,7 +40,7 @@
android:longClickable="false"
android:maxLines="10"
android:ellipsize="end"
- android:textAppearance="@style/TextAppearance.TopIntroText"/>
+ android:textAppearance="@style/TextAppearance.SettingsLib.BodyLarge"/>
<com.android.settingslib.widget.LinkableTextView
android:id="@+id/settingslib_expressive_learn_more"
diff --git a/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_preference_text_frame.xml b/packages/SettingsLib/SettingsTheme/res/layout/settingslib_expressive_preference_text_frame.xml
index c837ff43e46b..db357f8ae13f 100644
--- a/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_expressive_preference_text_frame.xml
+++ b/packages/SettingsLib/SettingsTheme/res/layout/settingslib_expressive_preference_text_frame.xml
@@ -32,8 +32,6 @@
android:layout_gravity="start"
android:textAlignment="viewStart"
android:maxLines="2"
- android:hyphenationFrequency="normalFast"
- android:lineBreakWordStyle="phrase"
android:textAppearance="?android:attr/textAppearanceListItem"
android:ellipsize="marquee"/>
@@ -47,7 +45,5 @@
android:textAlignment="viewStart"
android:textAppearance="?android:attr/textAppearanceListItemSecondary"
android:textColor="?android:attr/textColorSecondary"
- android:maxLines="10"
- android:hyphenationFrequency="normalFast"
- android:lineBreakWordStyle="phrase"/>
+ android:maxLines="10"/>
</RelativeLayout> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_preference_category_no_title.xml b/packages/SettingsLib/SettingsTheme/res/layout/settingslib_preference_category_no_title.xml
index f69fcd270919..f69fcd270919 100644
--- a/packages/SettingsLib/SettingsTheme/res/layout-v35/settingslib_preference_category_no_title.xml
+++ b/packages/SettingsLib/SettingsTheme/res/layout/settingslib_preference_category_no_title.xml
diff --git a/packages/SettingsLib/SettingsTheme/res/values-night-v31/colors.xml b/packages/SettingsLib/SettingsTheme/res/values-night-v31/colors.xml
index 46ec62e7a5ef..8873116be306 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-night-v31/colors.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values-night-v31/colors.xml
@@ -58,4 +58,39 @@
<color name="settingslib_colorSurface">@color/settingslib_surface_dark</color>
<color name="settingslib_list_divider_color">@android:color/system_neutral1_700</color>
+
+ <color name="settingslib_materialColorPrimary">@android:color/system_accent1_200</color>
+ <color name="settingslib_materialColorOnPrimary">@android:color/system_accent1_800</color>
+ <color name="settingslib_materialColorPrimaryContainer">@android:color/system_accent1_700</color>
+ <color name="settingslib_materialColorOnPrimaryContainer">@android:color/system_accent1_100</color>
+ <color name="settingslib_materialColorPrimaryInverse">@android:color/system_accent1_600</color>
+ <color name="settingslib_materialColorSecondary">@android:color/system_accent2_200</color>
+ <color name="settingslib_materialColorOnSecondary">@android:color/system_accent2_800</color>
+ <color name="settingslib_materialColorSecondaryContainer">@android:color/system_accent2_700</color>
+ <color name="settingslib_materialColorOnSecondaryContainer">@android:color/system_accent2_100</color>
+ <color name="settingslib_materialColorTertiary">@android:color/system_accent3_200</color>
+ <color name="settingslib_materialColorOnTertiary">@android:color/system_accent3_800</color>
+ <color name="settingslib_materialColorTertiaryContainer">@android:color/system_accent3_700</color>
+ <color name="settingslib_materialColorOnTertiaryContainer">@android:color/system_accent3_100</color>
+ <color name="settingslib_materialColorError">@color/settingslib_error_200</color>
+ <color name="settingslib_materialColorOnError">@color/settingslib_error_800</color>
+ <color name="settingslib_materialColorErrorContainer">@color/settingslib_error_700</color>
+ <color name="settingslib_materialColorOnErrorContainer">@color/settingslib_error_100</color>
+ <color name="settingslib_materialColorOutline">@android:color/system_neutral2_400</color>
+ <color name="settingslib_materialColorOutlineVariant">@android:color/system_neutral2_700</color>
+ <color name="settingslib_materialColorBackground">@color/settingslib_neutral_variant6</color>
+ <color name="settingslib_materialColorOnBackground">@android:color/system_neutral1_100</color>
+ <color name="settingslib_materialColorSurface">@color/settingslib_neutral_variant6</color>
+ <color name="settingslib_materialColorOnSurface">@android:color/system_neutral1_100</color>
+ <color name="settingslib_materialColorSurfaceVariant">@android:color/system_neutral2_700</color>
+ <color name="settingslib_materialColorOnSurfaceVariant">@android:color/system_neutral2_200</color>
+ <color name="settingslib_materialColorSurfaceInverse">@android:color/system_neutral1_100</color>
+ <color name="settingslib_materialColorOnSurfaceInverse">@android:color/system_neutral1_800</color>
+ <color name="settingslib_materialColorSurfaceBright">@color/settingslib_neutral_variant24</color>
+ <color name="settingslib_materialColorSurfaceDim">@color/settingslib_neutral_variant6</color>
+ <color name="settingslib_materialColorSurfaceContainer">@color/settingslib_neutral_variant12</color>
+ <color name="settingslib_materialColorSurfaceContainerLowest">@color/settingslib_neutral_variant4</color>
+ <color name="settingslib_materialColorSurfaceContainerLow">@android:color/system_neutral2_900</color>
+ <color name="settingslib_materialColorSurfaceContainerHigh">@color/settingslib_neutral_variant17</color>
+ <color name="settingslib_materialColorSurfaceContainerHighest">@color/settingslib_neutral_variant22</color>
</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/values-night-v34/colors.xml b/packages/SettingsLib/SettingsTheme/res/values-night-v34/colors.xml
index 8cfe54f44fe5..00a1f27c162a 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-night-v34/colors.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values-night-v34/colors.xml
@@ -42,4 +42,39 @@
<color name="settingslib_text_color_primary_device_default">@android:color/system_on_surface_dark</color>
<!--Deprecated. After sdk 35 don't use it. using materialColorOnSurfaceVariant-->
<color name="settingslib_text_color_secondary_device_default">@android:color/system_on_surface_variant_dark</color>
+
+ <color name="settingslib_materialColorPrimary">@android:color/system_primary_dark</color>
+ <color name="settingslib_materialColorOnPrimary">@android:color/system_on_primary_dark</color>
+ <color name="settingslib_materialColorPrimaryContainer">@android:color/system_primary_container_dark</color>
+ <color name="settingslib_materialColorOnPrimaryContainer">@android:color/system_on_primary_container_dark</color>
+ <color name="settingslib_materialColorPrimaryInverse">@android:color/system_primary_light</color>
+ <color name="settingslib_materialColorSecondary">@android:color/system_secondary_dark</color>
+ <color name="settingslib_materialColorOnSecondary">@android:color/system_on_secondary_dark</color>
+ <color name="settingslib_materialColorSecondaryContainer">@android:color/system_secondary_container_dark</color>
+ <color name="settingslib_materialColorOnSecondaryContainer">@android:color/system_on_secondary_container_dark</color>
+ <color name="settingslib_materialColorTertiary">@android:color/system_tertiary_dark</color>
+ <color name="settingslib_materialColorOnTertiary">@android:color/system_on_tertiary_dark</color>
+ <color name="settingslib_materialColorTertiaryContainer">@android:color/system_tertiary_container_dark</color>
+ <color name="settingslib_materialColorOnTertiaryContainer">@android:color/system_on_tertiary_container_dark</color>
+ <color name="settingslib_materialColorError">@android:color/system_error_dark</color>
+ <color name="settingslib_materialColorOnError">@android:color/system_on_error_dark</color>
+ <color name="settingslib_materialColorErrorContainer">@android:color/system_error_container_dark</color>
+ <color name="settingslib_materialColorOnErrorContainer">@android:color/system_on_error_container_dark</color>
+ <color name="settingslib_materialColorOutline">@android:color/system_outline_dark</color>
+ <color name="settingslib_materialColorOutlineVariant">@android:color/system_outline_variant_dark</color>
+ <color name="settingslib_materialColorBackground">@android:color/system_background_dark</color>
+ <color name="settingslib_materialColorOnBackground">@android:color/system_on_background_dark</color>
+ <color name="settingslib_materialColorSurface">@android:color/system_surface_dark</color>
+ <color name="settingslib_materialColorOnSurface">@android:color/system_on_surface_dark</color>
+ <color name="settingslib_materialColorSurfaceVariant">@android:color/system_surface_variant_dark</color>
+ <color name="settingslib_materialColorOnSurfaceVariant">@android:color/system_on_surface_variant_dark</color>
+ <color name="settingslib_materialColorSurfaceInverse">@android:color/system_surface_light</color>
+ <color name="settingslib_materialColorOnSurfaceInverse">@android:color/system_on_surface_light</color>
+ <color name="settingslib_materialColorSurfaceBright">@android:color/system_surface_bright_dark</color>
+ <color name="settingslib_materialColorSurfaceDim">@android:color/system_surface_dim_dark</color>
+ <color name="settingslib_materialColorSurfaceContainer">@android:color/system_surface_container_dark</color>
+ <color name="settingslib_materialColorSurfaceContainerLow">@android:color/system_surface_container_low_dark</color>
+ <color name="settingslib_materialColorSurfaceContainerLowest">@android:color/system_surface_container_lowest_dark</color>
+ <color name="settingslib_materialColorSurfaceContainerHigh">@android:color/system_surface_container_high_dark</color>
+ <color name="settingslib_materialColorSurfaceContainerHighest">@android:color/system_surface_container_highest_dark</color>
</resources>
diff --git a/packages/SettingsLib/SettingsTheme/res/values-night-v35/colors.xml b/packages/SettingsLib/SettingsTheme/res/values-night-v35/colors.xml
index 84a3ed68af01..e31e80176625 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-night-v35/colors.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values-night-v35/colors.xml
@@ -46,37 +46,4 @@
<color name="settingslib_colorSurfaceHeader">@color/settingslib_materialColorSurfaceVariant</color>
<color name="settingslib_text_color_preference_category_title">@color/settingslib_materialColorPrimary</color>
-
- <color name="settingslib_materialColorSurfaceContainerLowest">@android:color/system_surface_container_lowest_dark</color>
- <color name="settingslib_materialColorOnSecondaryContainer">@android:color/system_on_secondary_container_dark</color>
- <color name="settingslib_materialColorOnTertiaryContainer">@android:color/system_on_tertiary_container_dark</color>
- <color name="settingslib_materialColorSurfaceContainerLow">@android:color/system_surface_container_low_dark</color>
- <color name="settingslib_materialColorOnPrimaryContainer">@android:color/system_on_primary_container_dark</color>
- <color name="settingslib_materialColorOnErrorContainer">@android:color/system_on_error_container_dark</color>
- <color name="settingslib_materialColorInverseOnSurface">@android:color/system_on_surface_light</color>
- <color name="settingslib_materialColorSecondaryContainer">@android:color/system_secondary_container_dark</color>
- <color name="settingslib_materialColorErrorContainer">@android:color/system_error_container_dark</color>
- <color name="settingslib_materialColorInversePrimary">@android:color/system_primary_light</color>
- <color name="settingslib_materialColorInverseSurface">@android:color/system_surface_light</color>
- <color name="settingslib_materialColorSurfaceVariant">@android:color/system_surface_variant_dark</color>
- <color name="settingslib_materialColorTertiaryContainer">@android:color/system_tertiary_container_dark</color>
- <color name="settingslib_materialColorPrimaryContainer">@android:color/system_primary_container_dark</color>
- <color name="settingslib_materialColorOnBackground">@android:color/system_on_background_dark</color>
- <color name="settingslib_materialColorOnSecondary">@android:color/system_on_secondary_dark</color>
- <color name="settingslib_materialColorOnTertiary">@android:color/system_on_tertiary_dark</color>
- <color name="settingslib_materialColorSurfaceDim">@android:color/system_surface_dim_dark</color>
- <color name="settingslib_materialColorSurfaceBright">@android:color/system_surface_bright_dark</color>
- <color name="settingslib_materialColorOnError">@android:color/system_on_error_dark</color>
- <color name="settingslib_materialColorSurface">@android:color/system_surface_dark</color>
- <color name="settingslib_materialColorSurfaceContainerHigh">@android:color/system_surface_container_high_dark</color>
- <color name="settingslib_materialColorSurfaceContainerHighest">@android:color/system_surface_container_highest_dark</color>
- <color name="settingslib_materialColorOnSurfaceVariant">@android:color/system_on_surface_variant_dark</color>
- <color name="settingslib_materialColorOutline">@android:color/system_outline_dark</color>
- <color name="settingslib_materialColorOutlineVariant">@android:color/system_outline_variant_dark</color>
- <color name="settingslib_materialColorOnPrimary">@android:color/system_on_primary_dark</color>
- <color name="settingslib_materialColorOnSurface">@android:color/system_on_surface_dark</color>
- <color name="settingslib_materialColorSurfaceContainer">@android:color/system_surface_container_dark</color>
- <color name="settingslib_materialColorPrimary">@android:color/system_primary_dark</color>
- <color name="settingslib_materialColorSecondary">@android:color/system_secondary_dark</color>
- <color name="settingslib_materialColorTertiary">@android:color/system_tertiary_dark</color>
</resources>
diff --git a/packages/SettingsLib/SettingsTheme/res/values-night/colors.xml b/packages/SettingsLib/SettingsTheme/res/values-night/colors.xml
new file mode 100644
index 000000000000..e57fe4f512fe
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/values-night/colors.xml
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<resources>
+ <color name="settingslib_materialColorPrimary">#83D6C7</color>
+ <color name="settingslib_materialColorOnPrimary">#003730</color>
+ <color name="settingslib_materialColorPrimaryContainer">#005047</color>
+ <color name="settingslib_materialColorOnPrimaryContainer">#A1F1E2</color>
+ <color name="settingslib_materialColorPrimaryInverse">#A1F1E2</color>
+ <color name="settingslib_materialColorSecondary">#B1CCC6</color>
+ <color name="settingslib_materialColorOnSecondary">#1C342F</color>
+ <color name="settingslib_materialColorSecondaryContainer">#334C47</color>
+ <color name="settingslib_materialColorOnSecondaryContainer">#CCE8E2</color>
+ <color name="settingslib_materialColorTertiary">#ADCAE5</color>
+ <color name="settingslib_materialColorOnTertiary">#123349</color>
+ <color name="settingslib_materialColorTertiaryContainer">#2D4960</color>
+ <color name="settingslib_materialColorOnTertiaryContainer">#CEE7FF</color>
+ <color name="settingslib_materialColorError">#F2B8B5</color>
+ <color name="settingslib_materialColorOnError">#601410</color>
+ <color name="settingslib_materialColorErrorContainer">#8C1D18</color>
+ <color name="settingslib_materialColorOnErrorContainer">#F9DEDC</color>
+ <color name="settingslib_materialColorOutline">#919191</color>
+ <color name="settingslib_materialColorOutlineVariant">#474747</color>
+ <color name="settingslib_materialColorBackground">#131313</color>
+ <color name="settingslib_materialColorOnBackground">#E5E2E1</color>
+ <color name="settingslib_materialColorSurface">#131313</color>
+ <color name="settingslib_materialColorOnSurface">#E5E2E1</color>
+ <color name="settingslib_materialColorSurfaceVariant">#474747</color>
+ <color name="settingslib_materialColorOnSurfaceVariant">#C7C7C7</color>
+ <color name="settingslib_materialColorSurfaceInverse">#E5E2E1</color>
+ <color name="settingslib_materialColorOnSurfaceInverse">#303030</color>
+ <color name="settingslib_materialColorSurfaceBright">#393939</color>
+ <color name="settingslib_materialColorSurfaceDim">#131313</color>
+ <color name="settingslib_materialColorSurfaceContainer">#1F1F1F</color>
+ <color name="settingslib_materialColorSurfaceContainerLowest">#1B1B1B</color>
+ <color name="settingslib_materialColorSurfaceContainerLow">#0E0E0E</color>
+ <color name="settingslib_materialColorSurfaceContainerHigh">#2A2A2A</color>
+ <color name="settingslib_materialColorSurfaceContainerHighest">#343434</color>
+</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v31/colors.xml b/packages/SettingsLib/SettingsTheme/res/values-v31/colors.xml
index fef92b792bec..e000423784c6 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-v31/colors.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values-v31/colors.xml
@@ -92,4 +92,51 @@
<color name="settingslib_spinner_dropdown_color">@android:color/system_neutral2_700</color>
<color name="settingslib_list_divider_color">@android:color/system_neutral1_200</color>
+
+ <color name="settingslib_materialColorPrimary">@android:color/system_accent1_600</color>
+ <color name="settingslib_materialColorOnPrimary">@android:color/system_accent1_0</color>
+ <color name="settingslib_materialColorPrimaryContainer">@android:color/system_accent1_100</color>
+ <color name="settingslib_materialColorOnPrimaryContainer">@android:color/system_accent1_900</color>
+ <color name="settingslib_materialColorPrimaryInverse">@android:color/system_accent1_200</color>
+ <color name="settingslib_materialColorPrimaryFixed">@android:color/system_accent1_100</color>
+ <color name="settingslib_materialColorPrimaryFixedDim">@android:color/system_accent1_200</color>
+ <color name="settingslib_materialColorOnPrimaryFixed">@android:color/system_accent1_900</color>
+ <color name="settingslib_materialColorOnPrimaryFixedVariant">@android:color/system_accent1_700</color>
+ <color name="settingslib_materialColorSecondary">@android:color/system_accent2_600</color>
+ <color name="settingslib_materialColorOnSecondary">@android:color/system_accent2_0</color>
+ <color name="settingslib_materialColorSecondaryContainer">@android:color/system_accent2_100</color>
+ <color name="settingslib_materialColorOnSecondaryContainer">@android:color/system_accent2_900</color>
+ <color name="settingslib_materialColorSecondaryFixed">@android:color/system_accent2_100</color>
+ <color name="settingslib_materialColorSecondaryFixedDim">@android:color/system_accent2_200</color>
+ <color name="settingslib_materialColorOnSecondaryFixed">@android:color/system_accent2_900</color>
+ <color name="settingslib_materialColorOnSecondaryFixedVariant">@android:color/system_accent2_700</color>
+ <color name="settingslib_materialColorTertiary">@android:color/system_accent3_600</color>
+ <color name="settingslib_materialColorOnTertiary">@android:color/system_accent3_0</color>
+ <color name="settingslib_materialColorTertiaryContainer">@android:color/system_accent3_100</color>
+ <color name="settingslib_materialColorOnTertiaryContainer">@android:color/system_accent3_900</color>
+ <color name="settingslib_materialColorTertiaryFixed">@android:color/system_accent3_100</color>
+ <color name="settingslib_materialColorTertiaryFixedDim">@android:color/system_accent3_200</color>
+ <color name="settingslib_materialColorOnTertiaryFixed">@android:color/system_accent3_900</color>
+ <color name="settingslib_materialColorOnTertiaryFixedVariant">@android:color/system_accent3_700</color>
+ <color name="settingslib_materialColorError">@color/settingslib_error_600</color>
+ <color name="settingslib_materialColorOnError">@android:color/white</color>
+ <color name="settingslib_materialColorErrorContainer">@color/settingslib_error_100</color>
+ <color name="settingslib_materialColorOnErrorContainer">@color/settingslib_error_900</color>
+ <color name="settingslib_materialColorOutline">@android:color/system_neutral2_500</color>
+ <color name="settingslib_materialColorOutlineVariant">@android:color/system_neutral2_200</color>
+ <color name="settingslib_materialColorBackground">@android:color/white</color>
+ <color name="settingslib_materialColorOnBackground">@android:color/system_neutral1_900</color>
+ <color name="settingslib_materialColorSurface">@color/settingslib_neutral_variant98</color>
+ <color name="settingslib_materialColorOnSurface">@android:color/system_neutral1_900</color>
+ <color name="settingslib_materialColorSurfaceVariant">@android:color/system_neutral2_100</color>
+ <color name="settingslib_materialColorOnSurfaceVariant">@android:color/system_neutral2_700</color>
+ <color name="settingslib_materialColorSurfaceInverse">@android:color/system_neutral1_800</color>
+ <color name="settingslib_materialColorOnSurfaceInverse">@android:color/system_neutral1_50</color>
+ <color name="settingslib_materialColorSurfaceBright">@color/settingslib_neutral_variant98</color>
+ <color name="settingslib_materialColorSurfaceDim">@color/settingslib_neutral_variant87</color>
+ <color name="settingslib_materialColorSurfaceContainer">@color/settingslib_neutral_variant94</color>
+ <color name="settingslib_materialColorSurfaceContainerLow">@color/settingslib_neutral_variant96</color>
+ <color name="settingslib_materialColorSurfaceContainerLowest">@android:color/system_neutral2_0</color>
+ <color name="settingslib_materialColorSurfaceContainerHigh">@color/settingslib_neutral_variant92</color>
+ <color name="settingslib_materialColorSurfaceContainerHighest">@android:color/system_neutral2_100</color>
</resources>
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v31/config.xml b/packages/SettingsLib/SettingsTheme/res/values-v31/config.xml
index 4860ad361744..8993d0fc71f7 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-v31/config.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values-v31/config.xml
@@ -17,6 +17,4 @@
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<bool name="settingslib_config_icon_space_reserved">false</bool>
<bool name="settingslib_config_allow_divider">false</bool>
- <!-- Name of a font family to use for headlines in SettingsLib. -->
- <string name="settingslib_config_headlineFontFamily" translatable="false"></string>
</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v31/styles_expressive.xml b/packages/SettingsLib/SettingsTheme/res/values-v31/styles_expressive.xml
new file mode 100644
index 000000000000..9d3d70b366aa
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/values-v31/styles_expressive.xml
@@ -0,0 +1,129 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ -->
+
+<resources>
+ <style name="SettingsLibButtonStyle.Expressive.Filled"
+ parent="@style/Widget.Material3.Button">
+ <item name="android:theme">@style/Theme.Material3.DynamicColors.DayNight</item>
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:gravity">center</item>
+ <item name="android:minWidth">@dimen/settingslib_expressive_space_medium4</item>
+ <item name="android:minHeight">@dimen/settingslib_expressive_space_medium4</item>
+ <item name="android:paddingVertical">@dimen/settingslib_expressive_space_extrasmall5</item>
+ <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small1</item>
+ <item name="android:backgroundTint">@color/settingslib_materialColorPrimary</item>
+ <item name="android:textAppearance">@style/TextAppearance.SettingsLib.LabelLarge</item>
+ <item name="android:textColor">@color/settingslib_materialColorOnPrimary</item>
+ <item name="iconGravity">textStart</item>
+ <item name="iconTint">@color/settingslib_materialColorOnPrimary</item>
+ <item name="iconSize">@dimen/settingslib_expressive_space_small4</item>
+ </style>
+
+ <style name="SettingsLibButtonStyle.Expressive.Filled.Large">
+ <item name="android:paddingVertical">@dimen/settingslib_expressive_space_small1</item>
+ <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small4</item>
+ <item name="android:textAppearance">@style/TextAppearance.SettingsLib.TitleMedium</item>
+ </style>
+
+ <style name="SettingsLibButtonStyle.Expressive.Filled.Extra"
+ parent="@style/SettingsLibButtonStyle.Expressive.Filled.Large">
+ <item name="android:layout_width">match_parent</item>
+ </style>
+
+ <style name="SettingsLibButtonStyle.Expressive.Tonal"
+ parent="@style/Widget.Material3.Button.TonalButton">
+ <item name="android:theme">@style/Theme.Material3.DynamicColors.DayNight</item>
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:gravity">center</item>
+ <item name="android:minWidth">@dimen/settingslib_expressive_space_medium4</item>
+ <item name="android:minHeight">@dimen/settingslib_expressive_space_medium4</item>
+ <item name="android:paddingVertical">@dimen/settingslib_expressive_space_extrasmall5</item>
+ <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small1</item>
+ <item name="android:backgroundTint">@color/settingslib_materialColorSecondaryContainer</item>
+ <item name="android:textAppearance">@style/TextAppearance.SettingsLib.LabelLarge</item>
+ <item name="android:textColor">@color/settingslib_materialColorOnSecondaryContainer</item>
+ <item name="iconGravity">textStart</item>
+ <item name="iconTint">@color/settingslib_materialColorOnSecondaryContainer</item>
+ <item name="iconSize">@dimen/settingslib_expressive_space_small4</item>
+ </style>
+
+ <style name="SettingsLibButtonStyle.Expressive.Tonal.Large">
+ <item name="android:paddingVertical">@dimen/settingslib_expressive_space_small1</item>
+ <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small4</item>
+ <item name="android:textAppearance">@style/TextAppearance.SettingsLib.TitleMedium</item>
+ </style>
+
+ <style name="SettingsLibButtonStyle.Expressive.Tonal.Extra"
+ parent="@style/SettingsLibButtonStyle.Expressive.Tonal.Large">
+ <item name="android:layout_width">match_parent</item>
+ </style>
+
+ <style name="SettingsLibButtonStyle.Expressive.Outline"
+ parent="@style/Widget.Material3.Button.OutlinedButton.Icon">
+ <item name="android:theme">@style/Theme.Material3.DynamicColors.DayNight</item>
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:gravity">center</item>
+ <item name="android:minWidth">@dimen/settingslib_expressive_space_medium4</item>
+ <item name="android:minHeight">@dimen/settingslib_expressive_space_medium4</item>
+ <item name="android:paddingVertical">@dimen/settingslib_expressive_space_extrasmall5</item>
+ <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small1</item>
+ <item name="android:textAppearance">@style/TextAppearance.SettingsLib.LabelLarge</item>
+ <item name="android:textColor">@color/settingslib_materialColorPrimary</item>
+ <item name="iconTint">@color/settingslib_materialColorPrimary</item>
+ <item name="iconGravity">textStart</item>
+ <item name="iconSize">@dimen/settingslib_expressive_space_small4</item>
+ <item name="iconPadding">@dimen/settingslib_expressive_space_extrasmall4</item>
+ <item name="strokeColor">@color/settingslib_materialColorOutlineVariant</item>
+ </style>
+
+ <style name="SettingsLibButtonStyle.Expressive.Outline.Large">
+ <item name="android:paddingVertical">@dimen/settingslib_expressive_space_small1</item>
+ <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small4</item>
+ <item name="android:textAppearance">@style/TextAppearance.SettingsLib.TitleMedium</item>
+ </style>
+
+ <style name="SettingsLibButtonStyle.Expressive.Outline.Extra"
+ parent="@style/SettingsLibButtonStyle.Expressive.Outline.Large">
+ <item name="android:layout_width">match_parent</item>
+ </style>
+
+ <style name="SettingslibTextButtonStyle.Expressive"
+ parent="@style/Widget.Material3.Button.TextButton.Icon">
+ <item name="android:theme">@style/Theme.Material3.DynamicColors.DayNight</item>
+ <item name="android:layout_width">wrap_content</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:textAppearance">@style/TextAppearance.SettingsLib.BodyLarge.Emphasized</item>
+ <item name="android:textColor">@color/settingslib_materialColorOnSurface</item>
+ <item name="iconTint">@null</item>
+ <item name="iconPadding">@dimen/settingslib_expressive_space_extrasmall4</item>
+ <item name="rippleColor">?android:attr/colorControlHighlight</item>
+ </style>
+
+ <style name="SettingsLibCardStyle" parent="">
+ <item name="android:layout_width">match_parent</item>
+ <item name="android:layout_height">wrap_content</item>
+ <item name="android:layout_marginHorizontal">?android:attr/listPreferredItemPaddingStart</item>
+ <item name="android:layout_marginVertical">@dimen/settingslib_expressive_space_extrasmall4</item>
+ <item name="cardBackgroundColor">@color/settingslib_materialColorPrimary</item>
+ <item name="cardCornerRadius">@dimen/settingslib_expressive_radius_extralarge3</item>
+ <item name="cardElevation">0dp</item>
+ <item name="rippleColor">?android:attr/colorControlHighlight</item>
+ </style>
+</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v33/styles_expressive.xml b/packages/SettingsLib/SettingsTheme/res/values-v33/styles_expressive.xml
new file mode 100644
index 000000000000..74bf55a8a625
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/values-v33/styles_expressive.xml
@@ -0,0 +1,306 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ -->
+
+<resources>
+ <style name="TextAppearance.SettingsLib.DisplayLarge"
+ parent="@android:style/TextAppearance.DeviceDefault.Headline">
+ <item name="android:textSize">57sp</item>
+ <item name="android:letterSpacing">-0.00438596</item>
+ <item name="android:lineHeight">64sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.DisplayMedium"
+ parent="@android:style/TextAppearance.DeviceDefault.Headline">
+ <item name="android:textSize">45sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">52sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.DisplaySmall"
+ parent="@android:style/TextAppearance.DeviceDefault.Headline">
+ <item name="android:textSize">36sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">44sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.HeadlineLarge"
+ parent="@android:style/TextAppearance.DeviceDefault.Headline">
+ <item name="android:textSize">32sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">40sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.HeadlineMedium"
+ parent="@android:style/TextAppearance.DeviceDefault.Headline">
+ <item name="android:textSize">28sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">36sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.HeadlineSmall"
+ parent="@android:style/TextAppearance.DeviceDefault.Headline">
+ <item name="android:textSize">24sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">32sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.TitleLarge"
+ parent="@android:style/TextAppearance.DeviceDefault.Headline">
+ <item name="android:textSize">22sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">28sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.TitleMedium"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textSize">16sp</item>
+ <item name="android:letterSpacing">0.009375</item>
+ <item name="android:lineHeight">24sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.TitleSmall"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.00714286</item>
+ <item name="android:lineHeight">20sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.LabelLarge"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.00714286</item>
+ <item name="android:lineHeight">20sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.LabelMedium"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textSize">12sp</item>
+ <item name="android:letterSpacing">0.04166667</item>
+ <item name="android:lineHeight">16sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.LabelSmall"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textSize">11sp</item>
+ <item name="android:letterSpacing">0.04545455</item>
+ <item name="android:lineHeight">16sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.BodyLarge"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textSize">16sp</item>
+ <item name="android:letterSpacing">0.03125</item>
+ <item name="android:lineHeight">24sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.BodyMedium"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.01785714</item>
+ <item name="android:lineHeight">20sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.BodySmall"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textSize">12sp</item>
+ <item name="android:letterSpacing">0.03333333</item>
+ <item name="android:lineHeight">16sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.DisplayLarge.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">57sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">64sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.DisplayMedium.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">45sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">52sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.DisplaySmall.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">36sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">44sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.HeadlineLarge.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">32sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">40sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.HeadlineMedium.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">28sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">36sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.HeadlineSmall.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">24sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">32sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.TitleLarge.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">22sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight">28sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.TitleMedium.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">16sp</item>
+ <item name="android:letterSpacing">0.009375</item>
+ <item name="android:lineHeight">24sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.TitleSmall.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.00714286</item>
+ <item name="android:lineHeight">20sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.LabelLarge.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.00714286</item>
+ <item name="android:lineHeight">20sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.LabelMedium.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">12sp</item>
+ <item name="android:letterSpacing">0.04166667</item>
+ <item name="android:lineHeight">16sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.LabelSmall.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">11sp</item>
+ <item name="android:letterSpacing">0.04545455</item>
+ <item name="android:lineHeight">16sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.BodyLarge.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textStyle">normal</item>
+ <item name="android:textSize">16sp</item>
+ <item name="android:letterSpacing">0.009375</item>
+ <item name="android:lineHeight">24sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.BodyMedium.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textStyle">normal</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.01785714</item>
+ <item name="android:lineHeight">20sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.BodySmall.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textStyle">normal</item>
+ <item name="android:textSize">12sp</item>
+ <item name="android:letterSpacing">0.03333333</item>
+ <item name="android:lineHeight">16sp</item>
+ <item name="android:hyphenationFrequency">normalFast</item>
+ <item name="android:lineBreakWordStyle">phrase</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v34/colors.xml b/packages/SettingsLib/SettingsTheme/res/values-v34/colors.xml
index 185ac3e1fe73..60642e617a81 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-v34/colors.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values-v34/colors.xml
@@ -43,4 +43,51 @@
<color name="settingslib_text_color_primary_device_default">@android:color/system_on_surface_light</color>
<!--Deprecated. After sdk 35 don't use it. using materialColorOnSurfaceVariant-->
<color name="settingslib_text_color_secondary_device_default">@android:color/system_on_surface_variant_light</color>
+
+ <color name="settingslib_materialColorPrimary">@android:color/system_primary_light</color>
+ <color name="settingslib_materialColorOnPrimary">@android:color/system_on_primary_light</color>
+ <color name="settingslib_materialColorPrimaryContainer">@android:color/system_primary_container_light</color>
+ <color name="settingslib_materialColorOnPrimaryContainer">@android:color/system_on_primary_container_light</color>
+ <color name="settingslib_materialColorPrimaryInverse">@android:color/system_primary_dark</color>
+ <color name="settingslib_materialColorPrimaryFixed">@android:color/system_primary_fixed</color>
+ <color name="settingslib_materialColorPrimaryFixedDim">@android:color/system_primary_fixed_dim</color>
+ <color name="settingslib_materialColorOnPrimaryFixed">@android:color/system_on_primary_fixed</color>
+ <color name="settingslib_materialColorOnPrimaryFixedVariant">@android:color/system_on_primary_fixed_variant</color>
+ <color name="settingslib_materialColorSecondary">@android:color/system_secondary_light</color>
+ <color name="settingslib_materialColorOnSecondary">@android:color/system_on_secondary_light</color>
+ <color name="settingslib_materialColorSecondaryContainer">@android:color/system_secondary_container_light</color>
+ <color name="settingslib_materialColorOnSecondaryContainer">@android:color/system_on_secondary_container_light</color>
+ <color name="settingslib_materialColorSecondaryFixed">@android:color/system_secondary_fixed</color>
+ <color name="settingslib_materialColorSecondaryFixedDim">@android:color/system_secondary_fixed_dim</color>
+ <color name="settingslib_materialColorOnSecondaryFixed">@android:color/system_on_secondary_fixed</color>
+ <color name="settingslib_materialColorOnSecondaryFixedVariant">@android:color/system_on_secondary_fixed_variant</color>
+ <color name="settingslib_materialColorTertiary">@android:color/system_tertiary_light</color>
+ <color name="settingslib_materialColorOnTertiary">@android:color/system_on_tertiary_light</color>
+ <color name="settingslib_materialColorTertiaryContainer">@android:color/system_tertiary_container_light</color>
+ <color name="settingslib_materialColorOnTertiaryContainer">@android:color/system_on_tertiary_container_light</color>
+ <color name="settingslib_materialColorTertiaryFixed">@android:color/system_tertiary_fixed</color>
+ <color name="settingslib_materialColorTertiaryFixedDim">@android:color/system_tertiary_fixed_dim</color>
+ <color name="settingslib_materialColorOnTertiaryFixed">@android:color/system_on_tertiary_fixed</color>
+ <color name="settingslib_materialColorOnTertiaryFixedVariant">@android:color/system_on_tertiary_fixed_variant</color>
+ <color name="settingslib_materialColorError">@android:color/system_error_light</color>
+ <color name="settingslib_materialColorOnError">@android:color/system_on_error_light</color>
+ <color name="settingslib_materialColorErrorContainer">@android:color/system_error_container_light</color>
+ <color name="settingslib_materialColorOnErrorContainer">@android:color/system_on_error_container_light</color>
+ <color name="settingslib_materialColorOutline">@android:color/system_outline_light</color>
+ <color name="settingslib_materialColorOutlineVariant">@android:color/system_outline_variant_light</color>
+ <color name="settingslib_materialColorBackground">@android:color/system_background_light</color>
+ <color name="settingslib_materialColorOnBackground">@android:color/system_on_background_light</color>
+ <color name="settingslib_materialColorSurface">@android:color/system_surface_light</color>
+ <color name="settingslib_materialColorOnSurface">@android:color/system_on_surface_light</color>
+ <color name="settingslib_materialColorSurfaceVariant">@android:color/system_surface_variant_light</color>
+ <color name="settingslib_materialColorOnSurfaceVariant">@android:color/system_on_surface_variant_light</color>
+ <color name="settingslib_materialColorSurfaceInverse">@android:color/system_surface_dark</color>
+ <color name="settingslib_materialColorOnSurfaceInverse">@android:color/system_on_surface_dark</color>
+ <color name="settingslib_materialColorSurfaceBright">@android:color/system_surface_bright_light</color>
+ <color name="settingslib_materialColorSurfaceDim">@android:color/system_surface_dim_light</color>
+ <color name="settingslib_materialColorSurfaceContainer">@android:color/system_surface_container_light</color>
+ <color name="settingslib_materialColorSurfaceContainerLow">@android:color/system_surface_container_low_light</color>
+ <color name="settingslib_materialColorSurfaceContainerLowest">@android:color/system_surface_container_lowest_light</color>
+ <color name="settingslib_materialColorSurfaceContainerHigh">@android:color/system_surface_container_high_light</color>
+ <color name="settingslib_materialColorSurfaceContainerHighest">@android:color/system_surface_container_highest_light</color>
</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v35/colors.xml b/packages/SettingsLib/SettingsTheme/res/values-v35/colors.xml
index 90c19e1aa676..b1b37b12c572 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-v35/colors.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values-v35/colors.xml
@@ -54,49 +54,4 @@
<color name="settingslib_spinner_title_color">@color/settingslib_materialColorOnPrimaryContainer</color>
<!-- The text color of dropdown item title -->
<color name="settingslib_spinner_dropdown_color">@color/settingslib_materialColorOnPrimaryContainer</color>
-
- <color name="settingslib_materialColorOnSecondaryFixedVariant">@android:color/system_on_secondary_fixed_variant</color>
- <color name="settingslib_materialColorOnTertiaryFixedVariant">@android:color/system_on_tertiary_fixed_variant</color>
- <color name="settingslib_materialColorSurfaceContainerLowest">@android:color/system_surface_container_lowest_light</color>
- <color name="settingslib_materialColorOnPrimaryFixedVariant">@android:color/system_on_primary_fixed_variant</color>
- <color name="settingslib_materialColorOnSecondaryContainer">@android:color/system_on_secondary_container_light</color>
- <color name="settingslib_materialColorOnTertiaryContainer">@android:color/system_on_tertiary_container_light</color>
- <color name="settingslib_materialColorSurfaceContainerLow">@android:color/system_surface_container_low_light</color>
- <color name="settingslib_materialColorOnPrimaryContainer">@android:color/system_on_primary_container_light</color>
- <color name="settingslib_materialColorSecondaryFixedDim">@android:color/system_secondary_fixed_dim</color>
- <color name="settingslib_materialColorOnErrorContainer">@android:color/system_on_error_container_light</color>
- <color name="settingslib_materialColorOnSecondaryFixed">@android:color/system_on_secondary_fixed</color>
- <color name="settingslib_materialColorInverseOnSurface">@android:color/system_on_surface_dark</color>
- <color name="settingslib_materialColorTertiaryFixedDim">@android:color/system_tertiary_fixed_dim</color>
- <color name="settingslib_materialColorOnTertiaryFixed">@android:color/system_on_tertiary_fixed</color>
- <color name="settingslib_materialColorPrimaryFixedDim">@android:color/system_primary_fixed_dim</color>
- <color name="settingslib_materialColorSecondaryContainer">@android:color/system_secondary_container_light</color>
- <color name="settingslib_materialColorErrorContainer">@android:color/system_error_container_light</color>
- <color name="settingslib_materialColorOnPrimaryFixed">@android:color/system_on_primary_fixed</color>
- <color name="settingslib_materialColorInversePrimary">@android:color/system_primary_dark</color>
- <color name="settingslib_materialColorSecondaryFixed">@android:color/system_secondary_fixed</color>
- <color name="settingslib_materialColorInverseSurface">@android:color/system_surface_dark</color>
- <color name="settingslib_materialColorSurfaceVariant">@android:color/system_surface_variant_light</color>
- <color name="settingslib_materialColorTertiaryContainer">@android:color/system_tertiary_container_light</color>
- <color name="settingslib_materialColorTertiaryFixed">@android:color/system_tertiary_fixed</color>
- <color name="settingslib_materialColorPrimaryContainer">@android:color/system_primary_container_light</color>
- <color name="settingslib_materialColorOnBackground">@android:color/system_on_background_light</color>
- <color name="settingslib_materialColorPrimaryFixed">@android:color/system_primary_fixed</color>
- <color name="settingslib_materialColorOnSecondary">@android:color/system_on_secondary_light</color>
- <color name="settingslib_materialColorOnTertiary">@android:color/system_on_tertiary_light</color>
- <color name="settingslib_materialColorSurfaceDim">@android:color/system_surface_dim_light</color>
- <color name="settingslib_materialColorSurfaceBright">@android:color/system_surface_bright_light</color>
- <color name="settingslib_materialColorOnError">@android:color/system_on_error_light</color>
- <color name="settingslib_materialColorSurface">@android:color/system_surface_light</color>
- <color name="settingslib_materialColorSurfaceContainerHigh">@android:color/system_surface_container_high_light</color>
- <color name="settingslib_materialColorSurfaceContainerHighest">@android:color/system_surface_container_highest_light</color>
- <color name="settingslib_materialColorOnSurfaceVariant">@android:color/system_on_surface_variant_light</color>
- <color name="settingslib_materialColorOutline">@android:color/system_outline_light</color>
- <color name="settingslib_materialColorOutlineVariant">@android:color/system_outline_variant_light</color>
- <color name="settingslib_materialColorOnPrimary">@android:color/system_on_primary_light</color>
- <color name="settingslib_materialColorOnSurface">@android:color/system_on_surface_light</color>
- <color name="settingslib_materialColorSurfaceContainer">@android:color/system_surface_container_light</color>
- <color name="settingslib_materialColorPrimary">@android:color/system_primary_light</color>
- <color name="settingslib_materialColorSecondary">@android:color/system_secondary_light</color>
- <color name="settingslib_materialColorTertiary">@android:color/system_tertiary_light</color>
</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v35/styles_expressive.xml b/packages/SettingsLib/SettingsTheme/res/values-v35/styles_expressive.xml
index 05a1ceacdb65..1a085681864a 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-v35/styles_expressive.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values-v35/styles_expressive.xml
@@ -16,150 +16,6 @@
-->
<resources>
- <style name="SettingsLibTextAppearance" parent="@android:style/TextAppearance.DeviceDefault">
- <!--item name="android:fontFamily"></item-->
- <item name="android:hyphenationFrequency">normalFast</item>
- <item name="android:lineBreakWordStyle">phrase</item>
- </style>
-
- <style name="SettingsLibTextAppearance.Primary">
- <!--item name="android:fontFamily"></item-->
- </style>
-
- <style name="SettingsLibTextAppearance.Primary.Display">
- <!--item name="android:fontFamily"></item-->
- </style>
- <style name="SettingsLibTextAppearance.Primary.Display.Large">
- <item name="android:textSize">57sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Primary.Display.Medium">
- <item name="android:textSize">45sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Primary.Display.Small">
- <item name="android:textSize">36sp</item>
- </style>
-
- <style name="SettingsLibTextAppearance.Primary.Headline">
- <!--item name="android:fontFamily"></item-->
- </style>
- <style name="SettingsLibTextAppearance.Primary.Headline.Large">
- <item name="android:textSize">32sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Primary.Headline.Medium">
- <item name="android:textSize">28sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Primary.Headline.Small">
- <item name="android:textSize">24sp</item>
- </style>
-
- <style name="SettingsLibTextAppearance.Primary.Title">
- <!--item name="android:fontFamily"></item-->
- </style>
- <style name="SettingsLibTextAppearance.Primary.Title.Large">
- <item name="android:textSize">22sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Primary.Title.Medium">
- <item name="android:textSize">16sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Primary.Title.Small">
- <item name="android:textSize">14sp</item>
- </style>
-
- <style name="SettingsLibTextAppearance.Primary.Label">
- <!--item name="android:fontFamily"></item-->
- </style>
- <style name="SettingsLibTextAppearance.Primary.Label.Large">
- <item name="android:textSize">14sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Primary.Label.Medium">
- <item name="android:textSize">12sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Primary.Label.Small">
- <item name="android:textSize">11sp</item>
- </style>
-
- <style name="SettingsLibTextAppearance.Primary.Body">
- <!--item name="android:fontFamily"></item-->
- </style>
- <style name="SettingsLibTextAppearance.Primary.Body.Large">
- <item name="android:textSize">16sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Primary.Body.Medium">
- <item name="android:textSize">14sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Primary.Body.Small">
- <item name="android:textSize">12sp</item>
- </style>
-
- <style name="SettingsLibTextAppearance.Emphasized">
- <!--item name="android:fontFamily"></item-->
- </style>
-
- <style name="SettingsLibTextAppearance.Emphasized.Display">
- <!--item name="android:fontFamily"></item-->
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Display.Large">
- <item name="android:textSize">57sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Display.Medium">
- <item name="android:textSize">45sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Display.Small">
- <item name="android:textSize">36sp</item>
- </style>
-
- <style name="SettingsLibTextAppearance.Emphasized.Headline">
- <!--item name="android:fontFamily"></item-->
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Headline.Large">
- <item name="android:textSize">32sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Headline.Medium">
- <item name="android:textSize">28sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Headline.Small">
- <item name="android:textSize">24sp</item>
- </style>
-
- <style name="SettingsLibTextAppearance.Emphasized.Title">
- <!--item name="android:fontFamily"></item-->
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Title.Large">
- <item name="android:textSize">22sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Title.Medium">
- <item name="android:textSize">16sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Title.Small">
- <item name="android:textSize">14sp</item>
- </style>
-
- <style name="SettingsLibTextAppearance.Emphasized.Label">
- <!--item name="android:fontFamily"></item-->
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Label.Large">
- <item name="android:textSize">14sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Label.Medium">
- <item name="android:textSize">12sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Label.Small">
- <item name="android:textSize">11sp</item>
- </style>
-
- <style name="SettingsLibTextAppearance.Emphasized.Body">
- <!--item name="android:fontFamily"></item-->
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Body.Large">
- <item name="android:textSize">16sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Body.Medium">
- <item name="android:textSize">14sp</item>
- </style>
- <style name="SettingsLibTextAppearance.Emphasized.Body.Small">
- <item name="android:textSize">12sp</item>
- </style>
-
<style name="SettingslibSwitchStyle.Expressive" parent="">
<item name="android:layout_width">wrap_content</item>
<item name="android:layout_height">wrap_content</item>
@@ -175,122 +31,6 @@
<item name="trackTint">@color/settingslib_expressive_color_main_switch_track</item>
</style>
- <style name="SettingsLibCardStyle" parent="">
- <item name="android:layout_width">match_parent</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:layout_marginHorizontal">?android:attr/listPreferredItemPaddingStart</item>
- <item name="android:layout_marginVertical">@dimen/settingslib_expressive_space_extrasmall4</item>
- <item name="cardBackgroundColor">@color/settingslib_materialColorPrimary</item>
- <item name="cardCornerRadius">@dimen/settingslib_expressive_radius_extralarge3</item>
- <item name="cardElevation">0dp</item>
- <item name="rippleColor">?android:attr/colorControlHighlight</item>
- </style>
-
- <style name="SettingsLibButtonStyle.Expressive.Filled"
- parent="@style/Widget.Material3.Button">
- <item name="android:theme">@style/Theme.Material3.DynamicColors.DayNight</item>
- <item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:gravity">center</item>
- <item name="android:minWidth">@dimen/settingslib_expressive_space_medium4</item>
- <item name="android:minHeight">@dimen/settingslib_expressive_space_medium4</item>
- <item name="android:paddingVertical">@dimen/settingslib_expressive_space_extrasmall5</item>
- <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small1</item>
- <item name="android:backgroundTint">@color/settingslib_materialColorPrimary</item>
- <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Medium</item>
- <item name="android:textColor">@color/settingslib_materialColorOnPrimary</item>
- <item name="android:textSize">14sp</item>
- <item name="iconGravity">textStart</item>
- <item name="iconTint">@color/settingslib_materialColorOnPrimary</item>
- <item name="iconSize">@dimen/settingslib_expressive_space_small4</item>
- </style>
-
- <style name="SettingsLibButtonStyle.Expressive.Filled.Large">
- <item name="android:paddingVertical">@dimen/settingslib_expressive_space_small1</item>
- <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small4</item>
- <item name="android:textSize">16sp</item>
- </style>
-
- <style name="SettingsLibButtonStyle.Expressive.Filled.Extra"
- parent="@style/SettingsLibButtonStyle.Expressive.Filled.Large">
- <item name="android:layout_width">match_parent</item>
- </style>
-
- <style name="SettingsLibButtonStyle.Expressive.Tonal"
- parent="@style/Widget.Material3.Button.TonalButton">
- <item name="android:theme">@style/Theme.Material3.DynamicColors.DayNight</item>
- <item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:gravity">center</item>
- <item name="android:minWidth">@dimen/settingslib_expressive_space_medium4</item>
- <item name="android:minHeight">@dimen/settingslib_expressive_space_medium4</item>
- <item name="android:paddingVertical">@dimen/settingslib_expressive_space_extrasmall5</item>
- <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small1</item>
- <item name="android:backgroundTint">@color/settingslib_materialColorSecondaryContainer</item>
- <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Medium</item>
- <item name="android:textColor">@color/settingslib_materialColorOnSecondaryContainer</item>
- <item name="android:textSize">14sp</item>
- <item name="iconGravity">textStart</item>
- <item name="iconTint">@color/settingslib_materialColorOnSecondaryContainer</item>
- <item name="iconSize">@dimen/settingslib_expressive_space_small4</item>
- </style>
-
- <style name="SettingsLibButtonStyle.Expressive.Tonal.Large">
- <item name="android:paddingVertical">@dimen/settingslib_expressive_space_small1</item>
- <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small4</item>
- <item name="android:textSize">16sp</item>
- </style>
-
- <style name="SettingsLibButtonStyle.Expressive.Tonal.Extra"
- parent="@style/SettingsLibButtonStyle.Expressive.Tonal.Large">
- <item name="android:layout_width">match_parent</item>
- </style>
-
- <style name="SettingsLibButtonStyle.Expressive.Outline"
- parent="@style/Widget.Material3.Button.OutlinedButton.Icon">
- <item name="android:theme">@style/Theme.Material3.DynamicColors.DayNight</item>
- <item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:gravity">center</item>
- <item name="android:minWidth">@dimen/settingslib_expressive_space_medium4</item>
- <item name="android:minHeight">@dimen/settingslib_expressive_space_medium4</item>
- <item name="android:paddingVertical">@dimen/settingslib_expressive_space_extrasmall5</item>
- <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small1</item>
- <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Medium</item>
- <item name="android:textColor">@color/settingslib_materialColorPrimary</item>
- <item name="android:textSize">14sp</item>
- <item name="iconTint">@color/settingslib_materialColorPrimary</item>
- <item name="iconGravity">textStart</item>
- <item name="iconSize">@dimen/settingslib_expressive_space_small4</item>
- <item name="iconPadding">@dimen/settingslib_expressive_space_extrasmall4</item>
- <item name="strokeColor">@color/settingslib_materialColorOutlineVariant</item>
-
- </style>
-
- <style name="SettingsLibButtonStyle.Expressive.Outline.Large">
- <item name="android:paddingVertical">@dimen/settingslib_expressive_space_small1</item>
- <item name="android:paddingHorizontal">@dimen/settingslib_expressive_space_small4</item>
- <item name="android:textSize">16sp</item>
- </style>
-
- <style name="SettingsLibButtonStyle.Expressive.Outline.Extra"
- parent="@style/SettingsLibButtonStyle.Expressive.Outline.Large">
- <item name="android:layout_width">match_parent</item>
- </style>
-
- <style name="SettingslibTextButtonStyle.Expressive"
- parent="@style/Widget.Material3.Button.TextButton.Icon">
- <item name="android:theme">@style/Theme.Material3.DynamicColors.DayNight</item>
- <item name="android:layout_width">wrap_content</item>
- <item name="android:layout_height">wrap_content</item>
- <item name="android:textAppearance">@android:style/TextAppearance.DeviceDefault.Medium</item>
- <item name="android:textSize">16sp</item>
- <item name="android:textColor">@color/settingslib_materialColorOnSurface</item>
- <item name="iconTint">@null</item>
- <item name="iconPadding">@dimen/settingslib_expressive_space_extrasmall4</item>
- <item name="rippleColor">?android:attr/colorControlHighlight</item>
- </style>
-
<style name="EntityHeader">
<item name="android:paddingTop">@dimen/settingslib_expressive_space_small4</item>
<item name="android:paddingBottom">@dimen/settingslib_expressive_space_small1</item>
@@ -327,12 +67,11 @@
<item name="android:gravity">center</item>
<item name="android:ellipsize">marquee</item>
<item name="android:textDirection">locale</item>
- <item name="android:textAppearance">@style/TextAppearance.EntityHeaderTitle</item>
+ <item name="android:textAppearance">@style/TextAppearance.SettingsLib.TitleLarge.Emphasized</item>
</style>
<style name="SettingslibTextAppearance.LinkableTextStyle.Expressive"
- parent="@android:style/TextAppearance.DeviceDefault.WindowTitle">
- <item name="android:textSize">14sp</item>
+ parent="@style/TextAppearance.SettingsLib.LabelLarge">
<item name="android:textColor">?android:attr/colorAccent</item>
</style>
@@ -346,4 +85,14 @@
<item name="cardElevation">0dp</item>
<item name="rippleColor">?android:attr/colorControlHighlight</item>
</style>
+
+ <style name="TextAppearance.SettingsLib.PreferenceTitle"
+ parent="@style/TextAppearance.SettingsLib.TitleMedium">
+ <item name="android:textColor">@color/settingslib_text_color_primary</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.PreferenceSummary"
+ parent="@style/TextAppearance.SettingsLib.BodyMedium">
+ <item name="android:textColor">@color/settingslib_text_color_secondary</item>
+ </style>
</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v35/themes_expressive.xml b/packages/SettingsLib/SettingsTheme/res/values-v35/themes_expressive.xml
index fea8739ab37d..14f214a96435 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-v35/themes_expressive.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values-v35/themes_expressive.xml
@@ -18,8 +18,8 @@
<resources>
<style name="Theme.SettingsBase.Expressive">
<!-- Set up Preference title text style -->
- <!--item name="android:textAppearanceListItem">@style/TextAppearance.PreferenceTitle.SettingsLib</item-->
- <!--item name="android:textAppearanceListItemSecondary">@style/textAppearanceListItemSecondary</item-->
+ <item name="android:textAppearanceListItem">@style/TextAppearance.SettingsLib.PreferenceTitle</item>
+ <item name="android:textAppearanceListItemSecondary">@style/TextAppearance.SettingsLib.PreferenceSummary</item>
<!-- Set up list item padding -->
<item name="android:listPreferredItemPaddingStart">@dimen/settingslib_expressive_space_small1</item>
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v35/attrs_expressive.xml b/packages/SettingsLib/SettingsTheme/res/values/attrs_expressive.xml
index 857dd7953234..857dd7953234 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-v35/attrs_expressive.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values/attrs_expressive.xml
diff --git a/packages/SettingsLib/SettingsTheme/res/values/colors.xml b/packages/SettingsLib/SettingsTheme/res/values/colors.xml
new file mode 100644
index 000000000000..c5c613b4b329
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/values/colors.xml
@@ -0,0 +1,79 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+-->
+
+<resources>
+ <color name="settingslib_error_0">#FFFFFF</color>
+ <color name="settingslib_error_10">#FFFBFF</color>
+ <color name="settingslib_error_50">#FFEDEA</color>
+ <color name="settingslib_error_100">#FFDAD6</color>
+ <color name="settingslib_error_200">#FFB4AB</color>
+ <color name="settingslib_error_300">#FF897D</color>
+ <color name="settingslib_error_400">#FF5449</color>
+ <color name="settingslib_error_500">#DE3730</color>
+ <color name="settingslib_error_600">#BA1A1A</color>
+ <color name="settingslib_error_700">#93000A</color>
+ <color name="settingslib_error_800">#690005</color>
+ <color name="settingslib_error_900">#410002</color>
+ <color name="settingslib_error_1000">#000000</color>
+
+ <color name="settingslib_materialColorPrimary">#006B5F</color>
+ <color name="settingslib_materialColorOnPrimary">#FFFFFF</color>
+ <color name="settingslib_materialColorPrimaryContainer">#C5EAE2</color>
+ <color name="settingslib_materialColorOnPrimaryContainer">#00201C</color>
+ <color name="settingslib_materialColorPrimaryInverse">#83D6C7</color>
+ <color name="settingslib_materialColorPrimaryFixed">#C5EAE2</color>
+ <color name="settingslib_materialColorPrimaryFixedDim">#82D5C6</color>
+ <color name="settingslib_materialColorOnPrimaryFixed">#00201C</color>
+ <color name="settingslib_materialColorOnPrimaryFixedVariant">#005047</color>
+ <color name="settingslib_materialColorSecondary">#4A635E</color>
+ <color name="settingslib_materialColorOnSecondary">#FFFFFF</color>
+ <color name="settingslib_materialColorSecondaryContainer">#CCE8E2</color>
+ <color name="settingslib_materialColorOnSecondaryContainer">#051F1B</color>
+ <color name="settingslib_materialColorSecondaryFixed">#CCE8E2</color>
+ <color name="settingslib_materialColorSecondaryFixedDim">#B1CCC6</color>
+ <color name="settingslib_materialColorOnSecondaryFixed">#051F1B</color>
+ <color name="settingslib_materialColorOnSecondaryFixedVariant">#334C47</color>
+ <color name="settingslib_materialColorTertiary">#456179</color>
+ <color name="settingslib_materialColorOnTertiary">#FFFFFF</color>
+ <color name="settingslib_materialColorTertiaryContainer">#CBE6FF</color>
+ <color name="settingslib_materialColorOnTertiaryContainer">#001E31</color>
+ <color name="settingslib_materialColorTertiaryFixed">#CBE5FF</color>
+ <color name="settingslib_materialColorTertiaryFixedDim">#ADCAE5</color>
+ <color name="settingslib_materialColorOnTertiaryFixed">#001E31</color>
+ <color name="settingslib_materialColorOnTertiaryFixedVariant">#2D4A60</color>
+ <color name="settingslib_materialColorError">#B3261E</color>
+ <color name="settingslib_materialColorOnError">#FFFFFF</color>
+ <color name="settingslib_materialColorErrorContainer">#F9DEDC</color>
+ <color name="settingslib_materialColorOnErrorContainer">#3A0A08</color>
+ <color name="settingslib_materialColorOutline">#777777</color>
+ <color name="settingslib_materialColorOutlineVariant">#C7C6C5</color>
+ <color name="settingslib_materialColorBackground">#F9FAF8</color>
+ <color name="settingslib_materialColorOnBackground">#1B1B1B</color>
+ <color name="settingslib_materialColorSurface">#F9FAF8</color>
+ <color name="settingslib_materialColorOnSurface">#1B1B1B</color>
+ <color name="settingslib_materialColorSurfaceVariant">#E3E3E3</color>
+ <color name="settingslib_materialColorOnSurfaceVariant">#474747</color>
+ <color name="settingslib_materialColorSurfaceInverse">#303030</color>
+ <color name="settingslib_materialColorOnSurfaceInverse">#F1F1F1</color>
+ <color name="settingslib_materialColorSurfaceBright">#F9FAF8</color>
+ <color name="settingslib_materialColorSurfaceDim">#DADADA</color>
+ <color name="settingslib_materialColorSurfaceContainer">#EEEEEE</color>
+ <color name="settingslib_materialColorSurfaceContainerLow">#F4F4F4</color>
+ <color name="settingslib_materialColorSurfaceContainerLowest">#FFFFFF</color>
+ <color name="settingslib_materialColorSurfaceContainerHigh">#E8E8E8</color>
+ <color name="settingslib_materialColorSurfaceContainerHighest">#E3E3E3</color>
+</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/values/config.xml b/packages/SettingsLib/SettingsTheme/res/values/config.xml
index e73dcc0cc559..53da49180219 100644
--- a/packages/SettingsLib/SettingsTheme/res/values/config.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values/config.xml
@@ -16,4 +16,7 @@
-->
<resources xmlns:xliff="urn:oasis:names:tc:xliff:document:1.2">
<bool name="settingslib_config_icon_space_reserved">true</bool>
+
+ <!-- Name of a font family to use for headlines in SettingsLib. -->
+ <string name="settingslib_config_headlineFontFamily" translatable="false"></string>
</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/SettingsTheme/res/values-v35/dimens_expressive.xml b/packages/SettingsLib/SettingsTheme/res/values/dimens_expressive.xml
index 0542c510fa63..0542c510fa63 100644
--- a/packages/SettingsLib/SettingsTheme/res/values-v35/dimens_expressive.xml
+++ b/packages/SettingsLib/SettingsTheme/res/values/dimens_expressive.xml
diff --git a/packages/SettingsLib/SettingsTheme/res/values/styles_expressive.xml b/packages/SettingsLib/SettingsTheme/res/values/styles_expressive.xml
new file mode 100644
index 000000000000..f73e100906c8
--- /dev/null
+++ b/packages/SettingsLib/SettingsTheme/res/values/styles_expressive.xml
@@ -0,0 +1,253 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+ 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.
+ -->
+
+<resources xmlns:tools="http://schemas.android.com/tools">
+ <style name="TextAppearance.SettingsLib.DisplayLarge"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:fontFamily">@string/settingslib_config_headlineFontFamily</item>
+ <item name="android:textSize">57sp</item>
+ <item name="android:letterSpacing">-0.00438596</item>
+ <item name="android:lineHeight" tools:targetApi="28">64sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.DisplayMedium"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:fontFamily">@string/settingslib_config_headlineFontFamily</item>
+ <item name="android:textSize">45sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">52sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.DisplaySmall"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:fontFamily">@string/settingslib_config_headlineFontFamily</item>
+ <item name="android:textSize">36sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">44sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.HeadlineLarge"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:fontFamily">@string/settingslib_config_headlineFontFamily</item>
+ <item name="android:textSize">32sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">40sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.HeadlineMedium"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:fontFamily">@string/settingslib_config_headlineFontFamily</item>
+ <item name="android:textSize">28sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">36sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.HeadlineSmall"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:fontFamily">@string/settingslib_config_headlineFontFamily</item>
+ <item name="android:textSize">24sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">32sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.TitleLarge"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:fontFamily">@string/settingslib_config_headlineFontFamily</item>
+ <item name="android:textSize">22sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">28sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.TitleMedium"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textSize">16sp</item>
+ <item name="android:letterSpacing">0.009375</item>
+ <item name="android:lineHeight" tools:targetApi="28">24sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.TitleSmall"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.00714286</item>
+ <item name="android:lineHeight" tools:targetApi="28">20sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.LabelLarge"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.00714286</item>
+ <item name="android:lineHeight" tools:targetApi="28">20sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.LabelMedium"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textSize">12sp</item>
+ <item name="android:letterSpacing">0.04166667</item>
+ <item name="android:lineHeight" tools:targetApi="28">16sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.LabelSmall"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textSize">11sp</item>
+ <item name="android:letterSpacing">0.04545455</item>
+ <item name="android:lineHeight" tools:targetApi="28">16sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.BodyLarge"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textSize">16sp</item>
+ <item name="android:letterSpacing">0.03125</item>
+ <item name="android:lineHeight" tools:targetApi="28">24sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.BodyMedium"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.01785714</item>
+ <item name="android:lineHeight" tools:targetApi="28">20sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.BodySmall"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textSize">12sp</item>
+ <item name="android:letterSpacing">0.03333333</item>
+ <item name="android:lineHeight" tools:targetApi="28">16sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.DisplayLarge.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">57sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">64sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.DisplayMedium.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">45sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">52sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.DisplaySmall.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">36sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">44sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.HeadlineLarge.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">32sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">40sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.HeadlineMedium.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">28sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">36sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.HeadlineSmall.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">24sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">32sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.TitleLarge.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Widget.ActionBar.Title">
+ <item name="android:textSize">22sp</item>
+ <item name="android:letterSpacing">0</item>
+ <item name="android:lineHeight" tools:targetApi="28">28sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.TitleMedium.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">16sp</item>
+ <item name="android:letterSpacing">0.009375</item>
+ <item name="android:lineHeight" tools:targetApi="28">24sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.TitleSmall.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.00714286</item>
+ <item name="android:lineHeight" tools:targetApi="28">20sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.LabelLarge.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.00714286</item>
+ <item name="android:lineHeight" tools:targetApi="28">20sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.LabelMedium.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">12sp</item>
+ <item name="android:letterSpacing">0.04166667</item>
+ <item name="android:lineHeight" tools:targetApi="28">16sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.LabelSmall.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault">
+ <item name="android:textStyle">bold</item>
+ <item name="android:textSize">11sp</item>
+ <item name="android:letterSpacing">0.04545455</item>
+ <item name="android:lineHeight" tools:targetApi="28">16sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+
+ <style name="TextAppearance.SettingsLib.BodyLarge.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textStyle">normal</item>
+ <item name="android:textSize">16sp</item>
+ <item name="android:letterSpacing">0.009375</item>
+ <item name="android:lineHeight" tools:targetApi="28">24sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.BodyMedium.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textStyle">normal</item>
+ <item name="android:textSize">14sp</item>
+ <item name="android:letterSpacing">0.01785714</item>
+ <item name="android:lineHeight" tools:targetApi="28">20sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+ <style name="TextAppearance.SettingsLib.BodySmall.Emphasized"
+ parent="@android:style/TextAppearance.DeviceDefault.Medium">
+ <item name="android:textStyle">normal</item>
+ <item name="android:textSize">12sp</item>
+ <item name="android:letterSpacing">0.03333333</item>
+ <item name="android:lineHeight" tools:targetApi="28">16sp</item>
+ <item name="android:textAllCaps">false</item>
+ </style>
+</resources> \ No newline at end of file
diff --git a/packages/SettingsLib/StatusBannerPreference/res/layout/settingslib_expressive_preference_statusbanner.xml b/packages/SettingsLib/StatusBannerPreference/res/layout/settingslib_expressive_preference_statusbanner.xml
index 9a3e5b9e1e50..083b862e8a5c 100644
--- a/packages/SettingsLib/StatusBannerPreference/res/layout/settingslib_expressive_preference_statusbanner.xml
+++ b/packages/SettingsLib/StatusBannerPreference/res/layout/settingslib_expressive_preference_statusbanner.xml
@@ -72,7 +72,7 @@
android:layout_height="wrap_content"
android:hyphenationFrequency="normalFast"
android:lineBreakWordStyle="phrase"
- android:textAppearance="@style/SettingsLibTextAppearance.Emphasized.Title.Large"/>
+ android:textAppearance="@style/TextAppearance.SettingsLib.TitleLarge.Emphasized"/>
<TextView
android:id="@android:id/summary"
@@ -81,7 +81,7 @@
android:hyphenationFrequency="normalFast"
android:lineBreakWordStyle="phrase"
android:maxLines="3"
- android:textAppearance="@style/SettingsLibTextAppearance.Primary.Body.Medium"/>
+ android:textAppearance="@style/TextAppearance.SettingsLib.BodyMedium"/>
</LinearLayout>
</LinearLayout>
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/AmbientVolumeController.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/AmbientVolumeController.java
new file mode 100644
index 000000000000..7f0c1263570e
--- /dev/null
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/AmbientVolumeController.java
@@ -0,0 +1,415 @@
+/*
+ * 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.settingslib.bluetooth;
+
+import static android.bluetooth.AudioInputControl.MUTE_DISABLED;
+import static android.bluetooth.AudioInputControl.MUTE_MUTED;
+import static android.bluetooth.AudioInputControl.MUTE_NOT_MUTED;
+
+import static com.android.settingslib.bluetooth.HearingDeviceLocalDataManager.Data.INVALID_VOLUME;
+
+import android.bluetooth.AudioInputControl;
+import android.bluetooth.BluetoothDevice;
+import android.bluetooth.BluetoothProfile;
+import android.util.ArrayMap;
+import android.util.Log;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.Executor;
+
+/**
+ * AmbientVolumeController manages the {@link AudioInputControl}s of
+ * {@link AudioInputControl#AUDIO_INPUT_TYPE_AMBIENT} on the remote device.
+ */
+public class AmbientVolumeController implements LocalBluetoothProfileManager.ServiceListener {
+
+ private static final boolean DEBUG = true;
+ private static final String TAG = "AmbientController";
+
+ private final LocalBluetoothProfileManager mProfileManager;
+ private final VolumeControlProfile mVolumeControlProfile;
+ private final Map<BluetoothDevice, List<AudioInputControl>> mDeviceAmbientControlsMap =
+ new ArrayMap<>();
+ private final Map<BluetoothDevice, AmbientCallback> mDeviceCallbackMap = new ArrayMap<>();
+ final Map<BluetoothDevice, RemoteAmbientState> mDeviceAmbientStateMap =
+ new ArrayMap<>();
+ @Nullable
+ private final AmbientVolumeControlCallback mCallback;
+
+ public AmbientVolumeController(
+ @NonNull LocalBluetoothProfileManager profileManager,
+ @Nullable AmbientVolumeControlCallback callback) {
+ mProfileManager = profileManager;
+ mVolumeControlProfile = profileManager.getVolumeControlProfile();
+ if (mVolumeControlProfile != null && !mVolumeControlProfile.isProfileReady()) {
+ mProfileManager.addServiceListener(this);
+ }
+ mCallback = callback;
+ }
+
+ @Override
+ public void onServiceConnected() {
+ if (mVolumeControlProfile != null && mVolumeControlProfile.isProfileReady()) {
+ mProfileManager.removeServiceListener(this);
+ if (mCallback != null) {
+ mCallback.onVolumeControlServiceConnected();
+ }
+ }
+ }
+
+ @Override
+ public void onServiceDisconnected() {
+ // Do nothing
+ }
+
+ /**
+ * Registers the same {@link AmbientCallback} on all ambient control points of the remote
+ * device. The {@link AmbientCallback} will pass the event to registered
+ * {@link AmbientVolumeControlCallback} if exists.
+ *
+ * @param executor the executor to run the callback
+ * @param device the remote device
+ */
+ public void registerCallback(@NonNull Executor executor, @NonNull BluetoothDevice device) {
+ AmbientCallback ambientCallback = new AmbientCallback(device, mCallback);
+ synchronized (mDeviceCallbackMap) {
+ mDeviceCallbackMap.put(device, ambientCallback);
+ }
+
+ // register callback on all ambient input control points of this device
+ List<AudioInputControl> controls = getAmbientControls(device);
+ controls.forEach((control) -> {
+ try {
+ control.registerCallback(executor, ambientCallback);
+ } catch (IllegalArgumentException e) {
+ // The callback was already registered
+ Log.i(TAG, "Skip registering the callback, " + e.getMessage());
+ }
+ });
+ }
+
+ /**
+ * Unregisters the {@link AmbientCallback} on all ambient control points of the remote
+ * device which is previously registered with {@link #registerCallback}.
+ *
+ * @param device the remote device
+ */
+ public void unregisterCallback(@NonNull BluetoothDevice device) {
+ AmbientCallback ambientCallback;
+ synchronized (mDeviceCallbackMap) {
+ ambientCallback = mDeviceCallbackMap.remove(device);
+ }
+ if (ambientCallback == null) {
+ // callback not found, no need to unregister
+ return;
+ }
+
+ // unregister callback on all ambient input control points of this device
+ List<AudioInputControl> controls = getAmbientControls(device);
+ controls.forEach(control -> {
+ try {
+ control.unregisterCallback(ambientCallback);
+ } catch (IllegalArgumentException e) {
+ // The callback was never registered or was already unregistered
+ Log.i(TAG, "Skip unregistering the callback, " + e.getMessage());
+ }
+ });
+ }
+
+ /**
+ * Gets the gain setting max value from first ambient control point of the remote device.
+ *
+ * @param device the remote device
+ */
+ public int getAmbientMax(@NonNull BluetoothDevice device) {
+ List<AudioInputControl> ambientControls = getAmbientControls(device);
+ int value = INVALID_VOLUME;
+ if (!ambientControls.isEmpty()) {
+ value = ambientControls.getFirst().getGainSettingMax();
+ }
+ return value;
+ }
+
+ /**
+ * Gets the gain setting min value from first ambient control point of the remote device.
+ *
+ * @param device the remote device
+ */
+ public int getAmbientMin(@NonNull BluetoothDevice device) {
+ List<AudioInputControl> ambientControls = getAmbientControls(device);
+ int value = INVALID_VOLUME;
+ if (!ambientControls.isEmpty()) {
+ value = ambientControls.getFirst().getGainSettingMin();
+ }
+ return value;
+ }
+
+ /**
+ * Gets the latest values in {@link RemoteAmbientState}.
+ *
+ * @param device the remote device
+ * @return the {@link RemoteAmbientState} represents current remote ambient control point state
+ */
+ @Nullable
+ public RemoteAmbientState refreshAmbientState(@Nullable BluetoothDevice device) {
+ if (device == null || !device.isConnected()) {
+ return null;
+ }
+ int gainSetting = getAmbient(device);
+ int mute = getMute(device);
+ return new RemoteAmbientState(gainSetting, mute);
+ }
+
+ /**
+ * Gets the gain setting value from first ambient control point of the remote device and
+ * stores it in cached {@link RemoteAmbientState}.
+ *
+ * When any audio input point receives {@link AmbientCallback#onGainSettingChanged(int)}
+ * callback, only the changed value which is different from the value stored in the cached
+ * state will be notified to the {@link AmbientVolumeControlCallback} of this controller.
+ *
+ * @param device the remote device
+ */
+ public int getAmbient(@NonNull BluetoothDevice device) {
+ List<AudioInputControl> ambientControls = getAmbientControls(device);
+ int value = INVALID_VOLUME;
+ if (!ambientControls.isEmpty()) {
+ synchronized (mDeviceAmbientStateMap) {
+ value = ambientControls.getFirst().getGainSetting();
+ RemoteAmbientState state = mDeviceAmbientStateMap.getOrDefault(device,
+ new RemoteAmbientState(INVALID_VOLUME, MUTE_DISABLED));
+ RemoteAmbientState updatedState = new RemoteAmbientState(value, state.mute);
+ mDeviceAmbientStateMap.put(device, updatedState);
+ }
+ }
+ return value;
+ }
+
+ /**
+ * Sets the gain setting value to all ambient control points of the remote device.
+ *
+ * @param device the remote device
+ * @param value the gain setting value to be updated
+ */
+ public void setAmbient(@NonNull BluetoothDevice device, int value) {
+ if (DEBUG) {
+ Log.d(TAG, "setAmbient, value:" + value + ", device:" + device);
+ }
+ List<AudioInputControl> ambientControls = getAmbientControls(device);
+ ambientControls.forEach(control -> control.setGainSetting(value));
+ }
+
+ /**
+ * Gets the mute state from first ambient control point of the remote device and
+ * stores it in cached {@link RemoteAmbientState}. The value will be one of
+ * {@link AudioInputControl.Mute}.
+ *
+ * When any audio input point receives {@link AmbientCallback#onMuteChanged(int)} callback,
+ * only the changed value which is different from the value stored in the cached state will
+ * be notified to the {@link AmbientVolumeControlCallback} of this controller.
+ *
+ * @param device the remote device
+ */
+ public int getMute(@NonNull BluetoothDevice device) {
+ List<AudioInputControl> ambientControls = getAmbientControls(device);
+ int value = MUTE_DISABLED;
+ if (!ambientControls.isEmpty()) {
+ synchronized (mDeviceAmbientStateMap) {
+ value = ambientControls.getFirst().getMute();
+ RemoteAmbientState state = mDeviceAmbientStateMap.getOrDefault(device,
+ new RemoteAmbientState(INVALID_VOLUME, MUTE_DISABLED));
+ RemoteAmbientState updatedState = new RemoteAmbientState(state.gainSetting, value);
+ mDeviceAmbientStateMap.put(device, updatedState);
+ }
+ }
+ return value;
+ }
+
+ /**
+ * Sets the mute state to all ambient control points of the remote device.
+ *
+ * @param device the remote device
+ * @param muted the mute state to be updated
+ */
+ public void setMuted(@NonNull BluetoothDevice device, boolean muted) {
+ if (DEBUG) {
+ Log.d(TAG, "setMuted, muted:" + muted + ", device:" + device);
+ }
+ List<AudioInputControl> ambientControls = getAmbientControls(device);
+ ambientControls.forEach(control -> {
+ try {
+ control.setMute(muted ? MUTE_MUTED : MUTE_NOT_MUTED);
+ } catch (IllegalStateException e) {
+ // Sometimes remote will throw this exception due to initialization not done
+ // yet. Catch it to prevent crashes on UI.
+ Log.w(TAG, "Remote mute state is currently disabled.");
+ }
+ });
+ }
+
+ /**
+ * Checks if there's any valid ambient control point exists on the remote device
+ *
+ * @param device the remote device
+ */
+ public boolean isAmbientControlAvailable(@NonNull BluetoothDevice device) {
+ final boolean hasAmbientControlPoint = !getAmbientControls(device).isEmpty();
+ final boolean connectedToVcp = mVolumeControlProfile.getConnectionStatus(device)
+ == BluetoothProfile.STATE_CONNECTED;
+ return hasAmbientControlPoint && connectedToVcp;
+ }
+
+ @NonNull
+ private List<AudioInputControl> getAmbientControls(@NonNull BluetoothDevice device) {
+ if (mVolumeControlProfile == null) {
+ return Collections.emptyList();
+ }
+ synchronized (mDeviceAmbientControlsMap) {
+ if (mDeviceAmbientControlsMap.containsKey(device)) {
+ return mDeviceAmbientControlsMap.get(device);
+ }
+ List<AudioInputControl> ambientControls =
+ mVolumeControlProfile.getAudioInputControlServices(device).stream().filter(
+ this::isValidAmbientControl).toList();
+ if (!ambientControls.isEmpty()) {
+ mDeviceAmbientControlsMap.put(device, ambientControls);
+ }
+ return ambientControls;
+ }
+ }
+
+ private boolean isValidAmbientControl(AudioInputControl control) {
+ boolean isAmbientControl =
+ control.getAudioInputType() == AudioInputControl.AUDIO_INPUT_TYPE_AMBIENT;
+ boolean isManual = control.getGainMode() == AudioInputControl.GAIN_MODE_MANUAL
+ || control.getGainMode() == AudioInputControl.GAIN_MODE_MANUAL_ONLY;
+ boolean isActive =
+ control.getAudioInputStatus() == AudioInputControl.AUDIO_INPUT_STATUS_ACTIVE;
+
+ return isAmbientControl && isManual && isActive;
+ }
+
+ /**
+ * Callback providing information about the status and received events of
+ * {@link AmbientVolumeController}.
+ */
+ public interface AmbientVolumeControlCallback {
+
+ /** This method is called when the Volume Control Service is connected */
+ default void onVolumeControlServiceConnected() {
+ }
+
+ /**
+ * This method is called when one of the remote device's ambient control point's gain
+ * settings value is changed.
+ *
+ * @param device the remote device
+ * @param gainSettings the new gain setting value
+ */
+ default void onAmbientChanged(@NonNull BluetoothDevice device, int gainSettings) {
+ }
+
+ /**
+ * This method is called when one of the remote device's ambient control point's mute
+ * state is changed.
+ *
+ * @param device the remote device
+ * @param mute the new mute state
+ */
+ default void onMuteChanged(@NonNull BluetoothDevice device, int mute) {
+ }
+
+ /**
+ * This method is called when any command to the remote device's ambient control point
+ * is failed.
+ *
+ * @param device the remote device.
+ */
+ default void onCommandFailed(@NonNull BluetoothDevice device) {
+ }
+ }
+
+ /**
+ * A wrapper callback that will pass {@link AudioInputControl.AudioInputCallback} with extra
+ * device information to {@link AmbientVolumeControlCallback}.
+ */
+ class AmbientCallback implements AudioInputControl.AudioInputCallback {
+
+ private final BluetoothDevice mDevice;
+ private final AmbientVolumeControlCallback mCallback;
+
+ AmbientCallback(@NonNull BluetoothDevice device,
+ @Nullable AmbientVolumeControlCallback callback) {
+ mDevice = device;
+ mCallback = callback;
+ }
+
+ @Override
+ public void onGainSettingChanged(int gainSetting) {
+ if (mCallback != null) {
+ synchronized (mDeviceAmbientStateMap) {
+ RemoteAmbientState previousState = mDeviceAmbientStateMap.get(mDevice);
+ if (previousState.gainSetting != gainSetting) {
+ mCallback.onAmbientChanged(mDevice, gainSetting);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onSetGainSettingFailed() {
+ Log.w(TAG, "onSetGainSettingFailed, device=" + mDevice);
+ if (mCallback != null) {
+ mCallback.onCommandFailed(mDevice);
+ }
+ }
+
+ @Override
+ public void onMuteChanged(int mute) {
+ if (mCallback != null) {
+ synchronized (mDeviceAmbientStateMap) {
+ RemoteAmbientState previousState = mDeviceAmbientStateMap.get(mDevice);
+ if (previousState.mute != mute) {
+ mCallback.onMuteChanged(mDevice, mute);
+ }
+ }
+ }
+ }
+
+ @Override
+ public void onSetMuteFailed() {
+ Log.w(TAG, "onSetMuteFailed, device=" + mDevice);
+ if (mCallback != null) {
+ mCallback.onCommandFailed(mDevice);
+ }
+ }
+ }
+
+ public record RemoteAmbientState(int gainSetting, int mute) {
+ public boolean isMutable() {
+ return mute != MUTE_DISABLED;
+ }
+ public boolean isMuted() {
+ return mute == MUTE_MUTED;
+ }
+ }
+}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index b58983ff1ce8..257c93505cfc 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -1591,6 +1591,12 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
private int getHearingDeviceSummaryRes(int leftBattery, int rightBattery,
boolean shortSummary) {
+ if (getDeviceSide() == HearingAidInfo.DeviceSide.SIDE_MONO
+ || getDeviceSide() == HearingAidInfo.DeviceSide.SIDE_LEFT_AND_RIGHT) {
+ return !shortSummary && (getBatteryLevel() > BluetoothDevice.BATTERY_LEVEL_UNKNOWN)
+ ? R.string.bluetooth_active_battery_level
+ : R.string.bluetooth_active_no_battery_level;
+ }
boolean isLeftDeviceConnected = getConnectedHearingAidSide(
HearingAidInfo.DeviceSide.SIDE_LEFT).isPresent();
boolean isRightDeviceConnected = getConnectedHearingAidSide(
@@ -1646,8 +1652,7 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
@HearingAidInfo.DeviceSide int side) {
return Stream.concat(Stream.of(this, mSubDevice), mMemberDevices.stream())
.filter(Objects::nonNull)
- .filter(device -> device.getDeviceSide() == side
- || device.getDeviceSide() == HearingAidInfo.DeviceSide.SIDE_LEFT_AND_RIGHT)
+ .filter(device -> device.getDeviceSide() == side)
.filter(device -> device.getDevice().isConnected())
// For hearing aids, we should expect only one device assign to one side, but if
// it happens, we don't care which one.
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
index 7fdb32cb63e9..b754706fb9a1 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManager.java
@@ -153,7 +153,7 @@ public class CachedBluetoothDeviceManager {
/**
* Returns device summary of the pair of the hearing aid / CSIP passed as the parameter.
*
- * @param CachedBluetoothDevice device
+ * @param device the remote device
* @return Device summary, or if the pair does not exist or if it is not a hearing aid or
* a CSIP set member, then {@code null}.
*/
@@ -394,6 +394,7 @@ public class CachedBluetoothDeviceManager {
}
public synchronized void onDeviceUnpaired(CachedBluetoothDevice device) {
+ mHearingAidDeviceManager.clearLocalDataIfNeeded(device);
device.setGroupId(BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
CachedBluetoothDevice mainDevice = mCsipDeviceManager.findMainDevice(device);
// Should iterate through the cloned set to avoid ConcurrentModificationException
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidDeviceManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidDeviceManager.java
index fa28cf6c8a76..1ca4c2b39a70 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidDeviceManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidDeviceManager.java
@@ -18,7 +18,6 @@ package com.android.settingslib.bluetooth;
import android.bluetooth.BluetoothCsipSetCoordinator;
import android.bluetooth.BluetoothHapClient;
import android.bluetooth.BluetoothHearingAid;
-import android.bluetooth.BluetoothLeAudio;
import android.bluetooth.BluetoothProfile;
import android.bluetooth.BluetoothUuid;
import android.bluetooth.le.ScanFilter;
@@ -308,6 +307,10 @@ public class HearingAidDeviceManager {
}
}
+ void clearLocalDataIfNeeded(CachedBluetoothDevice device) {
+ HearingDeviceLocalDataManager.clear(mContext, device.getDevice());
+ }
+
private void setAudioRoutingConfig(CachedBluetoothDevice device) {
AudioDeviceAttributes hearingDeviceAttributes =
mRoutingHelper.getMatchedHearingDeviceAttributes(device);
@@ -428,8 +431,7 @@ public class HearingAidDeviceManager {
p -> p instanceof HapClientProfile)) {
int audioLocation = leAudioProfile.getAudioLocation(cachedDevice.getDevice());
int hearingAidType = hapClientProfile.getHearingAidType(cachedDevice.getDevice());
- if (audioLocation != BluetoothLeAudio.AUDIO_LOCATION_INVALID
- && hearingAidType != HapClientProfile.HearingAidType.TYPE_INVALID) {
+ if (hearingAidType != HapClientProfile.HearingAidType.TYPE_INVALID) {
final HearingAidInfo info = new HearingAidInfo.Builder()
.setLeAudioLocation(audioLocation)
.setHapDeviceType(hearingAidType)
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidInfo.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidInfo.java
index ef08c924b844..8399824f11e9 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidInfo.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingAidInfo.java
@@ -34,6 +34,7 @@ public class HearingAidInfo {
DeviceSide.SIDE_LEFT,
DeviceSide.SIDE_RIGHT,
DeviceSide.SIDE_LEFT_AND_RIGHT,
+ DeviceSide.SIDE_MONO
})
/** Side definition for hearing aids. */
@@ -42,6 +43,7 @@ public class HearingAidInfo {
int SIDE_LEFT = 0;
int SIDE_RIGHT = 1;
int SIDE_LEFT_AND_RIGHT = 2;
+ int SIDE_MONO = 3;
}
@Retention(java.lang.annotation.RetentionPolicy.SOURCE)
@@ -124,6 +126,9 @@ public class HearingAidInfo {
@DeviceSide
private static int convertLeAudioLocationToInternalSide(int leAudioLocation) {
+ if (leAudioLocation == BluetoothLeAudio.AUDIO_LOCATION_MONO) {
+ return DeviceSide.SIDE_MONO;
+ }
boolean isLeft = (leAudioLocation & LE_AUDIO_LOCATION_LEFT) != 0;
boolean isRight = (leAudioLocation & LE_AUDIO_LOCATION_RIGHT) != 0;
if (isLeft && isRight) {
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingDeviceLocalDataManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingDeviceLocalDataManager.java
index 7a64965334c9..6725558cd2bd 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingDeviceLocalDataManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/HearingDeviceLocalDataManager.java
@@ -86,6 +86,17 @@ public class HearingDeviceLocalDataManager {
mSettingsObserver = new SettingsObserver(ThreadUtils.getUiThreadHandler());
}
+ /**
+ * Clears the local data of the device. This method should be called when the device is
+ * unpaired.
+ */
+ public static void clear(@NonNull Context context, @NonNull BluetoothDevice device) {
+ HearingDeviceLocalDataManager manager = new HearingDeviceLocalDataManager(context);
+ manager.getLocalDataFromSettings();
+ manager.remove(device);
+ manager.putAmbientVolumeSettings();
+ }
+
/** Starts the manager. Loads the data from Settings and start observing any changes. */
public synchronized void start() {
if (mIsStarted) {
@@ -141,6 +152,7 @@ public class HearingDeviceLocalDataManager {
* Puts the local data of the corresponding hearing device.
*
* @param device the device to update the local data
+ * @param data the local data to be stored
*/
private void put(BluetoothDevice device, Data data) {
if (device == null) {
@@ -148,7 +160,11 @@ public class HearingDeviceLocalDataManager {
}
synchronized (sLock) {
final String addr = device.getAnonymizedAddress();
- mAddrToDataMap.put(addr, data);
+ if (data == null) {
+ mAddrToDataMap.remove(addr);
+ } else {
+ mAddrToDataMap.put(addr, data);
+ }
if (mListener != null && mListenerExecutor != null) {
mListenerExecutor.execute(() -> mListener.onDeviceLocalDataChange(addr, data));
}
@@ -156,6 +172,24 @@ public class HearingDeviceLocalDataManager {
}
/**
+ * Removes the local data of the corresponding hearing device.
+ *
+ * @param device the device to remove the local data
+ */
+ private void remove(BluetoothDevice device) {
+ if (device == null) {
+ return;
+ }
+ synchronized (sLock) {
+ final String addr = device.getAnonymizedAddress();
+ mAddrToDataMap.remove(addr);
+ if (mListener != null && mListenerExecutor != null) {
+ mListenerExecutor.execute(() -> mListener.onDeviceLocalDataChange(addr, null));
+ }
+ }
+ }
+
+ /**
* Updates the ambient volume of the corresponding hearing device. This should be called after
* {@link #start()} is called().
*
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/AmbientVolumeControllerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/AmbientVolumeControllerTest.java
new file mode 100644
index 000000000000..abc1d226972b
--- /dev/null
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/AmbientVolumeControllerTest.java
@@ -0,0 +1,318 @@
+/*
+ * 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.settingslib.bluetooth;
+
+import static com.google.common.truth.Truth.assertThat;
+
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+import android.bluetooth.AudioInputControl;
+import android.bluetooth.BluetoothDevice;
+import android.content.Context;
+
+import androidx.test.core.app.ApplicationProvider;
+
+import org.junit.Before;
+import org.junit.Rule;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.junit.MockitoJUnit;
+import org.mockito.junit.MockitoRule;
+import org.robolectric.RobolectricTestRunner;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.Executor;
+
+/** Tests for {@link AmbientVolumeController}. */
+@RunWith(RobolectricTestRunner.class)
+public class AmbientVolumeControllerTest {
+
+ @Rule
+ public MockitoRule mMockitoRule = MockitoJUnit.rule();
+
+ private static final String TEST_ADDRESS = "00:00:00:00:11";
+
+ @Mock
+ private LocalBluetoothProfileManager mProfileManager;
+ @Mock
+ private VolumeControlProfile mVolumeControlProfile;
+ @Mock
+ private AmbientVolumeController.AmbientVolumeControlCallback mCallback;
+ @Mock
+ private BluetoothDevice mDevice;
+
+ private final Context mContext = ApplicationProvider.getApplicationContext();
+ private AmbientVolumeController mVolumeController;
+
+ @Before
+ public void setUp() {
+ when(mProfileManager.getVolumeControlProfile()).thenReturn(mVolumeControlProfile);
+ when(mDevice.getAddress()).thenReturn(TEST_ADDRESS);
+ when(mDevice.isConnected()).thenReturn(true);
+ mVolumeController = new AmbientVolumeController(mProfileManager, mCallback);
+ }
+
+ @Test
+ public void onServiceConnected_notifyCallback() {
+ when(mVolumeControlProfile.isProfileReady()).thenReturn(true);
+
+ mVolumeController.onServiceConnected();
+
+ verify(mCallback).onVolumeControlServiceConnected();
+ }
+
+ @Test
+ public void isAmbientControlAvailable_validControls_assertTrue() {
+ prepareValidAmbientControls();
+
+ assertThat(mVolumeController.isAmbientControlAvailable(mDevice)).isTrue();
+ }
+
+ @Test
+ public void isAmbientControlAvailable_streamingControls_assertFalse() {
+ prepareStreamingControls();
+
+ assertThat(mVolumeController.isAmbientControlAvailable(mDevice)).isFalse();
+ }
+
+ @Test
+ public void isAmbientControlAvailable_automaticAmbientControls_assertFalse() {
+ prepareAutomaticAmbientControls();
+
+ assertThat(mVolumeController.isAmbientControlAvailable(mDevice)).isFalse();
+ }
+
+ @Test
+ public void isAmbientControlAvailable_inactiveAmbientControls_assertFalse() {
+ prepareInactiveAmbientControls();
+
+ assertThat(mVolumeController.isAmbientControlAvailable(mDevice)).isFalse();
+ }
+
+ @Test
+ public void registerCallback_verifyRegisterOnAllControls() {
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+
+ mVolumeController.registerCallback(mContext.getMainExecutor(), mDevice);
+
+ for (AudioInputControl control : controls) {
+ verify(control).registerCallback(any(Executor.class), any());
+ }
+ }
+
+ @Test
+ public void unregisterCallback_verifyUnregisterOnAllControls() {
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+
+ mVolumeController.registerCallback(mContext.getMainExecutor(), mDevice);
+ mVolumeController.unregisterCallback(mDevice);
+
+ for (AudioInputControl control : controls) {
+ verify(control).unregisterCallback(any());
+ }
+ }
+
+ @Test
+ public void getAmbientMax_verifyGetOnFirstControl() {
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+
+ mVolumeController.getAmbientMax(mDevice);
+
+ verify(controls.getFirst()).getGainSettingMax();
+ }
+
+ @Test
+ public void getAmbientMin_verifyGetOnFirstControl() {
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+
+ mVolumeController.getAmbientMin(mDevice);
+
+ verify(controls.getFirst()).getGainSettingMin();
+ }
+
+ @Test
+ public void getAmbient_verifyGetOnFirstControl() {
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+
+ mVolumeController.getAmbient(mDevice);
+
+ verify(controls.getFirst()).getGainSetting();
+ }
+
+ @Test
+ public void setAmbient_verifySetOnAllControls() {
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+
+ mVolumeController.setAmbient(mDevice, 10);
+
+ for (AudioInputControl control : controls) {
+ verify(control).setGainSetting(10);
+ }
+ }
+
+ @Test
+ public void getMute_verifyGetOnFirstControl() {
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+
+ mVolumeController.getMute(mDevice);
+
+ verify(controls.getFirst()).getMute();
+ }
+
+ @Test
+ public void setMuted_true_verifySetOnAllControls() {
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+
+ mVolumeController.setMuted(mDevice, true);
+
+ for (AudioInputControl control : controls) {
+ verify(control).setMute(AudioInputControl.MUTE_MUTED);
+ }
+ }
+
+ @Test
+ public void setMuted_false_verifySetOnAllControls() {
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+
+ mVolumeController.setMuted(mDevice, false);
+
+ for (AudioInputControl control : controls) {
+ verify(control).setMute(AudioInputControl.MUTE_NOT_MUTED);
+ }
+ }
+
+ @Test
+ public void ambientCallback_onGainSettingChanged_verifyCallbackIsCalledWhenStateChange() {
+ AmbientVolumeController.AmbientCallback ambientCallback =
+ mVolumeController.new AmbientCallback(mDevice, mCallback);
+ final int testAmbient = 10;
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+ when(controls.getFirst().getGainSetting()).thenReturn(testAmbient);
+
+ mVolumeController.refreshAmbientState(mDevice);
+ ambientCallback.onGainSettingChanged(testAmbient);
+ verify(mCallback, never()).onAmbientChanged(mDevice, testAmbient);
+
+ final int updatedTestAmbient = 20;
+ ambientCallback.onGainSettingChanged(updatedTestAmbient);
+ verify(mCallback).onAmbientChanged(mDevice, updatedTestAmbient);
+ }
+
+
+ @Test
+ public void ambientCallback_onSetAmbientFailed_verifyCallbackIsCalled() {
+ AmbientVolumeController.AmbientCallback ambientCallback =
+ mVolumeController.new AmbientCallback(mDevice, mCallback);
+
+ ambientCallback.onSetGainSettingFailed();
+
+ verify(mCallback).onCommandFailed(mDevice);
+ }
+
+ @Test
+ public void ambientCallback_onMuteChanged_verifyCallbackIsCalledWhenStateChange() {
+ AmbientVolumeController.AmbientCallback ambientCallback =
+ mVolumeController.new AmbientCallback(mDevice, mCallback);
+ final int testMute = 0;
+ List<AudioInputControl> controls = prepareValidAmbientControls();
+ when(controls.getFirst().getMute()).thenReturn(testMute);
+
+ mVolumeController.refreshAmbientState(mDevice);
+ ambientCallback.onMuteChanged(testMute);
+ verify(mCallback, never()).onMuteChanged(mDevice, testMute);
+
+ final int updatedTestMute = 1;
+ ambientCallback.onMuteChanged(updatedTestMute);
+ verify(mCallback).onMuteChanged(mDevice, updatedTestMute);
+ }
+
+ @Test
+ public void ambientCallback_onSetMuteFailed_verifyCallbackIsCalled() {
+ AmbientVolumeController.AmbientCallback ambientCallback =
+ mVolumeController.new AmbientCallback(mDevice, mCallback);
+
+ ambientCallback.onSetMuteFailed();
+
+ verify(mCallback).onCommandFailed(mDevice);
+ }
+
+ private List<AudioInputControl> prepareValidAmbientControls() {
+ List<AudioInputControl> controls = new ArrayList<>();
+ final int controlsCount = 2;
+ for (int i = 0; i < controlsCount; i++) {
+ controls.add(prepareAudioInputControl(
+ AudioInputControl.AUDIO_INPUT_TYPE_AMBIENT,
+ AudioInputControl.GAIN_MODE_MANUAL,
+ AudioInputControl.AUDIO_INPUT_STATUS_ACTIVE));
+ }
+ when(mVolumeControlProfile.getAudioInputControlServices(mDevice)).thenReturn(controls);
+ return controls;
+ }
+
+ private List<AudioInputControl> prepareStreamingControls() {
+ List<AudioInputControl> controls = new ArrayList<>();
+ final int controlsCount = 2;
+ for (int i = 0; i < controlsCount; i++) {
+ controls.add(prepareAudioInputControl(
+ AudioInputControl.AUDIO_INPUT_TYPE_STREAMING,
+ AudioInputControl.GAIN_MODE_MANUAL,
+ AudioInputControl.AUDIO_INPUT_STATUS_ACTIVE));
+ }
+ when(mVolumeControlProfile.getAudioInputControlServices(mDevice)).thenReturn(controls);
+ return controls;
+ }
+
+ private List<AudioInputControl> prepareAutomaticAmbientControls() {
+ List<AudioInputControl> controls = new ArrayList<>();
+ final int controlsCount = 2;
+ for (int i = 0; i < controlsCount; i++) {
+ controls.add(prepareAudioInputControl(
+ AudioInputControl.AUDIO_INPUT_TYPE_STREAMING,
+ AudioInputControl.GAIN_MODE_AUTOMATIC,
+ AudioInputControl.AUDIO_INPUT_STATUS_ACTIVE));
+ }
+ when(mVolumeControlProfile.getAudioInputControlServices(mDevice)).thenReturn(controls);
+ return controls;
+ }
+
+ private List<AudioInputControl> prepareInactiveAmbientControls() {
+ List<AudioInputControl> controls = new ArrayList<>();
+ final int controlsCount = 2;
+ for (int i = 0; i < controlsCount; i++) {
+ controls.add(prepareAudioInputControl(
+ AudioInputControl.AUDIO_INPUT_TYPE_STREAMING,
+ AudioInputControl.GAIN_MODE_AUTOMATIC,
+ AudioInputControl.AUDIO_INPUT_STATUS_INACTIVE));
+ }
+ when(mVolumeControlProfile.getAudioInputControlServices(mDevice)).thenReturn(controls);
+ return controls;
+ }
+
+ private AudioInputControl prepareAudioInputControl(int type, int mode, int status) {
+ AudioInputControl control = mock(AudioInputControl.class);
+ when(control.getAudioInputType()).thenReturn(type);
+ when(control.getGainMode()).thenReturn(mode);
+ when(control.getAudioInputStatus()).thenReturn(status);
+ return control;
+ }
+}
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
index 8cc997414d70..05f471f62f1d 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceManagerTest.java
@@ -139,6 +139,11 @@ public class CachedBluetoothDeviceManagerTest {
mCachedDevice1 = spy(new CachedBluetoothDevice(mContext, mLocalProfileManager, mDevice1));
mCachedDevice2 = spy(new CachedBluetoothDevice(mContext, mLocalProfileManager, mDevice2));
mCachedDevice3 = spy(new CachedBluetoothDevice(mContext, mLocalProfileManager, mDevice3));
+
+ mHearingAidDeviceManager = spy(new HearingAidDeviceManager(mContext, mLocalBluetoothManager,
+ mCachedDeviceManager.mCachedDevices));
+ mCachedDeviceManager.mHearingAidDeviceManager = mHearingAidDeviceManager;
+ doNothing().when(mHearingAidDeviceManager).clearLocalDataIfNeeded(any());
}
/**
@@ -338,6 +343,8 @@ public class CachedBluetoothDeviceManagerTest {
// Call onDeviceUnpaired for the one in mCachedDevices.
mCachedDeviceManager.onDeviceUnpaired(cachedDevice2);
+
+ verify(mHearingAidDeviceManager).clearLocalDataIfNeeded(cachedDevice2);
verify(mDevice1).removeBond();
}
@@ -353,6 +360,8 @@ public class CachedBluetoothDeviceManagerTest {
// Call onDeviceUnpaired for the one in mCachedDevices.
mCachedDeviceManager.onDeviceUnpaired(cachedDevice1);
+
+ verify(mHearingAidDeviceManager).clearLocalDataIfNeeded(cachedDevice1);
verify(mDevice2).removeBond();
}
@@ -406,9 +415,6 @@ public class CachedBluetoothDeviceManagerTest {
*/
@Test
public void updateHearingAidDevices_directToHearingAidDeviceManager() {
- mHearingAidDeviceManager = spy(new HearingAidDeviceManager(mContext, mLocalBluetoothManager,
- mCachedDeviceManager.mCachedDevices));
- mCachedDeviceManager.mHearingAidDeviceManager = mHearingAidDeviceManager;
mCachedDeviceManager.updateHearingAidsDevices();
verify(mHearingAidDeviceManager).updateHearingAidsDevices();
@@ -535,6 +541,7 @@ public class CachedBluetoothDeviceManagerTest {
// Call onDeviceUnpaired for the one in mCachedDevices.
mCachedDeviceManager.onDeviceUnpaired(cachedDevice1);
+ verify(mHearingAidDeviceManager).clearLocalDataIfNeeded(cachedDevice1);
verify(mDevice2).removeBond();
assertThat(cachedDevice1.getGroupId()).isEqualTo(
BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
@@ -559,6 +566,7 @@ public class CachedBluetoothDeviceManagerTest {
// Call onDeviceUnpaired for the one in mCachedDevices.
mCachedDeviceManager.onDeviceUnpaired(cachedDevice2);
+ verify(mHearingAidDeviceManager).clearLocalDataIfNeeded(cachedDevice2);
verify(mDevice1).removeBond();
assertThat(cachedDevice2.getGroupId()).isEqualTo(
BluetoothCsipSetCoordinator.GROUP_ID_INVALID);
@@ -611,10 +619,7 @@ public class CachedBluetoothDeviceManagerTest {
@Test
public void onActiveDeviceChanged_validHiSyncId_callExpectedFunction() {
- mHearingAidDeviceManager = spy(new HearingAidDeviceManager(mContext, mLocalBluetoothManager,
- mCachedDeviceManager.mCachedDevices));
doNothing().when(mHearingAidDeviceManager).onActiveDeviceChanged(any());
- mCachedDeviceManager.mHearingAidDeviceManager = mHearingAidDeviceManager;
when(mDevice1.getBondState()).thenReturn(BluetoothDevice.BOND_BONDED);
CachedBluetoothDevice cachedDevice1 = mCachedDeviceManager.addDevice(mDevice1);
cachedDevice1.setHearingAidInfo(
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/HearingAidDeviceManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/HearingAidDeviceManagerTest.java
index bf927a1eb4cc..eb73eee90f0d 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/HearingAidDeviceManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/HearingAidDeviceManagerTest.java
@@ -17,7 +17,6 @@ package com.android.settingslib.bluetooth;
import static android.bluetooth.BluetoothHearingAid.HI_SYNC_ID_INVALID;
import static android.bluetooth.BluetoothLeAudio.AUDIO_LOCATION_FRONT_LEFT;
-import static android.bluetooth.BluetoothLeAudio.AUDIO_LOCATION_INVALID;
import static com.android.settingslib.bluetooth.HapClientProfile.HearingAidType.TYPE_BINAURAL;
import static com.android.settingslib.bluetooth.HapClientProfile.HearingAidType.TYPE_INVALID;
@@ -272,14 +271,14 @@ public class HearingAidDeviceManagerTest {
*
* Conditions:
* 1) LeAudio hearing aid
- * 2) Invalid audio location and device type
+ * 2) Invalid device type
* Result:
* Do not set hearing aid info to the device.
*/
@Test
public void initHearingAidDeviceIfNeeded_leAudio_invalidInfo_notToSetHearingAidInfo() {
when(mCachedDevice1.getProfiles()).thenReturn(List.of(mLeAudioProfile, mHapClientProfile));
- when(mLeAudioProfile.getAudioLocation(mDevice1)).thenReturn(AUDIO_LOCATION_INVALID);
+ when(mLeAudioProfile.getAudioLocation(mDevice1)).thenReturn(AUDIO_LOCATION_FRONT_LEFT);
when(mHapClientProfile.getHearingAidType(mDevice1)).thenReturn(TYPE_INVALID);
mHearingAidDeviceManager.initHearingAidDeviceIfNeeded(mCachedDevice1, null);
@@ -506,14 +505,14 @@ public class HearingAidDeviceManagerTest {
*
* Conditions:
* 1) LeAudio hearing aid
- * 2) Invalid audio location and device type
+ * 2) Invalid device type
* Result:
* Do not set hearing aid info to the device.
*/
@Test
public void updateHearingAidsDevices_leAudio_invalidInfo_notToSetHearingAidInfo() {
when(mCachedDevice1.getProfiles()).thenReturn(List.of(mLeAudioProfile, mHapClientProfile));
- when(mLeAudioProfile.getAudioLocation(mDevice1)).thenReturn(AUDIO_LOCATION_INVALID);
+ when(mLeAudioProfile.getAudioLocation(mDevice1)).thenReturn(AUDIO_LOCATION_FRONT_LEFT);
when(mHapClientProfile.getHearingAidType(mDevice1)).thenReturn(TYPE_INVALID);
mCachedDeviceManager.mCachedDevices.add(mCachedDevice1);
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/HearingDeviceLocalDataManagerTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/HearingDeviceLocalDataManagerTest.java
index b659c02a2540..6d83588e0f6e 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/HearingDeviceLocalDataManagerTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/HearingDeviceLocalDataManagerTest.java
@@ -194,6 +194,19 @@ public class HearingDeviceLocalDataManagerTest {
verify(mListener).onDeviceLocalDataChange(TEST_ADDRESS, newData);
}
+ @Test
+ public void clear_dataIsRemoved() {
+ String settings = Settings.Global.getStringForUser(mContext.getContentResolver(),
+ Settings.Global.HEARING_DEVICE_LOCAL_AMBIENT_VOLUME, UserHandle.USER_SYSTEM);
+ assertThat(settings.contains(TEST_ADDRESS)).isTrue();
+
+ HearingDeviceLocalDataManager.clear(mContext, mDevice);
+
+ settings = Settings.Global.getStringForUser(mContext.getContentResolver(),
+ Settings.Global.HEARING_DEVICE_LOCAL_AMBIENT_VOLUME, UserHandle.USER_SYSTEM);
+ assertThat(settings.contains(TEST_ADDRESS)).isFalse();
+ }
+
private void prepareTestDataInSettings() {
String data = generateSettingsString(TEST_ADDRESS, TEST_AMBIENT, TEST_GROUP_AMBIENT,
TEST_AMBIENT_CONTROL_EXPANDED);
diff --git a/packages/SystemUI/checks/src/com/android/internal/systemui/lint/ShadeDisplayAwareDetector.kt b/packages/SystemUI/checks/src/com/android/internal/systemui/lint/ShadeDisplayAwareDetector.kt
index 92b6fd44e2f2..2a27a3033cf9 100644
--- a/packages/SystemUI/checks/src/com/android/internal/systemui/lint/ShadeDisplayAwareDetector.kt
+++ b/packages/SystemUI/checks/src/com/android/internal/systemui/lint/ShadeDisplayAwareDetector.kt
@@ -59,9 +59,9 @@ class ShadeDisplayAwareDetector : Detector(), SourceCodeScanner {
private const val INJECT_ANNOTATION = "javax.inject.Inject"
private const val APPLICATION_ANNOTATION =
"com.android.systemui.dagger.qualifiers.Application"
- private const val GLOBAL_CONFIG_ANNOTATION = "com.android.systemui.common.ui.GlobalConfig"
private const val SHADE_DISPLAY_AWARE_ANNOTATION =
"com.android.systemui.shade.ShadeDisplayAware"
+ private const val MAIN_ANNOTATION = "com.android.systemui.dagger.qualifiers.Main"
private const val CONTEXT = "android.content.Context"
private const val WINDOW_MANAGER = "android.view.WindowManager"
@@ -108,13 +108,10 @@ class ShadeDisplayAwareDetector : Detector(), SourceCodeScanner {
// check if the parameter is a context-dependent class relevant to shade
if (className !in CONTEXT_DEPENDENT_SHADE_CLASSES) return false
- // check if it has @ShadeDisplayAware
- if (hasAnnotation(SHADE_DISPLAY_AWARE_ANNOTATION)) return false
+ if (hasAnnotation(SHADE_DISPLAY_AWARE_ANNOTATION) || hasAnnotation(MAIN_ANNOTATION))
+ return false
// check if its a @Application-annotated Context
if (className == CONTEXT && hasAnnotation(APPLICATION_ANNOTATION)) return false
- // check if its a @GlobalConfig-annotated ConfigurationState, ConfigurationController
- // or ConfigurationInteractor
- if (className in CONFIG_CLASSES && hasAnnotation(GLOBAL_CONFIG_ANNOTATION)) return false
return true
}
diff --git a/packages/SystemUI/checks/tests/com/android/internal/systemui/lint/ShadeDisplayAwareDetectorTest.kt b/packages/SystemUI/checks/tests/com/android/internal/systemui/lint/ShadeDisplayAwareDetectorTest.kt
index 79f190782ee8..638d7cb7ee58 100644
--- a/packages/SystemUI/checks/tests/com/android/internal/systemui/lint/ShadeDisplayAwareDetectorTest.kt
+++ b/packages/SystemUI/checks/tests/com/android/internal/systemui/lint/ShadeDisplayAwareDetectorTest.kt
@@ -73,12 +73,12 @@ class ShadeDisplayAwareDetectorTest : SystemUILintDetectorTest() {
)
.indented()
- private val globalConfigStub: TestFile =
+ private val mainStub: TestFile =
kotlin(
"""
- package com.android.systemui.common.ui
+ package com.android.systemui.dagger.qualifiers
- @Retention(AnnotationRetention.RUNTIME) annotation class GlobalConfig
+ @Retention(AnnotationRetention.RUNTIME) annotation class Main
"""
)
.indented()
@@ -119,7 +119,7 @@ class ShadeDisplayAwareDetectorTest : SystemUILintDetectorTest() {
qsContext,
shadeDisplayAwareStub,
applicationStub,
- globalConfigStub,
+ mainStub,
configStateStub,
configControllerStub,
configInteractorStub,
@@ -308,7 +308,7 @@ class ShadeDisplayAwareDetectorTest : SystemUILintDetectorTest() {
}
@Test
- fun injectedConstructor_inRelevantPackage_withGlobalConfigAnnotatedConfigurationClass() {
+ fun injectedConstructor_inRelevantPackage_withMainAnnotatedConfigurationClass() {
lint()
.files(
TestFiles.kotlin(
@@ -317,11 +317,11 @@ class ShadeDisplayAwareDetectorTest : SystemUILintDetectorTest() {
import javax.inject.Inject
import com.android.systemui.common.ui.ConfigurationState
- import com.android.systemui.common.ui.GlobalConfig
+ import com.android.systemui.dagger.qualifiers.Main
class ExampleClass
@Inject
- constructor(@GlobalConfig private val configState: ConfigurationState)
+ constructor(@Main private val configState: ConfigurationState)
"""
.trimIndent()
),
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 35cdf81e8c14..59d0b55c1db8 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
@@ -337,13 +337,6 @@ internal class SwipeAnimation<T : ContentKey>(
check(!isAnimatingOffset()) { "SwipeAnimation.animateOffset() can only be called once" }
val initialProgress = progress
- // Skip the animation if we have already reached the target content and the overscroll does
- // not animate anything.
- val hasReachedTargetContent =
- (targetContent == toContent && initialProgress >= 1f) ||
- (targetContent == fromContent && initialProgress <= 0f)
- val skipAnimation =
- hasReachedTargetContent && !contentTransition.isWithinProgressRange(initialProgress)
val targetContent =
if (targetContent != currentContent && !canChangeContent(targetContent)) {
@@ -352,6 +345,14 @@ internal class SwipeAnimation<T : ContentKey>(
targetContent
}
+ // Skip the animation if we have already reached the target content and the overscroll does
+ // not animate anything.
+ val hasReachedTargetContent =
+ (targetContent == toContent && initialProgress >= 1f) ||
+ (targetContent == fromContent && initialProgress <= 0f)
+ val skipAnimation =
+ hasReachedTargetContent && !contentTransition.isWithinProgressRange(initialProgress)
+
val targetOffset =
if (targetContent == fromContent) {
0f
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 2c8dc3264b7e..b20056d54de1 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
@@ -42,7 +42,6 @@ import com.android.compose.animation.scene.content.state.TransitionState.Transit
import com.android.compose.animation.scene.subjects.assertThat
import com.android.compose.test.MonotonicClockTestScope
import com.android.compose.test.runMonotonicClockTest
-import com.android.compose.test.transition
import com.google.common.truth.Truth.assertThat
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Deferred
@@ -921,6 +920,28 @@ class DraggableHandlerTest {
}
@Test
+ fun blockTransition_animated() = runGestureTest {
+ assertIdle(SceneA)
+ layoutState.transitions = transitions { overscrollDisabled(SceneB, Orientation.Vertical) }
+
+ // Swipe up to scene B. Overscroll 50%.
+ val dragController = onDragStarted(overSlop = up(1.5f), expectedConsumedOverSlop = up(1.0f))
+ assertTransition(currentScene = SceneA, fromScene = SceneA, toScene = SceneB, progress = 1f)
+
+ // Block the transition when the user release their finger.
+ canChangeScene = { false }
+ val velocityConsumed =
+ dragController.onDragStoppedAnimateLater(velocity = -velocityThreshold)
+
+ // Start an animation: overscroll and from 1f to 0f.
+ assertTransition(currentScene = SceneA, fromScene = SceneA, toScene = SceneB, progress = 1f)
+
+ val consumed = velocityConsumed.await()
+ assertThat(consumed).isEqualTo(-velocityThreshold)
+ assertIdle(SceneA)
+ }
+
+ @Test
fun scrollFromIdleWithNoTargetScene_shouldUseOverscrollSpecIfAvailable() = runGestureTest {
layoutState.transitions = transitions {
overscroll(SceneC, Orientation.Vertical) { fade(TestElements.Foo) }
diff --git a/packages/SystemUI/lint-baseline.xml b/packages/SystemUI/lint-baseline.xml
index 09abc3762511..523adc6d3144 100644
--- a/packages/SystemUI/lint-baseline.xml
+++ b/packages/SystemUI/lint-baseline.xml
@@ -33959,5 +33959,6 @@
file="frameworks/base/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsSensorInteractor.kt"
line="53"
column="5"/>
+ </issue>
</issues>
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/DragToInteractAnimationControllerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/DragToInteractAnimationControllerTest.java
index fa8cdcc4ce2b..80de087971c5 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/DragToInteractAnimationControllerTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/DragToInteractAnimationControllerTest.java
@@ -24,6 +24,7 @@ import android.platform.test.annotations.DisableFlags;
import android.platform.test.annotations.EnableFlags;
import android.testing.TestableLooper;
import android.view.WindowManager;
+import android.view.accessibility.AccessibilityManager;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
@@ -39,6 +40,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -54,11 +56,15 @@ public class DragToInteractAnimationControllerTest extends SysuiTestCase {
@Rule
public MockitoRule mockito = MockitoJUnit.rule();
+ @Mock
+ private AccessibilityManager mAccessibilityManager;
+
@Before
public void setUp() throws Exception {
final WindowManager stubWindowManager = mContext.getSystemService(WindowManager.class);
final SecureSettings mockSecureSettings = TestUtils.mockSecureSettings();
- final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext, mockSecureSettings);
+ final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext, mAccessibilityManager,
+ mockSecureSettings);
final MenuViewAppearance stubMenuViewAppearance = new MenuViewAppearance(mContext,
stubWindowManager);
final MenuView stubMenuView = spy(new MenuView(mContext, stubMenuViewModel,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepositoryTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepositoryTest.java
index 7e4b6f913770..24f3a29e64ee 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepositoryTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepositoryTest.java
@@ -16,11 +16,16 @@
package com.android.systemui.accessibility.floatingmenu;
+import static com.android.internal.accessibility.AccessibilityShortcutController.MAGNIFICATION_CONTROLLER_NAME;
+
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.any;
+import static org.mockito.Mockito.doReturn;
import static org.mockito.Mockito.verify;
+import android.content.Context;
import android.content.res.Configuration;
+import android.view.accessibility.AccessibilityManager;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
@@ -28,6 +33,7 @@ import androidx.test.filters.SmallTest;
import com.android.systemui.SysuiTestCase;
import com.android.systemui.util.settings.SecureSettings;
+import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -36,6 +42,8 @@ import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
+import java.util.ArrayList;
+import java.util.List;
import java.util.Locale;
/** Tests for {@link MenuInfoRepository}. */
@@ -46,16 +54,30 @@ public class MenuInfoRepositoryTest extends SysuiTestCase {
public MockitoRule mockito = MockitoJUnit.rule();
@Mock
+ private AccessibilityManager mAccessibilityManager;
+
+ @Mock
private MenuInfoRepository.OnSettingsContentsChanged mMockSettingsContentsChanged;
@Mock
private SecureSettings mSecureSettings;
private MenuInfoRepository mMenuInfoRepository;
+ private final List<String> mShortcutTargets = new ArrayList<>();
@Before
public void setUp() {
- mMenuInfoRepository = new MenuInfoRepository(mContext, mMockSettingsContentsChanged,
- mSecureSettings);
+ mContext.addMockSystemService(Context.ACCESSIBILITY_SERVICE, mAccessibilityManager);
+ mShortcutTargets.add(MAGNIFICATION_CONTROLLER_NAME);
+ doReturn(mShortcutTargets).when(mAccessibilityManager).getAccessibilityShortcutTargets(
+ anyInt());
+
+ mMenuInfoRepository = new MenuInfoRepository(mContext, mAccessibilityManager,
+ mMockSettingsContentsChanged, mSecureSettings);
+ }
+
+ @After
+ public void tearDown() {
+ mShortcutTargets.clear();
}
@Test
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuItemAccessibilityDelegateTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuItemAccessibilityDelegateTest.java
index 1f48bec97b2d..157cccc3d62f 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuItemAccessibilityDelegateTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuItemAccessibilityDelegateTest.java
@@ -83,7 +83,8 @@ public class MenuItemAccessibilityDelegateTest extends SysuiTestCase {
final WindowManager stubWindowManager = mContext.getSystemService(WindowManager.class);
final MenuViewAppearance stubMenuViewAppearance = new MenuViewAppearance(mContext,
stubWindowManager);
- final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext, mSecureSettings);
+ final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext, mAccessibilityManager,
+ mSecureSettings);
final int halfScreenHeight =
stubWindowManager.getCurrentWindowMetrics().getBounds().height() / 2;
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuListViewTouchHandlerTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuListViewTouchHandlerTest.java
index f7b81cc49f0b..46f076a75116 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuListViewTouchHandlerTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuListViewTouchHandlerTest.java
@@ -33,6 +33,7 @@ import android.platform.test.annotations.EnableFlags;
import android.testing.TestableLooper;
import android.view.MotionEvent;
import android.view.WindowManager;
+import android.view.accessibility.AccessibilityManager;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.recyclerview.widget.RecyclerView;
@@ -52,6 +53,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -78,11 +80,15 @@ public class MenuListViewTouchHandlerTest extends SysuiTestCase {
@Rule
public MockitoRule mockito = MockitoJUnit.rule();
+ @Mock
+ private AccessibilityManager mAccessibilityManager;
+
@Before
public void setUp() throws Exception {
final WindowManager windowManager = mContext.getSystemService(WindowManager.class);
final SecureSettings secureSettings = TestUtils.mockSecureSettings();
- final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext, secureSettings);
+ final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext, mAccessibilityManager,
+ secureSettings);
final MenuViewAppearance stubMenuViewAppearance = new MenuViewAppearance(mContext,
windowManager);
mStubMenuView = new MenuView(mContext, stubMenuViewModel, stubMenuViewAppearance,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuViewTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuViewTest.java
index c1708d175224..ee8ce17cecd4 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuViewTest.java
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/accessibility/floatingmenu/MenuViewTest.java
@@ -32,6 +32,7 @@ import android.graphics.drawable.GradientDrawable;
import android.platform.test.annotations.EnableFlags;
import android.testing.TestableLooper;
import android.view.WindowManager;
+import android.view.accessibility.AccessibilityManager;
import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
@@ -48,6 +49,7 @@ import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
+import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -66,6 +68,9 @@ public class MenuViewTest extends SysuiTestCase {
@Rule
public MockitoRule mockito = MockitoJUnit.rule();
+ @Mock
+ private AccessibilityManager mAccessibilityManager;
+
private SysuiTestableContext mSpyContext;
@Before
@@ -84,7 +89,8 @@ public class MenuViewTest extends SysuiTestCase {
doNothing().when(mSpyContext).startActivity(any());
final SecureSettings secureSettings = TestUtils.mockSecureSettings();
- final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext, secureSettings);
+ final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext, mAccessibilityManager,
+ secureSettings);
final WindowManager stubWindowManager = mContext.getSystemService(WindowManager.class);
mStubMenuViewAppearance = new MenuViewAppearance(mSpyContext, stubWindowManager);
mMenuView = spy(new MenuView(mSpyContext, stubMenuViewModel, mStubMenuViewAppearance,
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/display/StatusBarTouchShadeDisplayPolicyTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/display/StatusBarTouchShadeDisplayPolicyTest.kt
index ef1ae093bcc9..fd9f5f02ee62 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/display/StatusBarTouchShadeDisplayPolicyTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/shade/display/StatusBarTouchShadeDisplayPolicyTest.kt
@@ -25,6 +25,7 @@ import com.android.systemui.coroutines.collectLastValue
import com.android.systemui.coroutines.collectValues
import com.android.systemui.display.data.repository.display
import com.android.systemui.display.data.repository.displayRepository
+import com.android.systemui.keyguard.data.repository.fakeKeyguardRepository
import com.android.systemui.kosmos.testScope
import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.testKosmos
@@ -38,17 +39,31 @@ import org.junit.runner.RunWith
class StatusBarTouchShadeDisplayPolicyTest : SysuiTestCase() {
private val kosmos = testKosmos().useUnconfinedTestDispatcher()
private val testScope = kosmos.testScope
+ private val keyguardRepository = kosmos.fakeKeyguardRepository
private val displayRepository = kosmos.displayRepository
- val underTest = StatusBarTouchShadeDisplayPolicy(displayRepository, testScope.backgroundScope)
+
+ private fun createUnderTest(
+ shadeOnDefaultDisplayWhenLocked: Boolean = false
+ ): StatusBarTouchShadeDisplayPolicy {
+ return StatusBarTouchShadeDisplayPolicy(
+ displayRepository,
+ keyguardRepository,
+ testScope.backgroundScope,
+ shadeOnDefaultDisplayWhenLocked = shadeOnDefaultDisplayWhenLocked,
+ )
+ }
@Test
fun displayId_defaultToDefaultDisplay() {
+ val underTest = createUnderTest()
+
assertThat(underTest.displayId.value).isEqualTo(Display.DEFAULT_DISPLAY)
}
@Test
fun onStatusBarTouched_called_updatesDisplayId() =
testScope.runTest {
+ val underTest = createUnderTest()
val displayId by collectLastValue(underTest.displayId)
displayRepository.addDisplays(display(id = 2, type = TYPE_EXTERNAL))
@@ -60,6 +75,7 @@ class StatusBarTouchShadeDisplayPolicyTest : SysuiTestCase() {
@Test
fun onStatusBarTouched_notExistentDisplay_displayIdNotUpdated() =
testScope.runTest {
+ val underTest = createUnderTest()
val displayIds by collectValues(underTest.displayId)
assertThat(displayIds).isEqualTo(listOf(Display.DEFAULT_DISPLAY))
@@ -72,6 +88,7 @@ class StatusBarTouchShadeDisplayPolicyTest : SysuiTestCase() {
@Test
fun onStatusBarTouched_afterDisplayRemoved_goesBackToDefaultDisplay() =
testScope.runTest {
+ val underTest = createUnderTest()
val displayId by collectLastValue(underTest.displayId)
displayRepository.addDisplays(display(id = 2, type = TYPE_EXTERNAL))
@@ -83,4 +100,40 @@ class StatusBarTouchShadeDisplayPolicyTest : SysuiTestCase() {
assertThat(displayId).isEqualTo(Display.DEFAULT_DISPLAY)
}
+
+ @Test
+ fun onStatusBarTouched_afterKeyguardVisible_goesBackToDefaultDisplay() =
+ testScope.runTest {
+ val underTest = createUnderTest(shadeOnDefaultDisplayWhenLocked = true)
+ val displayId by collectLastValue(underTest.displayId)
+
+ displayRepository.addDisplays(display(id = 2, type = TYPE_EXTERNAL))
+ underTest.onStatusBarTouched(2)
+
+ assertThat(displayId).isEqualTo(2)
+
+ keyguardRepository.setKeyguardShowing(true)
+
+ assertThat(displayId).isEqualTo(Display.DEFAULT_DISPLAY)
+ }
+
+ @Test
+ fun onStatusBarTouched_afterKeyguardHides_goesBackToPreviousDisplay() =
+ testScope.runTest {
+ val underTest = createUnderTest(shadeOnDefaultDisplayWhenLocked = true)
+ val displayId by collectLastValue(underTest.displayId)
+
+ displayRepository.addDisplays(display(id = 2, type = TYPE_EXTERNAL))
+ underTest.onStatusBarTouched(2)
+
+ assertThat(displayId).isEqualTo(2)
+
+ keyguardRepository.setKeyguardShowing(true)
+
+ assertThat(displayId).isEqualTo(Display.DEFAULT_DISPLAY)
+
+ keyguardRepository.setKeyguardShowing(false)
+
+ assertThat(displayId).isEqualTo(2)
+ }
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractorTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractorTest.kt
index f06bab756acc..63efc55e1a09 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractorTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractorTest.kt
@@ -29,6 +29,7 @@ import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.chips.notification.domain.model.NotificationChipModel
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.notification.data.model.activeNotificationModel
+import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel
import com.android.systemui.testKosmos
import com.google.common.truth.Truth.assertThat
import org.junit.Test
@@ -46,7 +47,12 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
kosmos.runTest {
val icon = mock<StatusBarIconView>()
val startingNotif =
- activeNotificationModel(key = "notif1", statusBarChipIcon = icon, whenTime = 5432)
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = icon,
+ whenTime = 5432,
+ promotedContent = PROMOTED_CONTENT,
+ )
val underTest = factory.create(startingNotif)
@@ -63,7 +69,11 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
val originalIconView = mock<StatusBarIconView>()
val underTest =
factory.create(
- activeNotificationModel(key = "notif1", statusBarChipIcon = originalIconView)
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = originalIconView,
+ promotedContent = PROMOTED_CONTENT,
+ )
)
val latest by collectLastValue(underTest.notificationChip)
@@ -74,6 +84,7 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
key = "notif1",
statusBarChipIcon = newIconView,
whenTime = 6543,
+ promotedContent = PROMOTED_CONTENT,
)
)
@@ -88,14 +99,22 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
val originalIconView = mock<StatusBarIconView>()
val underTest =
factory.create(
- activeNotificationModel(key = "notif1", statusBarChipIcon = originalIconView)
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = originalIconView,
+ promotedContent = PROMOTED_CONTENT,
+ )
)
val latest by collectLastValue(underTest.notificationChip)
val newIconView = mock<StatusBarIconView>()
underTest.setNotification(
- activeNotificationModel(key = "other_notif", statusBarChipIcon = newIconView)
+ activeNotificationModel(
+ key = "other_notif",
+ statusBarChipIcon = newIconView,
+ promotedContent = PROMOTED_CONTENT,
+ )
)
assertThat(latest!!.key).isEqualTo("notif1")
@@ -103,10 +122,43 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
}
@Test
+ fun notificationChip_ignoresSetWithNullPromotedContent() =
+ kosmos.runTest {
+ val originalIconView = mock<StatusBarIconView>()
+ val underTest =
+ factory.create(
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = originalIconView,
+ promotedContent = PROMOTED_CONTENT,
+ )
+ )
+
+ val latest by collectLastValue(underTest.notificationChip)
+
+ val newIconView = mock<StatusBarIconView>()
+ underTest.setNotification(
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = newIconView,
+ promotedContent = null,
+ )
+ )
+
+ assertThat(latest!!.statusBarChipIconView).isEqualTo(originalIconView)
+ }
+
+ @Test
fun notificationChip_missingStatusBarIconChipView_inConstructor_emitsNull() =
kosmos.runTest {
val underTest =
- factory.create(activeNotificationModel(key = "notif1", statusBarChipIcon = null))
+ factory.create(
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = null,
+ promotedContent = PROMOTED_CONTENT,
+ )
+ )
val latest by collectLastValue(underTest.notificationChip)
@@ -123,6 +175,7 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
key = "notif1",
statusBarChipIcon = null,
whenTime = 123L,
+ promotedContent = PROMOTED_CONTENT,
)
)
@@ -130,20 +183,34 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
assertThat(latest)
.isEqualTo(
- NotificationChipModel("notif1", statusBarChipIconView = null, whenTime = 123L)
+ NotificationChipModel(
+ "notif1",
+ statusBarChipIconView = null,
+ whenTime = 123L,
+ promotedContent = PROMOTED_CONTENT,
+ )
)
}
@Test
fun notificationChip_missingStatusBarIconChipView_inSet_emitsNull() =
kosmos.runTest {
- val startingNotif = activeNotificationModel(key = "notif1", statusBarChipIcon = mock())
+ val startingNotif =
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = mock(),
+ promotedContent = PROMOTED_CONTENT,
+ )
val underTest = factory.create(startingNotif)
val latest by collectLastValue(underTest.notificationChip)
assertThat(latest).isNotNull()
underTest.setNotification(
- activeNotificationModel(key = "notif1", statusBarChipIcon = null)
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = null,
+ promotedContent = PROMOTED_CONTENT,
+ )
)
assertThat(latest).isNull()
@@ -153,13 +220,23 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
@EnableFlags(StatusBarConnectedDisplays.FLAG_NAME)
fun notificationChip_missingStatusBarIconChipView_inSet_cdEnabled_emitsNotNull() =
kosmos.runTest {
- val startingNotif = activeNotificationModel(key = "notif1", statusBarChipIcon = mock())
+ val startingNotif =
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = mock(),
+ promotedContent = PROMOTED_CONTENT,
+ )
val underTest = factory.create(startingNotif)
val latest by collectLastValue(underTest.notificationChip)
assertThat(latest).isNotNull()
underTest.setNotification(
- activeNotificationModel(key = "notif1", statusBarChipIcon = null, whenTime = 123L)
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = null,
+ whenTime = 123L,
+ promotedContent = PROMOTED_CONTENT,
+ )
)
assertThat(latest)
@@ -168,8 +245,26 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
key = "notif1",
statusBarChipIconView = null,
whenTime = 123L,
+ promotedContent = PROMOTED_CONTENT,
+ )
+ )
+ }
+
+ @Test
+ fun notificationChip_missingPromotedContent_inConstructor_emitsNull() =
+ kosmos.runTest {
+ val underTest =
+ factory.create(
+ activeNotificationModel(
+ key = "notif1",
+ statusBarChipIcon = mock(),
+ promotedContent = null,
)
)
+
+ val latest by collectLastValue(underTest.notificationChip)
+
+ assertThat(latest).isNull()
}
@Test
@@ -179,7 +274,12 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
val underTest =
factory.create(
- activeNotificationModel(key = "notif", uid = UID, statusBarChipIcon = mock())
+ activeNotificationModel(
+ key = "notif",
+ uid = UID,
+ statusBarChipIcon = mock(),
+ promotedContent = PROMOTED_CONTENT,
+ )
)
val latest by collectLastValue(underTest.notificationChip)
@@ -194,7 +294,12 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
val underTest =
factory.create(
- activeNotificationModel(key = "notif", uid = UID, statusBarChipIcon = mock())
+ activeNotificationModel(
+ key = "notif",
+ uid = UID,
+ statusBarChipIcon = mock(),
+ promotedContent = PROMOTED_CONTENT,
+ )
)
val latest by collectLastValue(underTest.notificationChip)
@@ -207,7 +312,12 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
kosmos.runTest {
val underTest =
factory.create(
- activeNotificationModel(key = "notif", uid = UID, statusBarChipIcon = mock())
+ activeNotificationModel(
+ key = "notif",
+ uid = UID,
+ statusBarChipIcon = mock(),
+ promotedContent = PROMOTED_CONTENT,
+ )
)
val latest by collectLastValue(underTest.notificationChip)
@@ -239,6 +349,7 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
key = "notif",
uid = hiddenUid,
statusBarChipIcon = mock(),
+ promotedContent = PROMOTED_CONTENT,
)
)
val latest by collectLastValue(underTest.notificationChip)
@@ -247,7 +358,12 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
// WHEN the notif gets a new UID that starts as visible
activityManagerRepository.fake.startingIsAppVisibleValue = true
underTest.setNotification(
- activeNotificationModel(key = "notif", uid = shownUid, statusBarChipIcon = mock())
+ activeNotificationModel(
+ key = "notif",
+ uid = shownUid,
+ statusBarChipIcon = mock(),
+ promotedContent = PROMOTED_CONTENT,
+ )
)
// THEN we re-fetch the app visibility state with the new UID, and since that UID is
@@ -257,5 +373,6 @@ class SingleNotificationChipInteractorTest : SysuiTestCase() {
companion object {
private const val UID = 885
+ private val PROMOTED_CONTENT = PromotedNotificationContentModel.Builder("notif1").build()
}
}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt
index 8a4ddceb0d3a..b174fcee779c 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModelTest.kt
@@ -28,6 +28,7 @@ import com.android.systemui.kosmos.useUnconfinedTestDispatcher
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.chips.notification.domain.interactor.statusBarNotificationChipsInteractor
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
+import com.android.systemui.statusbar.chips.ui.model.ColorsModel
import com.android.systemui.statusbar.chips.ui.model.OngoingActivityChipModel
import com.android.systemui.statusbar.core.StatusBarConnectedDisplays
import com.android.systemui.statusbar.notification.data.model.activeNotificationModel
@@ -132,6 +133,36 @@ class NotifChipsViewModelTest : SysuiTestCase() {
}
@Test
+ fun chips_onePromotedNotif_colorMatches() =
+ kosmos.runTest {
+ val latest by collectLastValue(underTest.chips)
+
+ val promotedContentBuilder =
+ PromotedNotificationContentModel.Builder("notif").apply {
+ this.colors =
+ PromotedNotificationContentModel.Colors(
+ backgroundColor = 56,
+ primaryTextColor = 89,
+ )
+ }
+ setNotifs(
+ listOf(
+ activeNotificationModel(
+ key = "notif",
+ statusBarChipIcon = mock<StatusBarIconView>(),
+ promotedContent = promotedContentBuilder.build(),
+ )
+ )
+ )
+
+ assertThat(latest).hasSize(1)
+ val colors = latest!![0].colors
+ assertThat(colors).isInstanceOf(ColorsModel.Custom::class.java)
+ assertThat((colors as ColorsModel.Custom).backgroundColorInt).isEqualTo(56)
+ assertThat((colors as ColorsModel.Custom).primaryTextColorInt).isEqualTo(89)
+ }
+
+ @Test
fun chips_onlyForPromotedNotifs() =
kosmos.runTest {
val latest by collectLastValue(underTest.chips)
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java
deleted file mode 100644
index 41782a123f14..000000000000
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.java
+++ /dev/null
@@ -1,379 +0,0 @@
-/*
- * Copyright (C) 2018 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file
- * except in compliance with the License. You may obtain a copy of the License at
- *
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software distributed under the
- * License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
- * KIND, either express or implied. See the License for the specific language governing
- * permissions and limitations under the License.
- */
-
-package com.android.systemui.statusbar.phone;
-
-import static android.view.Display.DEFAULT_DISPLAY;
-
-import static com.android.systemui.statusbar.notification.interruption.VisualInterruptionType.BUBBLE;
-import static com.android.systemui.statusbar.notification.interruption.VisualInterruptionType.PEEK;
-import static com.android.systemui.statusbar.notification.interruption.VisualInterruptionType.PULSE;
-
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
-import static org.junit.Assert.assertTrue;
-import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.times;
-import static org.mockito.Mockito.verify;
-import static org.mockito.Mockito.when;
-
-import android.app.Notification;
-import android.app.PendingIntent;
-import android.app.StatusBarManager;
-import android.platform.test.annotations.DisableFlags;
-import android.platform.test.annotations.EnableFlags;
-import android.testing.TestableLooper;
-import android.testing.TestableLooper.RunWithLooper;
-
-import androidx.test.ext.junit.runners.AndroidJUnit4;
-import androidx.test.filters.SmallTest;
-
-import com.android.systemui.InitController;
-import com.android.systemui.SysuiTestCase;
-import com.android.systemui.plugins.ActivityStarter;
-import com.android.systemui.plugins.statusbar.StatusBarStateController;
-import com.android.systemui.power.domain.interactor.PowerInteractor;
-import com.android.systemui.settings.FakeDisplayTracker;
-import com.android.systemui.shade.NotificationShadeWindowView;
-import com.android.systemui.shade.QuickSettingsController;
-import com.android.systemui.shade.ShadeController;
-import com.android.systemui.shade.ShadeViewController;
-import com.android.systemui.shade.domain.interactor.PanelExpansionInteractor;
-import com.android.systemui.statusbar.CommandQueue;
-import com.android.systemui.statusbar.LockscreenShadeTransitionController;
-import com.android.systemui.statusbar.NotificationLockscreenUserManager;
-import com.android.systemui.statusbar.NotificationMediaManager;
-import com.android.systemui.statusbar.NotificationRemoteInputManager;
-import com.android.systemui.statusbar.NotificationShadeWindowController;
-import com.android.systemui.statusbar.SysuiStatusBarStateController;
-import com.android.systemui.statusbar.notification.DynamicPrivacyController;
-import com.android.systemui.statusbar.notification.collection.NotificationEntry;
-import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder;
-import com.android.systemui.statusbar.notification.collection.render.NotifShadeEventSource;
-import com.android.systemui.statusbar.notification.domain.interactor.NotificationAlertsInteractor;
-import com.android.systemui.statusbar.notification.interruption.NotificationInterruptSuppressor;
-import com.android.systemui.statusbar.notification.interruption.VisualInterruptionCondition;
-import com.android.systemui.statusbar.notification.interruption.VisualInterruptionDecisionProvider;
-import com.android.systemui.statusbar.notification.interruption.VisualInterruptionFilter;
-import com.android.systemui.statusbar.notification.interruption.VisualInterruptionRefactor;
-import com.android.systemui.statusbar.notification.interruption.VisualInterruptionType;
-import com.android.systemui.statusbar.notification.row.NotificationGutsManager;
-import com.android.systemui.statusbar.notification.stack.NotificationListContainer;
-import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayout;
-import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController;
-import com.android.systemui.statusbar.notification.headsup.HeadsUpManager;
-import com.android.systemui.statusbar.policy.KeyguardStateController;
-
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.ArgumentCaptor;
-
-import java.util.List;
-import java.util.Set;
-
-@SmallTest
-@RunWith(AndroidJUnit4.class)
-@RunWithLooper()
-public class StatusBarNotificationPresenterTest extends SysuiTestCase {
- private StatusBarNotificationPresenter mStatusBarNotificationPresenter;
- private final VisualInterruptionDecisionProvider mVisualInterruptionDecisionProvider =
- mock(VisualInterruptionDecisionProvider.class);
- private NotificationInterruptSuppressor mInterruptSuppressor;
- private VisualInterruptionCondition mAlertsDisabledCondition;
- private VisualInterruptionCondition mVrModeCondition;
- private VisualInterruptionFilter mNeedsRedactionFilter;
- private VisualInterruptionCondition mPanelsDisabledCondition;
- private CommandQueue mCommandQueue;
- private final ShadeController mShadeController = mock(ShadeController.class);
- private final NotificationAlertsInteractor mNotificationAlertsInteractor =
- mock(NotificationAlertsInteractor.class);
- private final KeyguardStateController mKeyguardStateController =
- mock(KeyguardStateController.class);
-
- @Before
- public void setup() {
- mCommandQueue = new CommandQueue(mContext, new FakeDisplayTracker(mContext));
- mDependency.injectTestDependency(StatusBarStateController.class,
- mock(SysuiStatusBarStateController.class));
- mDependency.injectTestDependency(ShadeController.class, mShadeController);
- mDependency.injectMockDependency(NotificationRemoteInputManager.Callback.class);
- mDependency.injectMockDependency(NotificationShadeWindowController.class);
-
- when(mNotificationAlertsInteractor.areNotificationAlertsEnabled()).thenReturn(true);
-
- createPresenter();
- if (VisualInterruptionRefactor.isEnabled()) {
- verifyAndCaptureSuppressors();
- } else {
- verifyAndCaptureLegacySuppressor();
- }
- }
-
- @Test
- @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testInit_refactorDisabled() {
- assertFalse(VisualInterruptionRefactor.isEnabled());
- assertNull(mAlertsDisabledCondition);
- assertNull(mVrModeCondition);
- assertNull(mNeedsRedactionFilter);
- assertNull(mPanelsDisabledCondition);
- assertNotNull(mInterruptSuppressor);
- }
-
- @Test
- @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testInit_refactorEnabled() {
- assertTrue(VisualInterruptionRefactor.isEnabled());
- assertNotNull(mAlertsDisabledCondition);
- assertNotNull(mVrModeCondition);
- assertNotNull(mNeedsRedactionFilter);
- assertNotNull(mPanelsDisabledCondition);
- assertNull(mInterruptSuppressor);
- }
-
- @Test
- @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testNoSuppressHeadsUp_default_refactorDisabled() {
- assertFalse(mInterruptSuppressor.suppressAwakeHeadsUp(createNotificationEntry()));
- }
-
- @Test
- @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testNoSuppressHeadsUp_default_refactorEnabled() {
- assertFalse(mAlertsDisabledCondition.shouldSuppress());
- assertFalse(mVrModeCondition.shouldSuppress());
- assertFalse(mNeedsRedactionFilter.shouldSuppress(createNotificationEntry()));
- assertFalse(mAlertsDisabledCondition.shouldSuppress());
- }
-
- @Test
- @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testSuppressHeadsUp_disabledStatusBar_refactorDisabled() {
- mCommandQueue.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_EXPAND, 0,
- false /* animate */);
- TestableLooper.get(this).processAllMessages();
-
- assertTrue("The panel should suppress heads up while disabled",
- mInterruptSuppressor.suppressAwakeHeadsUp(createNotificationEntry()));
- }
-
- @Test
- @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testSuppressHeadsUp_disabledStatusBar_refactorEnabled() {
- mCommandQueue.disable(DEFAULT_DISPLAY, StatusBarManager.DISABLE_EXPAND, 0,
- false /* animate */);
- TestableLooper.get(this).processAllMessages();
-
- assertTrue("The panel should suppress heads up while disabled",
- mPanelsDisabledCondition.shouldSuppress());
- }
-
- @Test
- @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testSuppressHeadsUp_disabledNotificationShade_refactorDisabled() {
- mCommandQueue.disable(DEFAULT_DISPLAY, 0, StatusBarManager.DISABLE2_NOTIFICATION_SHADE,
- false /* animate */);
- TestableLooper.get(this).processAllMessages();
-
- assertTrue("The panel should suppress interruptions while notification shade disabled",
- mInterruptSuppressor.suppressAwakeHeadsUp(createNotificationEntry()));
- }
-
- @Test
- @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testSuppressHeadsUp_disabledNotificationShade_refactorEnabled() {
- mCommandQueue.disable(DEFAULT_DISPLAY, 0, StatusBarManager.DISABLE2_NOTIFICATION_SHADE,
- false /* animate */);
- TestableLooper.get(this).processAllMessages();
-
- assertTrue("The panel should suppress interruptions while notification shade disabled",
- mPanelsDisabledCondition.shouldSuppress());
- }
-
- @Test
- @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testPanelsDisabledConditionSuppressesPeek() {
- final Set<VisualInterruptionType> types = mPanelsDisabledCondition.getTypes();
- assertTrue(types.contains(PEEK));
- assertFalse(types.contains(PULSE));
- assertFalse(types.contains(BUBBLE));
- }
-
- @Test
- @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testNoSuppressHeadsUp_FSI_nonOccludedKeyguard_refactorDisabled() {
- when(mKeyguardStateController.isShowing()).thenReturn(true);
- when(mKeyguardStateController.isOccluded()).thenReturn(false);
-
- assertFalse(mInterruptSuppressor.suppressAwakeHeadsUp(createFsiNotificationEntry()));
- }
-
- @Test
- @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testNoSuppressHeadsUp_FSI_nonOccludedKeyguard_refactorEnabled() {
- when(mKeyguardStateController.isShowing()).thenReturn(true);
- when(mKeyguardStateController.isOccluded()).thenReturn(false);
-
- assertFalse(mNeedsRedactionFilter.shouldSuppress(createFsiNotificationEntry()));
-
- final Set<VisualInterruptionType> types = mNeedsRedactionFilter.getTypes();
- assertTrue(types.contains(PEEK));
- assertFalse(types.contains(PULSE));
- assertFalse(types.contains(BUBBLE));
- }
-
- @Test
- @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testSuppressInterruptions_vrMode_refactorDisabled() {
- mStatusBarNotificationPresenter.mVrMode = true;
-
- assertTrue("Vr mode should suppress interruptions",
- mInterruptSuppressor.suppressAwakeInterruptions(createNotificationEntry()));
- }
-
- @Test
- @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testSuppressInterruptions_vrMode_refactorEnabled() {
- mStatusBarNotificationPresenter.mVrMode = true;
-
- assertTrue("Vr mode should suppress interruptions", mVrModeCondition.shouldSuppress());
-
- final Set<VisualInterruptionType> types = mVrModeCondition.getTypes();
- assertTrue(types.contains(PEEK));
- assertFalse(types.contains(PULSE));
- assertTrue(types.contains(BUBBLE));
- }
-
- @Test
- @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testSuppressInterruptions_statusBarAlertsDisabled_refactorDisabled() {
- when(mNotificationAlertsInteractor.areNotificationAlertsEnabled()).thenReturn(false);
-
- assertTrue("When alerts aren't enabled, interruptions are suppressed",
- mInterruptSuppressor.suppressInterruptions(createNotificationEntry()));
- }
-
- @Test
- @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
- public void testSuppressInterruptions_statusBarAlertsDisabled_refactorEnabled() {
- when(mNotificationAlertsInteractor.areNotificationAlertsEnabled()).thenReturn(false);
-
- assertTrue("When alerts aren't enabled, interruptions are suppressed",
- mAlertsDisabledCondition.shouldSuppress());
-
- final Set<VisualInterruptionType> types = mAlertsDisabledCondition.getTypes();
- assertTrue(types.contains(PEEK));
- assertTrue(types.contains(PULSE));
- assertTrue(types.contains(BUBBLE));
- }
-
- private void createPresenter() {
- final ShadeViewController shadeViewController = mock(ShadeViewController.class);
-
- final NotificationShadeWindowView notificationShadeWindowView =
- mock(NotificationShadeWindowView.class);
- when(notificationShadeWindowView.getResources()).thenReturn(mContext.getResources());
-
- NotificationStackScrollLayoutController stackScrollLayoutController =
- mock(NotificationStackScrollLayoutController.class);
- when(stackScrollLayoutController.getView()).thenReturn(
- mock(NotificationStackScrollLayout.class));
-
- final InitController initController = new InitController();
-
- mStatusBarNotificationPresenter = new StatusBarNotificationPresenter(
- mContext,
- shadeViewController,
- mock(PanelExpansionInteractor.class),
- mock(QuickSettingsController.class),
- mock(HeadsUpManager.class),
- notificationShadeWindowView,
- mock(ActivityStarter.class),
- stackScrollLayoutController,
- mock(DozeScrimController.class),
- mock(NotificationShadeWindowController.class),
- mock(DynamicPrivacyController.class),
- mKeyguardStateController,
- mNotificationAlertsInteractor,
- mock(LockscreenShadeTransitionController.class),
- mock(PowerInteractor.class),
- mCommandQueue,
- mock(NotificationLockscreenUserManager.class),
- mock(SysuiStatusBarStateController.class),
- mock(NotifShadeEventSource.class),
- mock(NotificationMediaManager.class),
- mock(NotificationGutsManager.class),
- initController,
- mVisualInterruptionDecisionProvider,
- mock(NotificationRemoteInputManager.class),
- mock(NotificationRemoteInputManager.Callback.class),
- mock(NotificationListContainer.class));
-
- initController.executePostInitTasks();
- }
-
- private void verifyAndCaptureSuppressors() {
- mInterruptSuppressor = null;
-
- final ArgumentCaptor<VisualInterruptionCondition> conditionCaptor =
- ArgumentCaptor.forClass(VisualInterruptionCondition.class);
- verify(mVisualInterruptionDecisionProvider, times(3)).addCondition(
- conditionCaptor.capture());
- final List<VisualInterruptionCondition> conditions = conditionCaptor.getAllValues();
- mAlertsDisabledCondition = conditions.get(0);
- mVrModeCondition = conditions.get(1);
- mPanelsDisabledCondition = conditions.get(2);
-
- final ArgumentCaptor<VisualInterruptionFilter> needsRedactionFilterCaptor =
- ArgumentCaptor.forClass(VisualInterruptionFilter.class);
- verify(mVisualInterruptionDecisionProvider).addFilter(needsRedactionFilterCaptor.capture());
- mNeedsRedactionFilter = needsRedactionFilterCaptor.getValue();
- }
-
- private void verifyAndCaptureLegacySuppressor() {
- mAlertsDisabledCondition = null;
- mVrModeCondition = null;
- mNeedsRedactionFilter = null;
- mPanelsDisabledCondition = null;
-
- final ArgumentCaptor<NotificationInterruptSuppressor> suppressorCaptor =
- ArgumentCaptor.forClass(NotificationInterruptSuppressor.class);
- verify(mVisualInterruptionDecisionProvider).addLegacySuppressor(suppressorCaptor.capture());
- mInterruptSuppressor = suppressorCaptor.getValue();
- }
-
- private NotificationEntry createNotificationEntry() {
- return new NotificationEntryBuilder()
- .setPkg("a")
- .setOpPkg("a")
- .setTag("a")
- .setNotification(new Notification.Builder(getContext(), "a").build())
- .build();
- }
-
- private NotificationEntry createFsiNotificationEntry() {
- final Notification notification = new Notification.Builder(getContext(), "a")
- .setFullScreenIntent(mock(PendingIntent.class), true)
- .build();
-
- return new NotificationEntryBuilder()
- .setPkg("a")
- .setOpPkg("a")
- .setTag("a")
- .setNotification(notification)
- .build();
- }
-}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.kt
new file mode 100644
index 000000000000..31fbcb984105
--- /dev/null
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/phone/StatusBarNotificationPresenterTest.kt
@@ -0,0 +1,385 @@
+/*
+ * 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.statusbar.phone
+
+import android.app.Notification
+import android.app.Notification.Builder
+import android.app.StatusBarManager
+import android.platform.test.annotations.DisableFlags
+import android.platform.test.annotations.EnableFlags
+import android.testing.TestableLooper
+import android.testing.TestableLooper.RunWithLooper
+import android.view.Display.DEFAULT_DISPLAY
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.android.systemui.InitController
+import com.android.systemui.SysuiTestCase
+import com.android.systemui.plugins.activityStarter
+import com.android.systemui.plugins.statusbar.StatusBarStateController
+import com.android.systemui.power.domain.interactor.powerInteractor
+import com.android.systemui.settings.FakeDisplayTracker
+import com.android.systemui.shade.NotificationShadeWindowView
+import com.android.systemui.shade.ShadeController
+import com.android.systemui.shade.ShadeViewController
+import com.android.systemui.shade.domain.interactor.panelExpansionInteractor
+import com.android.systemui.statusbar.CommandQueue
+import com.android.systemui.statusbar.NotificationRemoteInputManager
+import com.android.systemui.statusbar.NotificationShadeWindowController
+import com.android.systemui.statusbar.lockscreenShadeTransitionController
+import com.android.systemui.statusbar.notification.collection.NotificationEntry
+import com.android.systemui.statusbar.notification.collection.NotificationEntryBuilder
+import com.android.systemui.statusbar.notification.domain.interactor.NotificationAlertsInteractor
+import com.android.systemui.statusbar.notification.dynamicPrivacyController
+import com.android.systemui.statusbar.notification.headsup.headsUpManager
+import com.android.systemui.statusbar.notification.interruption.NotificationInterruptSuppressor
+import com.android.systemui.statusbar.notification.interruption.VisualInterruptionCondition
+import com.android.systemui.statusbar.notification.interruption.VisualInterruptionDecisionProvider
+import com.android.systemui.statusbar.notification.interruption.VisualInterruptionFilter
+import com.android.systemui.statusbar.notification.interruption.VisualInterruptionRefactor
+import com.android.systemui.statusbar.notification.interruption.VisualInterruptionType
+import com.android.systemui.statusbar.notification.stack.NotificationStackScrollLayoutController
+import com.android.systemui.statusbar.notificationLockscreenUserManager
+import com.android.systemui.statusbar.notificationRemoteInputManager
+import com.android.systemui.statusbar.notificationShadeWindowController
+import com.android.systemui.statusbar.policy.KeyguardStateController
+import com.android.systemui.statusbar.sysuiStatusBarStateController
+import com.android.systemui.testKosmos
+import com.google.common.truth.Truth.assertThat
+import com.google.common.truth.Truth.assertWithMessage
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+import org.mockito.kotlin.argumentCaptor
+import org.mockito.kotlin.mock
+import org.mockito.kotlin.times
+import org.mockito.kotlin.verify
+import org.mockito.kotlin.whenever
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+@RunWithLooper
+class StatusBarNotificationPresenterTest : SysuiTestCase() {
+ private val kosmos = testKosmos()
+
+ private val visualInterruptionDecisionProvider: VisualInterruptionDecisionProvider = mock()
+
+ private var interruptSuppressor: NotificationInterruptSuppressor? = null
+ private var alertsDisabledCondition: VisualInterruptionCondition? = null
+ private var vrModeCondition: VisualInterruptionCondition? = null
+ private var needsRedactionFilter: VisualInterruptionFilter? = null
+ private var panelsDisabledCondition: VisualInterruptionCondition? = null
+
+ private val commandQueue: CommandQueue = CommandQueue(mContext, FakeDisplayTracker(mContext))
+ private val shadeController: ShadeController = mock()
+ private val notificationAlertsInteractor: NotificationAlertsInteractor = mock()
+ private val keyguardStateController: KeyguardStateController = mock()
+
+ private lateinit var underTest: StatusBarNotificationPresenter
+
+ @Before
+ fun setup() {
+ mDependency.injectTestDependency(StatusBarStateController::class.java, mock())
+ mDependency.injectTestDependency(ShadeController::class.java, shadeController)
+ mDependency.injectMockDependency(NotificationRemoteInputManager.Callback::class.java)
+ mDependency.injectMockDependency(NotificationShadeWindowController::class.java)
+
+ whenever(notificationAlertsInteractor.areNotificationAlertsEnabled()).thenReturn(true)
+
+ underTest = createPresenter()
+ if (VisualInterruptionRefactor.isEnabled) {
+ verifyAndCaptureSuppressors()
+ } else {
+ verifyAndCaptureLegacySuppressor()
+ }
+ }
+
+ @Test
+ @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testInit_refactorDisabled() {
+ assertThat(VisualInterruptionRefactor.isEnabled).isFalse()
+ assertThat(alertsDisabledCondition).isNull()
+ assertThat(vrModeCondition).isNull()
+ assertThat(needsRedactionFilter).isNull()
+ assertThat(panelsDisabledCondition).isNull()
+ assertThat(interruptSuppressor).isNotNull()
+ }
+
+ @Test
+ @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testInit_refactorEnabled() {
+ assertThat(VisualInterruptionRefactor.isEnabled).isTrue()
+ assertThat(alertsDisabledCondition).isNotNull()
+ assertThat(vrModeCondition).isNotNull()
+ assertThat(needsRedactionFilter).isNotNull()
+ assertThat(panelsDisabledCondition).isNotNull()
+ assertThat(interruptSuppressor).isNull()
+ }
+
+ @Test
+ @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testNoSuppressHeadsUp_default_refactorDisabled() {
+ assertThat(interruptSuppressor!!.suppressAwakeHeadsUp(createNotificationEntry())).isFalse()
+ }
+
+ @Test
+ @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testNoSuppressHeadsUp_default_refactorEnabled() {
+ assertThat(alertsDisabledCondition!!.shouldSuppress()).isFalse()
+ assertThat(vrModeCondition!!.shouldSuppress()).isFalse()
+ assertThat(needsRedactionFilter!!.shouldSuppress(createNotificationEntry())).isFalse()
+ assertThat(alertsDisabledCondition!!.shouldSuppress()).isFalse()
+ }
+
+ @Test
+ @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testSuppressHeadsUp_disabledStatusBar_refactorDisabled() {
+ commandQueue.disable(
+ DEFAULT_DISPLAY,
+ StatusBarManager.DISABLE_EXPAND,
+ 0,
+ false, /* animate */
+ )
+ TestableLooper.get(this).processAllMessages()
+
+ assertWithMessage("The panel should suppress heads up while disabled")
+ .that(interruptSuppressor!!.suppressAwakeHeadsUp(createNotificationEntry()))
+ .isTrue()
+ }
+
+ @Test
+ @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testSuppressHeadsUp_disabledStatusBar_refactorEnabled() {
+ commandQueue.disable(
+ DEFAULT_DISPLAY,
+ StatusBarManager.DISABLE_EXPAND,
+ 0,
+ false, /* animate */
+ )
+ TestableLooper.get(this).processAllMessages()
+
+ assertWithMessage("The panel should suppress heads up while disabled")
+ .that(panelsDisabledCondition!!.shouldSuppress())
+ .isTrue()
+ }
+
+ @Test
+ @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testSuppressHeadsUp_disabledNotificationShade_refactorDisabled() {
+ commandQueue.disable(
+ DEFAULT_DISPLAY,
+ 0,
+ StatusBarManager.DISABLE2_NOTIFICATION_SHADE,
+ false, /* animate */
+ )
+ TestableLooper.get(this).processAllMessages()
+
+ assertWithMessage(
+ "The panel should suppress interruptions while notification shade disabled"
+ )
+ .that(interruptSuppressor!!.suppressAwakeHeadsUp(createNotificationEntry()))
+ .isTrue()
+ }
+
+ @Test
+ @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testSuppressHeadsUp_disabledNotificationShade_refactorEnabled() {
+ commandQueue.disable(
+ DEFAULT_DISPLAY,
+ 0,
+ StatusBarManager.DISABLE2_NOTIFICATION_SHADE,
+ false, /* animate */
+ )
+ TestableLooper.get(this).processAllMessages()
+
+ assertWithMessage(
+ "The panel should suppress interruptions while notification shade disabled"
+ )
+ .that(panelsDisabledCondition!!.shouldSuppress())
+ .isTrue()
+ }
+
+ @Test
+ @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testPanelsDisabledConditionSuppressesPeek() {
+ val types: Set<VisualInterruptionType> = panelsDisabledCondition!!.types
+ assertThat(types).contains(VisualInterruptionType.PEEK)
+ assertThat(types)
+ .containsNoneOf(VisualInterruptionType.BUBBLE, VisualInterruptionType.PULSE)
+ }
+
+ @Test
+ @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testNoSuppressHeadsUp_FSI_nonOccludedKeyguard_refactorDisabled() {
+ whenever(keyguardStateController.isShowing()).thenReturn(true)
+ whenever(keyguardStateController.isOccluded()).thenReturn(false)
+
+ assertThat(interruptSuppressor!!.suppressAwakeHeadsUp(createFsiNotificationEntry()))
+ .isFalse()
+ }
+
+ @Test
+ @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testNoSuppressHeadsUp_FSI_nonOccludedKeyguard_refactorEnabled() {
+ whenever(keyguardStateController.isShowing()).thenReturn(true)
+ whenever(keyguardStateController.isOccluded()).thenReturn(false)
+
+ assertThat(needsRedactionFilter!!.shouldSuppress(createFsiNotificationEntry())).isFalse()
+
+ val types: Set<VisualInterruptionType> = needsRedactionFilter!!.types
+ assertThat(types).contains(VisualInterruptionType.PEEK)
+ assertThat(types)
+ .containsNoneOf(VisualInterruptionType.BUBBLE, VisualInterruptionType.PULSE)
+ }
+
+ @Test
+ @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testSuppressInterruptions_vrMode_refactorDisabled() {
+ underTest.mVrMode = true
+
+ assertWithMessage("Vr mode should suppress interruptions")
+ .that(interruptSuppressor!!.suppressAwakeInterruptions(createNotificationEntry()))
+ .isTrue()
+ }
+
+ @Test
+ @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testSuppressInterruptions_vrMode_refactorEnabled() {
+ underTest.mVrMode = true
+
+ assertWithMessage("Vr mode should suppress interruptions")
+ .that(vrModeCondition!!.shouldSuppress())
+ .isTrue()
+
+ val types: Set<VisualInterruptionType> = vrModeCondition!!.types
+ assertThat(types).contains(VisualInterruptionType.PEEK)
+ assertThat(types).doesNotContain(VisualInterruptionType.PULSE)
+ assertThat(types).contains(VisualInterruptionType.BUBBLE)
+ }
+
+ @Test
+ @DisableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testSuppressInterruptions_statusBarAlertsDisabled_refactorDisabled() {
+ whenever(notificationAlertsInteractor.areNotificationAlertsEnabled()).thenReturn(false)
+
+ assertWithMessage("When alerts aren't enabled, interruptions are suppressed")
+ .that(interruptSuppressor!!.suppressInterruptions(createNotificationEntry()))
+ .isTrue()
+ }
+
+ @Test
+ @EnableFlags(VisualInterruptionRefactor.FLAG_NAME)
+ fun testSuppressInterruptions_statusBarAlertsDisabled_refactorEnabled() {
+ whenever(notificationAlertsInteractor.areNotificationAlertsEnabled()).thenReturn(false)
+
+ assertWithMessage("When alerts aren't enabled, interruptions are suppressed")
+ .that(alertsDisabledCondition!!.shouldSuppress())
+ .isTrue()
+
+ val types: Set<VisualInterruptionType> = alertsDisabledCondition!!.types
+ assertThat(types).contains(VisualInterruptionType.PEEK)
+ assertThat(types).contains(VisualInterruptionType.PULSE)
+ assertThat(types).contains(VisualInterruptionType.BUBBLE)
+ }
+
+ private fun createPresenter(): StatusBarNotificationPresenter {
+ val shadeViewController: ShadeViewController = mock()
+
+ val notificationShadeWindowView: NotificationShadeWindowView = mock()
+ whenever(notificationShadeWindowView.resources).thenReturn(mContext.resources)
+
+ val stackScrollLayoutController: NotificationStackScrollLayoutController = mock()
+ whenever(stackScrollLayoutController.view).thenReturn(mock())
+
+ val initController: InitController = InitController()
+
+ return StatusBarNotificationPresenter(
+ mContext,
+ shadeViewController,
+ kosmos.panelExpansionInteractor,
+ /* quickSettingsController = */ mock(),
+ kosmos.headsUpManager,
+ notificationShadeWindowView,
+ kosmos.activityStarter,
+ stackScrollLayoutController,
+ kosmos.dozeScrimController,
+ kosmos.notificationShadeWindowController,
+ kosmos.dynamicPrivacyController,
+ keyguardStateController,
+ notificationAlertsInteractor,
+ kosmos.lockscreenShadeTransitionController,
+ kosmos.powerInteractor,
+ commandQueue,
+ kosmos.notificationLockscreenUserManager,
+ kosmos.sysuiStatusBarStateController,
+ /* notifShadeEventSource = */ mock(),
+ /* notificationMediaManager = */ mock(),
+ /* notificationGutsManager = */ mock(),
+ initController,
+ visualInterruptionDecisionProvider,
+ kosmos.notificationRemoteInputManager,
+ /* remoteInputManagerCallback = */ mock(),
+ /* notificationListContainer = */ mock(),
+ )
+ .also { initController.executePostInitTasks() }
+ }
+
+ private fun verifyAndCaptureSuppressors() {
+ interruptSuppressor = null
+
+ val conditionCaptor = argumentCaptor<VisualInterruptionCondition>()
+ verify(visualInterruptionDecisionProvider, times(3)).addCondition(conditionCaptor.capture())
+ val conditions: List<VisualInterruptionCondition> = conditionCaptor.allValues
+ alertsDisabledCondition = conditions[0]
+ vrModeCondition = conditions[1]
+ panelsDisabledCondition = conditions[2]
+
+ val needsRedactionFilterCaptor = argumentCaptor<VisualInterruptionFilter>()
+ verify(visualInterruptionDecisionProvider).addFilter(needsRedactionFilterCaptor.capture())
+ needsRedactionFilter = needsRedactionFilterCaptor.lastValue
+ }
+
+ private fun verifyAndCaptureLegacySuppressor() {
+ alertsDisabledCondition = null
+ vrModeCondition = null
+ needsRedactionFilter = null
+ panelsDisabledCondition = null
+
+ val suppressorCaptor = argumentCaptor<NotificationInterruptSuppressor>()
+ verify(visualInterruptionDecisionProvider).addLegacySuppressor(suppressorCaptor.capture())
+ interruptSuppressor = suppressorCaptor.lastValue
+ }
+
+ private fun createNotificationEntry(): NotificationEntry {
+ return NotificationEntryBuilder()
+ .setPkg("a")
+ .setOpPkg("a")
+ .setTag("a")
+ .setNotification(Builder(mContext, "a").build())
+ .build()
+ }
+
+ private fun createFsiNotificationEntry(): NotificationEntry {
+ val notification: Notification =
+ Builder(mContext, "a").setFullScreenIntent(mock(), true).build()
+
+ return NotificationEntryBuilder()
+ .setPkg("a")
+ .setOpPkg("a")
+ .setTag("a")
+ .setNotification(notification)
+ .build()
+ }
+}
diff --git a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt
index 038722cd9608..bf1fbad074cd 100644
--- a/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt
+++ b/packages/SystemUI/multivalentTests/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModelTest.kt
@@ -20,8 +20,6 @@ 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.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH
-import com.android.settingslib.AccessibilityContentDescriptions.PHONE_SIGNAL_STRENGTH_NONE
import com.android.settingslib.mobile.MobileMappings
import com.android.settingslib.mobile.TelephonyIcons.G
import com.android.settingslib.mobile.TelephonyIcons.THREE_G
@@ -40,12 +38,15 @@ import com.android.systemui.statusbar.connectivity.MobileIconCarrierIdOverridesF
import com.android.systemui.statusbar.pipeline.airplane.data.repository.FakeAirplaneModeRepository
import com.android.systemui.statusbar.pipeline.airplane.domain.interactor.AirplaneModeInteractor
import com.android.systemui.statusbar.pipeline.mobile.data.model.DataConnectionState
+import com.android.systemui.statusbar.pipeline.mobile.data.model.NetworkNameModel
import com.android.systemui.statusbar.pipeline.mobile.data.repository.FakeMobileConnectionRepository
+import com.android.systemui.statusbar.pipeline.mobile.data.repository.FakeMobileConnectionRepository.Companion.DEFAULT_NETWORK_NAME
import com.android.systemui.statusbar.pipeline.mobile.data.repository.FakeMobileConnectionsRepository
import com.android.systemui.statusbar.pipeline.mobile.data.repository.fakeMobileConnectionsRepository
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconInteractorImpl
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractorImpl
import com.android.systemui.statusbar.pipeline.mobile.domain.model.SignalIconModel
+import com.android.systemui.statusbar.pipeline.mobile.ui.model.MobileContentDescription
import com.android.systemui.statusbar.pipeline.mobile.util.FakeMobileMappingsProxy
import com.android.systemui.statusbar.pipeline.shared.ConnectivityConstants
import com.android.systemui.statusbar.pipeline.shared.data.model.ConnectivitySlot
@@ -255,59 +256,146 @@ class MobileIconViewModelTest : SysuiTestCase() {
@Test
fun contentDescription_notInService_usesNoPhone() =
testScope.runTest {
- var latest: ContentDescription? = null
- val job = underTest.contentDescription.onEach { latest = it }.launchIn(this)
+ val latest by collectLastValue(underTest.contentDescription)
repository.isInService.value = false
- assertThat((latest as ContentDescription.Resource).res)
- .isEqualTo(PHONE_SIGNAL_STRENGTH_NONE)
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, NO_SIGNAL))
+ }
- job.cancel()
+ @Test
+ fun contentDescription_includesNetworkName() =
+ testScope.runTest {
+ val latest by collectLastValue(underTest.contentDescription)
+
+ repository.isInService.value = true
+ repository.networkName.value = NetworkNameModel.SubscriptionDerived("Test Network Name")
+ repository.numberOfLevels.value = 5
+ repository.setAllLevels(3)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular("Test Network Name", THREE_BARS))
}
@Test
fun contentDescription_inService_usesLevel() =
testScope.runTest {
- var latest: ContentDescription? = null
- val job = underTest.contentDescription.onEach { latest = it }.launchIn(this)
+ val latest by collectLastValue(underTest.contentDescription)
repository.setAllLevels(2)
- assertThat((latest as ContentDescription.Resource).res)
- .isEqualTo(PHONE_SIGNAL_STRENGTH[2])
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, TWO_BARS))
repository.setAllLevels(0)
- assertThat((latest as ContentDescription.Resource).res)
- .isEqualTo(PHONE_SIGNAL_STRENGTH[0])
- job.cancel()
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, NO_SIGNAL))
}
@Test
- fun contentDescription_nonInflated_invalidLevelIsNull() =
+ fun contentDescription_nonInflated_invalidLevelUsesNoSignalText() =
testScope.runTest {
val latest by collectLastValue(underTest.contentDescription)
repository.inflateSignalStrength.value = false
repository.setAllLevels(-1)
- assertThat(latest).isNull()
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, NO_SIGNAL))
repository.setAllLevels(100)
- assertThat(latest).isNull()
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, NO_SIGNAL))
+ }
+
+ @Test
+ fun contentDescription_nonInflated_levelStrings() =
+ testScope.runTest {
+ val latest by collectLastValue(underTest.contentDescription)
+
+ repository.inflateSignalStrength.value = false
+ repository.setAllLevels(0)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, NO_SIGNAL))
+
+ repository.setAllLevels(1)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, ONE_BAR))
+
+ repository.setAllLevels(2)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, TWO_BARS))
+
+ repository.setAllLevels(3)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, THREE_BARS))
+
+ repository.setAllLevels(4)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, FULL_BARS))
}
@Test
- fun contentDescription_inflated_invalidLevelIsNull() =
+ fun contentDescription_inflated_invalidLevelUsesNoSignalText() =
testScope.runTest {
val latest by collectLastValue(underTest.contentDescription)
repository.inflateSignalStrength.value = true
repository.numberOfLevels.value = 6
+
repository.setAllLevels(-2)
- assertThat(latest).isNull()
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, NO_SIGNAL))
repository.setAllLevels(100)
- assertThat(latest).isNull()
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, NO_SIGNAL))
+ }
+
+ @Test
+ fun contentDescription_inflated_levelStrings() =
+ testScope.runTest {
+ val latest by collectLastValue(underTest.contentDescription)
+
+ repository.inflateSignalStrength.value = true
+ repository.numberOfLevels.value = 6
+
+ // Note that the _repo_ level is 1 lower than the reported level through the interactor
+
+ repository.setAllLevels(0)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, ONE_BAR))
+
+ repository.setAllLevels(1)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, TWO_BARS))
+
+ repository.setAllLevels(2)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, THREE_BARS))
+
+ repository.setAllLevels(3)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, FOUR_BARS))
+
+ repository.setAllLevels(4)
+
+ assertThat(latest as MobileContentDescription.Cellular)
+ .isEqualTo(MobileContentDescription.Cellular(DEFAULT_NETWORK_NAME, FULL_BARS))
}
@Test
@@ -323,7 +411,10 @@ class MobileIconViewModelTest : SysuiTestCase() {
repository.setAllLevels(i)
when (i) {
-1,
- 5 -> assertWithMessage("Level $i is expected to be null").that(latest).isNull()
+ 5 ->
+ assertWithMessage("Level $i is expected to be 'no signal'")
+ .that((latest as MobileContentDescription.Cellular).levelDescriptionRes)
+ .isEqualTo(NO_SIGNAL)
else ->
assertWithMessage("Level $i is expected not to be null")
.that(latest)
@@ -344,7 +435,10 @@ class MobileIconViewModelTest : SysuiTestCase() {
repository.setAllLevels(i)
when (i) {
-2,
- 5 -> assertWithMessage("Level $i is expected to be null").that(latest).isNull()
+ 5 ->
+ assertWithMessage("Level $i is expected to be 'no signal'")
+ .that((latest as MobileContentDescription.Cellular).levelDescriptionRes)
+ .isEqualTo(NO_SIGNAL)
else ->
assertWithMessage("Level $i is not expected to be null")
.that(latest)
@@ -967,5 +1061,13 @@ class MobileIconViewModelTest : SysuiTestCase() {
companion object {
private const val SUB_1_ID = 1
+
+ // For convenience, just define these as constants
+ private val NO_SIGNAL = R.string.accessibility_no_signal
+ private val ONE_BAR = R.string.accessibility_one_bar
+ private val TWO_BARS = R.string.accessibility_two_bars
+ private val THREE_BARS = R.string.accessibility_three_bars
+ private val FOUR_BARS = R.string.accessibility_four_bars
+ private val FULL_BARS = R.string.accessibility_signal_full
}
}
diff --git a/packages/SystemUI/res/values/strings.xml b/packages/SystemUI/res/values/strings.xml
index 05c13f20f6d2..ff459e92ca28 100644
--- a/packages/SystemUI/res/values/strings.xml
+++ b/packages/SystemUI/res/values/strings.xml
@@ -1950,6 +1950,21 @@
<!-- Text displayed indicating that the user might be able to use satellite SOS. -->
<string name="satellite_emergency_only_carrier_text">Emergency calls or SOS</string>
+ <!-- Content description skeleton. Input strings should be carrier name and signal bar description [CHAR LIMIT=NONE]-->
+ <string name="accessibility_phone_string_format"><xliff:g id="carrier_name" example="Carrier Name">%1$s</xliff:g>, <xliff:g id="signal_strength_description" example="two bars">%2$s</xliff:g>.</string>
+ <!-- Content description describing 0 signal bars. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_no_signal">no signal</string>
+ <!-- Content description describing 1 signal bar. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_one_bar">one bar</string>
+ <!-- Content description describing 2 signal bars. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_two_bars">two bars</string>
+ <!-- Content description describing 3 signal bars. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_three_bars">three bars</string>
+ <!-- Content description describing 4 signal bars. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_four_bars">four bars</string>
+ <!-- Content description describing full signal bars. [CHAR LIMIT=NONE] -->
+ <string name="accessibility_signal_full">signal full</string>
+
<!-- Accessibility label for managed profile icon (not shown on screen) [CHAR LIMIT=NONE] -->
<string name="accessibility_managed_profile">Work profile</string>
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/Task.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/Task.java
index 9e8cabf141ed..8576a6ebac42 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/Task.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/Task.java
@@ -330,6 +330,11 @@ public class Task {
}
@Override
+ public int hashCode() {
+ return key.hashCode();
+ }
+
+ @Override
public String toString() {
return "[" + key.toString() + "] " + title;
}
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java
index 559e6f767f7b..ffb5f3d47bcc 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuInfoRepository.java
@@ -20,6 +20,7 @@ import static android.provider.Settings.Secure.ACCESSIBILITY_FLOATING_MENU_FADE_
import static android.provider.Settings.Secure.ACCESSIBILITY_FLOATING_MENU_MIGRATION_TOOLTIP_PROMPT;
import static android.provider.Settings.Secure.ACCESSIBILITY_FLOATING_MENU_OPACITY;
import static android.provider.Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE;
+import static android.provider.Settings.Secure.ENABLED_ACCESSIBILITY_SERVICES;
import static com.android.internal.accessibility.common.ShortcutConstants.UserShortcutType.SOFTWARE;
import static com.android.internal.accessibility.dialog.AccessibilityTargetHelper.getTargets;
@@ -42,6 +43,7 @@ import android.provider.Settings;
import android.text.TextUtils;
import android.util.Log;
import android.view.View;
+import android.view.accessibility.AccessibilityManager;
import androidx.annotation.NonNull;
@@ -75,6 +77,9 @@ class MenuInfoRepository {
private final Context mContext;
private final Configuration mConfiguration;
+ private final AccessibilityManager mAccessibilityManager;
+ private final AccessibilityManager.AccessibilityServicesStateChangeListener
+ mA11yServicesStateChangeListener = manager -> onTargetFeaturesChanged();
private final Handler mHandler = new Handler(Looper.getMainLooper());
private final OnSettingsContentsChanged mSettingsContentsCallback;
private final SecureSettings mSecureSettings;
@@ -142,9 +147,10 @@ class MenuInfoRepository {
}
};
- MenuInfoRepository(Context context,
+ MenuInfoRepository(Context context, AccessibilityManager accessibilityManager,
OnSettingsContentsChanged settingsContentsChanged, SecureSettings secureSettings) {
mContext = context;
+ mAccessibilityManager = accessibilityManager;
mConfiguration = new Configuration(context.getResources().getConfiguration());
mSettingsContentsCallback = settingsContentsChanged;
mSecureSettings = secureSettings;
@@ -238,6 +244,13 @@ class MenuInfoRepository {
mSecureSettings.getUriFor(Settings.Secure.ACCESSIBILITY_BUTTON_TARGETS),
/* notifyForDescendants */ false, mMenuTargetFeaturesContentObserver,
UserHandle.USER_CURRENT);
+ if (!com.android.systemui.Flags.floatingMenuNarrowTargetContentObserver()) {
+ mSecureSettings.registerContentObserverForUserSync(
+ mSecureSettings.getUriFor(ENABLED_ACCESSIBILITY_SERVICES),
+ /* notifyForDescendants */ false,
+ mMenuTargetFeaturesContentObserver,
+ UserHandle.USER_CURRENT);
+ }
mSecureSettings.registerContentObserverForUserSync(
mSecureSettings.getUriFor(Settings.Secure.ACCESSIBILITY_FLOATING_MENU_SIZE),
/* notifyForDescendants */ false, mMenuSizeContentObserver,
@@ -251,6 +264,11 @@ class MenuInfoRepository {
/* notifyForDescendants */ false, mMenuFadeOutContentObserver,
UserHandle.USER_CURRENT);
mContext.registerComponentCallbacks(mComponentCallbacks);
+
+ if (!com.android.systemui.Flags.floatingMenuNarrowTargetContentObserver()) {
+ mAccessibilityManager.addAccessibilityServicesStateChangeListener(
+ mA11yServicesStateChangeListener);
+ }
}
void unregisterObserversAndCallbacks() {
@@ -258,6 +276,11 @@ class MenuInfoRepository {
mContext.getContentResolver().unregisterContentObserver(mMenuSizeContentObserver);
mContext.getContentResolver().unregisterContentObserver(mMenuFadeOutContentObserver);
mContext.unregisterComponentCallbacks(mComponentCallbacks);
+
+ if (!com.android.systemui.Flags.floatingMenuNarrowTargetContentObserver()) {
+ mAccessibilityManager.removeAccessibilityServicesStateChangeListener(
+ mA11yServicesStateChangeListener);
+ }
}
interface OnSettingsContentsChanged {
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java
index cfcaa4fea99b..cb96e7859fba 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerController.java
@@ -42,7 +42,8 @@ class MenuViewLayerController implements IAccessibilityFloatingMenu {
NavigationModeController navigationModeController) {
mWindowManager = viewCaptureAwareWindowManager;
- MenuViewModel menuViewModel = new MenuViewModel(context, secureSettings);
+ MenuViewModel menuViewModel = new MenuViewModel(
+ context, accessibilityManager, secureSettings);
MenuViewAppearance menuViewAppearance = new MenuViewAppearance(context, windowManager);
mMenuViewLayer = new MenuViewLayer(context, windowManager, accessibilityManager,
diff --git a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewModel.java b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewModel.java
index 46c407e24fe2..f924784a5535 100644
--- a/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewModel.java
+++ b/packages/SystemUI/src/com/android/systemui/accessibility/floatingmenu/MenuViewModel.java
@@ -17,6 +17,7 @@
package com.android.systemui.accessibility.floatingmenu;
import android.content.Context;
+import android.view.accessibility.AccessibilityManager;
import androidx.lifecycle.LiveData;
import androidx.lifecycle.MutableLiveData;
@@ -42,9 +43,10 @@ class MenuViewModel implements MenuInfoRepository.OnSettingsContentsChanged {
private final MutableLiveData<Position> mPercentagePositionData = new MutableLiveData<>();
private final MenuInfoRepository mInfoRepository;
- MenuViewModel(Context context, SecureSettings secureSettings) {
- mInfoRepository = new MenuInfoRepository(context, /* settingsContentsChanged= */ this,
- secureSettings);
+ MenuViewModel(Context context, AccessibilityManager accessibilityManager,
+ SecureSettings secureSettings) {
+ mInfoRepository = new MenuInfoRepository(context,
+ accessibilityManager, /* settingsContentsChanged= */ this, secureSettings);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
index 316849d90cf3..d0cb507789a1 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthController.java
@@ -714,12 +714,12 @@ public class AuthController implements
onDialogDismissed(reason);
}
@Inject
- public AuthController(Context context,
+ public AuthController(@Main Context context,
@Application CoroutineScope applicationCoroutineScope,
Execution execution,
CommandQueue commandQueue,
ActivityTaskManager activityTaskManager,
- @NonNull WindowManager windowManager,
+ @NonNull @Main WindowManager windowManager,
@Nullable FingerprintManager fingerprintManager,
@Nullable FaceManager faceManager,
Optional<AuthContextPlugins> contextPlugins,
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt
index f6cc72431db0..22d2aaf2a8e7 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/AuthRippleController.kt
@@ -36,6 +36,7 @@ import com.android.systemui.Flags.lightRevealMigration
import com.android.systemui.biometrics.data.repository.FacePropertyRepository
import com.android.systemui.biometrics.shared.model.UdfpsOverlayParams
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.deviceentry.domain.interactor.AuthRippleInteractor
import com.android.systemui.keyguard.WakefulnessLifecycle
import com.android.systemui.keyguard.shared.model.BiometricUnlockSource
@@ -69,9 +70,9 @@ import javax.inject.Provider
class AuthRippleController
@Inject
constructor(
- private val sysuiContext: Context,
+ @Main private val sysuiContext: Context,
private val authController: AuthController,
- private val configurationController: ConfigurationController,
+ @Main private val configurationController: ConfigurationController,
private val keyguardUpdateMonitor: KeyguardUpdateMonitor,
private val keyguardStateController: KeyguardStateController,
private val wakefulnessLifecycle: WakefulnessLifecycle,
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricNotificationBroadcastReceiver.java b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricNotificationBroadcastReceiver.java
index 027f6744d4d7..8376850c1a28 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricNotificationBroadcastReceiver.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricNotificationBroadcastReceiver.java
@@ -22,6 +22,7 @@ import android.content.Intent;
import android.hardware.biometrics.BiometricSourceType;
import com.android.systemui.dagger.SysUISingleton;
+import com.android.systemui.dagger.qualifiers.Main;
import javax.inject.Inject;
@@ -43,7 +44,7 @@ public class BiometricNotificationBroadcastReceiver extends BroadcastReceiver {
private final BiometricNotificationDialogFactory mNotificationDialogFactory;
@Inject
BiometricNotificationBroadcastReceiver(
- Context context,
+ @Main Context context,
BiometricNotificationDialogFactory notificationDialogFactory) {
mContext = context;
mNotificationDialogFactory = notificationDialogFactory;
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricNotificationService.java b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricNotificationService.java
index 3b49ce2f10f7..e5c22677dbcc 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/BiometricNotificationService.java
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/BiometricNotificationService.java
@@ -45,6 +45,7 @@ import com.android.keyguard.KeyguardUpdateMonitor;
import com.android.keyguard.KeyguardUpdateMonitorCallback;
import com.android.systemui.CoreStartable;
import com.android.systemui.dagger.SysUISingleton;
+import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.res.R;
import com.android.systemui.statusbar.policy.KeyguardStateController;
@@ -145,7 +146,7 @@ public class BiometricNotificationService implements CoreStartable {
};
@Inject
- public BiometricNotificationService(@NonNull Context context,
+ public BiometricNotificationService(@NonNull @Main Context context,
@NonNull KeyguardUpdateMonitor keyguardUpdateMonitor,
@NonNull KeyguardStateController keyguardStateController,
@NonNull Handler handler, @NonNull NotificationManager notificationManager,
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/FingerprintPropertyInteractor.kt b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/FingerprintPropertyInteractor.kt
index 178e1112fa6f..d9ed9ca1f07b 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/FingerprintPropertyInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/FingerprintPropertyInteractor.kt
@@ -24,7 +24,7 @@ import com.android.systemui.biometrics.shared.model.SensorLocation
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.shade.ShadeDisplayAware
+import com.android.systemui.dagger.qualifiers.Main
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.flow.Flow
@@ -43,7 +43,7 @@ constructor(
@Application private val applicationScope: CoroutineScope,
@Application private val context: Context,
repository: FingerprintPropertyRepository,
- @ShadeDisplayAware configurationInteractor: ConfigurationInteractor,
+ @Main configurationInteractor: ConfigurationInteractor,
displayStateInteractor: DisplayStateInteractor,
udfpsOverlayInteractor: UdfpsOverlayInteractor,
) {
diff --git a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsSensorInteractor.kt b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsSensorInteractor.kt
index c3dc2d406cbc..52e85576e756 100644
--- a/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsSensorInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/biometrics/domain/interactor/SideFpsSensorInteractor.kt
@@ -26,6 +26,7 @@ import com.android.systemui.biometrics.shared.model.DisplayRotation
import com.android.systemui.biometrics.shared.model.FingerprintSensorType
import com.android.systemui.biometrics.shared.model.isDefaultOrientation
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyguard.data.repository.BiometricSettingsRepository
import com.android.systemui.keyguard.domain.interactor.KeyguardTransitionInteractor
import com.android.systemui.keyguard.shared.model.KeyguardState
@@ -48,9 +49,9 @@ import kotlinx.coroutines.flow.onEach
class SideFpsSensorInteractor
@Inject
constructor(
- private val context: Context,
+ @Main private val context: Context,
fingerprintPropertyRepository: FingerprintPropertyRepository,
- windowManager: WindowManager,
+ @Main windowManager: WindowManager,
displayStateInteractor: DisplayStateInteractor,
fingerprintInteractiveToAuthProvider: Optional<FingerprintInteractiveToAuthProvider>,
biometricSettingsRepository: BiometricSettingsRepository,
diff --git a/packages/SystemUI/src/com/android/systemui/bouncer/data/repository/EmergencyServicesRepository.kt b/packages/SystemUI/src/com/android/systemui/bouncer/data/repository/EmergencyServicesRepository.kt
index a42ae03b2c4e..cdd1b3c3cf54 100644
--- a/packages/SystemUI/src/com/android/systemui/bouncer/data/repository/EmergencyServicesRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/bouncer/data/repository/EmergencyServicesRepository.kt
@@ -18,7 +18,6 @@ package com.android.systemui.bouncer.data.repository
import android.content.res.Resources
import com.android.internal.R
-import com.android.systemui.common.ui.GlobalConfig
import com.android.systemui.common.ui.data.repository.ConfigurationRepository
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
@@ -37,7 +36,7 @@ class EmergencyServicesRepository
constructor(
@Application private val applicationScope: CoroutineScope,
@Main private val resources: Resources,
- @GlobalConfig configurationRepository: ConfigurationRepository,
+ @Main configurationRepository: ConfigurationRepository,
) {
/**
* Whether to enable emergency services calls while the SIM card is locked. This is disabled in
@@ -49,7 +48,7 @@ constructor(
.stateIn(
scope = applicationScope,
started = SharingStarted.Eagerly,
- initialValue = getEnableEmergencyCallWhileSimLocked()
+ initialValue = getEnableEmergencyCallWhileSimLocked(),
)
private fun getEnableEmergencyCallWhileSimLocked(): Boolean {
diff --git a/packages/SystemUI/src/com/android/systemui/common/ui/ConfigurationModule.kt b/packages/SystemUI/src/com/android/systemui/common/ui/ConfigurationModule.kt
index 7f50e4a06022..ad504d502847 100644
--- a/packages/SystemUI/src/com/android/systemui/common/ui/ConfigurationModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/common/ui/ConfigurationModule.kt
@@ -21,21 +21,11 @@ import com.android.systemui.common.ui.data.repository.ConfigurationRepository
import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractorImpl
import com.android.systemui.dagger.SysUISingleton
-import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.statusbar.policy.ConfigurationController
import dagger.Binds
import dagger.Module
import dagger.Provides
-import javax.inject.Qualifier
-
-/**
- * Annotates elements that provide information from the global configuration.
- *
- * The global configuration is the one associated with the main display. Secondary displays will
- * apply override to the global configuration. Elements annotated with this shouldn't be used for
- * secondary displays.
- */
-@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class GlobalConfig
@Module
interface ConfigurationModule {
@@ -45,32 +35,32 @@ interface ConfigurationModule {
* now, without annotation the global config associated state is provided.
*/
@Binds
- @Deprecated("Use the @GlobalConfig annotated one instead of this.")
+ @Deprecated("Use the @Main annotated one instead of this.")
fun provideGlobalConfigurationState(
- @GlobalConfig configurationState: ConfigurationState
+ @Main configurationState: ConfigurationState
): ConfigurationState
@Binds
- @Deprecated("Use the @GlobalConfig annotated one instead of this.")
+ @Deprecated("Use the @Main annotated one instead of this.")
fun provideDefaultConfigurationState(
- @GlobalConfig configurationState: ConfigurationInteractor
+ @Main configurationState: ConfigurationInteractor
): ConfigurationInteractor
companion object {
@SysUISingleton
@Provides
- @GlobalConfig
+ @Main
fun provideGlobalConfigurationState(
configStateFactory: ConfigurationStateImpl.Factory,
configurationController: ConfigurationController,
- @Application context: Context,
+ @Main context: Context,
): ConfigurationState {
return configStateFactory.create(context, configurationController)
}
@SysUISingleton
@Provides
- @GlobalConfig
+ @Main
fun provideGlobalConfigurationInteractor(
configurationRepository: ConfigurationRepository
): ConfigurationInteractor {
diff --git a/packages/SystemUI/src/com/android/systemui/common/ui/data/repository/ConfigurationRepository.kt b/packages/SystemUI/src/com/android/systemui/common/ui/data/repository/ConfigurationRepository.kt
index df891523798f..4d804d06fe87 100644
--- a/packages/SystemUI/src/com/android/systemui/common/ui/data/repository/ConfigurationRepository.kt
+++ b/packages/SystemUI/src/com/android/systemui/common/ui/data/repository/ConfigurationRepository.kt
@@ -23,9 +23,9 @@ import android.view.DisplayInfo
import androidx.annotation.DimenRes
import com.android.systemui.common.coroutine.ChannelExt.trySendWithFailureLogging
import com.android.systemui.common.coroutine.ConflatedCallbackFlow.conflatedCallbackFlow
-import com.android.systemui.common.ui.GlobalConfig
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Application
+import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.util.wrapper.DisplayUtilsWrapper
import dagger.Binds
@@ -162,19 +162,19 @@ abstract class ConfigurationRepositoryModule {
* injected.
*/
@Binds
- @Deprecated("Use the ConfigurationRepository annotated with @GlobalConfig instead.")
+ @Deprecated("Use the ConfigurationRepository annotated with @Main instead.")
@SysUISingleton
abstract fun provideDefaultConfigRepository(
- @GlobalConfig configurationRepository: ConfigurationRepository
+ @Main configurationRepository: ConfigurationRepository
): ConfigurationRepository
companion object {
@Provides
- @GlobalConfig
+ @Main
@SysUISingleton
fun provideGlobalConfigRepository(
context: Context,
- @GlobalConfig configurationController: ConfigurationController,
+ @Main configurationController: ConfigurationController,
factory: ConfigurationRepositoryImpl.Factory,
): ConfigurationRepository {
return factory.create(context, configurationController)
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
index 78a8a42e2743..9ae106c3ab39 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/FrameworkServicesModule.java
@@ -708,6 +708,14 @@ public class FrameworkServicesModule {
return context.getSystemService(WindowManager.class);
}
+ /** A window manager working for the default display only. */
+ @Provides
+ @Singleton
+ @Main
+ static WindowManager provideMainWindowManager(WindowManager windowManager) {
+ return windowManager;
+ }
+
@Provides
@Singleton
static ViewCaptureAwareWindowManager provideViewCaptureAwareWindowManager(
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/GlobalModule.java b/packages/SystemUI/src/com/android/systemui/dagger/GlobalModule.java
index 3072f74dff2b..ddc88a839a63 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/GlobalModule.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/GlobalModule.java
@@ -21,6 +21,7 @@ import android.util.DisplayMetrics;
import android.view.Display;
import com.android.systemui.dagger.qualifiers.Application;
+import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.plugins.PluginsModule;
import com.android.systemui.unfold.UnfoldTransitionModule;
import com.android.systemui.util.concurrency.GlobalConcurrencyModule;
@@ -62,6 +63,13 @@ public class GlobalModule {
return context.getApplicationContext();
}
+ /** Provides the default content with the main annotation. */
+ @Provides
+ @Main
+ public Context provideMainContext(Context context) {
+ return context;
+ }
+
/**
* @deprecated Deprecdated because {@link Display#getMetrics} is deprecated.
*/
diff --git a/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java b/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java
index 580896cb534e..00eead6eb7fc 100644
--- a/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java
+++ b/packages/SystemUI/src/com/android/systemui/dagger/SysUIComponent.java
@@ -21,7 +21,7 @@ import com.android.systemui.CoreStartable;
import com.android.systemui.Dependency;
import com.android.systemui.InitController;
import com.android.systemui.SystemUIAppComponentFactoryBase;
-import com.android.systemui.common.ui.GlobalConfig;
+import com.android.systemui.dagger.qualifiers.Main;
import com.android.systemui.dagger.qualifiers.PerUser;
import com.android.systemui.dump.DumpManager;
import com.android.systemui.keyguard.KeyguardSliceProvider;
@@ -128,14 +128,14 @@ public interface SysUIComponent {
* Creates a ConfigurationController.
*/
@SysUISingleton
- @GlobalConfig
+ @Main
ConfigurationController getConfigurationController();
/**
* Creates a ConfigurationForwarder.
*/
@SysUISingleton
- @GlobalConfig
+ @Main
ConfigurationForwarder getConfigurationForwarder();
/**
diff --git a/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt b/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt
index 84a423e226b4..c3e6f0c6b280 100644
--- a/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/keyboard/docking/ui/viewmodel/KeyboardDockingIndicationViewModel.kt
@@ -21,11 +21,10 @@ import android.view.Surface
import android.view.WindowManager
import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.settingslib.Utils
-import com.android.systemui.common.ui.GlobalConfig
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.dagger.qualifiers.Background
+import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.keyboard.docking.domain.interactor.KeyboardDockingIndicationInteractor
import com.android.systemui.surfaceeffects.glowboxeffect.GlowBoxConfig
import javax.inject.Inject
@@ -37,10 +36,10 @@ import kotlinx.coroutines.flow.asStateFlow
class KeyboardDockingIndicationViewModel
@Inject
constructor(
- private val windowManager: WindowManager,
- @Application private val context: Context,
+ @Main private val windowManager: WindowManager,
+ @Main private val context: Context,
keyboardDockingIndicationInteractor: KeyboardDockingIndicationInteractor,
- @GlobalConfig configurationInteractor: ConfigurationInteractor,
+ @Main configurationInteractor: ConfigurationInteractor,
@Background private val backgroundScope: CoroutineScope,
) {
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 2a9fe8314349..1e99697e6a33 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
@@ -93,7 +93,7 @@ constructor(
scrubbing = false,
elapsedTime = null,
duration = 0,
- listening = false
+ listening = false,
)
set(value) {
val enabledChanged = value.enabled != field.enabled
@@ -135,7 +135,6 @@ constructor(
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)
@@ -323,7 +322,7 @@ constructor(
bgExecutor.executeRepeatedly(
this::checkPlaybackPosition,
0L,
- POSITION_UPDATE_INTERVAL_MILLIS
+ POSITION_UPDATE_INTERVAL_MILLIS,
)
cancel = Runnable {
cancelPolling.run()
@@ -331,6 +330,7 @@ constructor(
}
}
} else {
+ checkPlaybackPosition()
cancel?.run()
cancel = null
}
@@ -542,7 +542,7 @@ constructor(
eventStart: MotionEvent?,
event: MotionEvent,
distanceX: Float,
- distanceY: Float
+ distanceY: Float,
): Boolean {
return shouldGoToSeekBar
}
@@ -556,7 +556,7 @@ constructor(
eventStart: MotionEvent?,
event: MotionEvent,
velocityX: Float,
- velocityY: Float
+ velocityY: Float,
): Boolean {
if (Math.abs(velocityX) > flingVelocity || Math.abs(velocityY) > flingVelocity) {
viewModel.onSeekFalse()
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 4cf6aab30596..5b8ac6408077 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/composefragment/QSFragmentCompose.kt
@@ -33,7 +33,6 @@ import androidx.activity.OnBackPressedDispatcherOwner
import androidx.activity.setViewTreeOnBackPressedDispatcherOwner
import androidx.annotation.VisibleForTesting
import androidx.compose.animation.AnimatedContent
-import androidx.compose.animation.AnimatedVisibility
import androidx.compose.animation.core.tween
import androidx.compose.animation.fadeIn
import androidx.compose.animation.fadeOut
@@ -246,51 +245,57 @@ constructor(
private fun Content() {
PlatformTheme(isDarkTheme = true) {
ProvideShortcutHelperIndication(interactionsConfig = interactionsConfig()) {
- AnimatedVisibility(
- visible = viewModel.isQsVisibleAndAnyShadeExpanded,
- modifier =
- Modifier.graphicsLayer { alpha = viewModel.viewAlpha }
- // Clipping before translation to match QSContainerImpl.onDraw
- .offset {
- IntOffset(x = 0, y = viewModel.viewTranslationY.fastRoundToInt())
- }
- .thenIf(notificationScrimClippingParams.isEnabled) {
- Modifier.notificationScrimClip {
- notificationScrimClippingParams.params
+ if (viewModel.isQsVisibleAndAnyShadeExpanded) {
+ Box(
+ modifier =
+ Modifier.graphicsLayer { alpha = viewModel.viewAlpha }
+ // Clipping before translation to match QSContainerImpl.onDraw
+ .offset {
+ IntOffset(
+ x = 0,
+ y = viewModel.viewTranslationY.fastRoundToInt(),
+ )
}
+ .thenIf(notificationScrimClippingParams.isEnabled) {
+ Modifier.notificationScrimClip {
+ notificationScrimClippingParams.params
+ }
+ }
+ // Disable touches in the whole composable while the mirror is
+ // showing. While the mirror is showing, an ancestor of the
+ // ComposeView is made alpha 0, but touches are still being captured
+ // by the composables.
+ .gesturesDisabled(viewModel.showingMirror)
+ ) {
+ val isEditing by
+ viewModel.containerViewModel.editModeViewModel.isEditing
+ .collectAsStateWithLifecycle()
+ val animationSpecEditMode = tween<Float>(EDIT_MODE_TIME_MILLIS)
+ AnimatedContent(
+ targetState = isEditing,
+ transitionSpec = {
+ fadeIn(animationSpecEditMode) togetherWith
+ fadeOut(animationSpecEditMode)
+ },
+ label = "EditModeAnimatedContent",
+ ) { editing ->
+ if (editing) {
+ val qqsPadding = viewModel.qqsHeaderHeight
+ EditMode(
+ viewModel = viewModel.containerViewModel.editModeViewModel,
+ modifier =
+ Modifier.fillMaxWidth()
+ .padding(top = { qqsPadding })
+ .padding(
+ horizontal = {
+ QuickSettingsShade.Dimensions.Padding
+ .roundToPx()
+ }
+ ),
+ )
+ } else {
+ CollapsableQuickSettingsSTL()
}
- // Disable touches in the whole composable while the mirror is showing.
- // While the mirror is showing, an ancestor of the ComposeView is made
- // alpha 0, but touches are still being captured by the composables.
- .gesturesDisabled(viewModel.showingMirror),
- ) {
- val isEditing by
- viewModel.containerViewModel.editModeViewModel.isEditing
- .collectAsStateWithLifecycle()
- val animationSpecEditMode = tween<Float>(EDIT_MODE_TIME_MILLIS)
- AnimatedContent(
- targetState = isEditing,
- transitionSpec = {
- fadeIn(animationSpecEditMode) togetherWith
- fadeOut(animationSpecEditMode)
- },
- label = "EditModeAnimatedContent",
- ) { editing ->
- if (editing) {
- val qqsPadding = viewModel.qqsHeaderHeight
- EditMode(
- viewModel = viewModel.containerViewModel.editModeViewModel,
- modifier =
- Modifier.fillMaxWidth()
- .padding(top = { qqsPadding })
- .padding(
- horizontal = {
- QuickSettingsShade.Dimensions.Padding.roundToPx()
- }
- ),
- )
- } else {
- CollapsableQuickSettingsSTL()
}
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/EditTileListState.kt b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/EditTileListState.kt
index 114e3c48a7a0..868855840922 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/EditTileListState.kt
+++ b/packages/SystemUI/src/com/android/systemui/qs/panels/ui/compose/EditTileListState.kt
@@ -135,6 +135,9 @@ class EditTileListState(
cell is TileGridCell && cell.tile.tileSpec == draggedTile.tile.tileSpec
}
draggedPosition = Offset.Unspecified
+
+ // Regenerate spacers without the dragged tile
+ regenerateGrid()
}
override fun onDrop() {
diff --git a/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt b/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt
index fc4db0877dbe..b7a3aedc565e 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt
+++ b/packages/SystemUI/src/com/android/systemui/settings/UserTrackerImpl.kt
@@ -31,6 +31,8 @@ import android.os.UserManager
import android.util.Log
import androidx.annotation.GuardedBy
import androidx.annotation.WorkerThread
+import com.android.app.tracing.coroutines.launchTraced as launch
+import com.android.app.tracing.traceSection
import com.android.systemui.Dumpable
import com.android.systemui.dump.DumpManager
import com.android.systemui.flags.FeatureFlagsClassic
@@ -49,7 +51,6 @@ import kotlinx.coroutines.Job
import kotlinx.coroutines.asCoroutineDispatcher
import kotlinx.coroutines.coroutineScope
import kotlinx.coroutines.delay
-import com.android.app.tracing.coroutines.launchTraced as launch
import kotlinx.coroutines.sync.Mutex
/**
@@ -314,7 +315,9 @@ internal constructor(
list.forEach {
val callback = it.callback.get()
if (callback != null) {
- it.executor.execute { action(callback) { latch.countDown() } }
+ it.executor.execute {
+ traceSection({ "$callback" }) { action(callback) { latch.countDown() } }
+ }
} else {
latch.countDown()
}
diff --git a/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSeekBar.java b/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSeekBar.java
index 30b6892731f1..c241f2165c8f 100644
--- a/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSeekBar.java
+++ b/packages/SystemUI/src/com/android/systemui/settings/brightness/ToggleSeekBar.java
@@ -62,7 +62,7 @@ public class ToggleSeekBar extends SeekBar {
} else if (event.getAction() == MotionEvent.ACTION_HOVER_EXIT) {
setHovered(false);
}
- return true;
+ return super.onHoverEvent(event);
}
@Override
diff --git a/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt b/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt
index a002aa53736a..d31868ca0217 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/ShadeDisplayAwareModule.kt
@@ -26,12 +26,12 @@ import android.window.WindowContext
import com.android.systemui.CoreStartable
import com.android.systemui.common.ui.ConfigurationState
import com.android.systemui.common.ui.ConfigurationStateImpl
-import com.android.systemui.common.ui.GlobalConfig
import com.android.systemui.common.ui.data.repository.ConfigurationRepository
import com.android.systemui.common.ui.data.repository.ConfigurationRepositoryImpl
import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractor
import com.android.systemui.common.ui.domain.interactor.ConfigurationInteractorImpl
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.res.R
import com.android.systemui.scene.ui.view.WindowRootView
import com.android.systemui.shade.data.repository.MutableShadeDisplaysRepository
@@ -49,6 +49,7 @@ import dagger.Provides
import dagger.multibindings.ClassKey
import dagger.multibindings.IntoMap
import javax.inject.Provider
+import javax.inject.Qualifier
/**
* Module responsible for managing display-specific components and resources for the notification
@@ -133,7 +134,7 @@ object ShadeDisplayAwareModule {
fun provideShadeWindowConfigurationController(
@ShadeDisplayAware shadeContext: Context,
factory: ConfigurationControllerImpl.Factory,
- @GlobalConfig globalConfigController: ConfigurationController,
+ @Main globalConfigController: ConfigurationController,
): ConfigurationController {
return if (ShadeWindowGoesAround.isEnabled) {
factory.create(shadeContext)
@@ -159,7 +160,7 @@ object ShadeDisplayAwareModule {
factory: ConfigurationStateImpl.Factory,
@ShadeDisplayAware configurationController: ConfigurationController,
@ShadeDisplayAware context: Context,
- @GlobalConfig configurationState: ConfigurationState,
+ @Main configurationState: ConfigurationState,
): ConfigurationState {
return if (ShadeWindowGoesAround.isEnabled) {
factory.create(context, configurationController)
@@ -175,7 +176,7 @@ object ShadeDisplayAwareModule {
factory: ConfigurationRepositoryImpl.Factory,
@ShadeDisplayAware configurationController: ConfigurationController,
@ShadeDisplayAware context: Context,
- @GlobalConfig globalConfigurationRepository: ConfigurationRepository,
+ @Main globalConfigurationRepository: ConfigurationRepository,
): ConfigurationRepository {
return if (ShadeWindowGoesAround.isEnabled) {
factory.create(context, configurationController)
@@ -189,7 +190,7 @@ object ShadeDisplayAwareModule {
@ShadeDisplayAware
fun provideShadeAwareConfigurationInteractor(
@ShadeDisplayAware configurationRepository: ConfigurationRepository,
- @GlobalConfig configurationInteractor: ConfigurationInteractor,
+ @Main configurationInteractor: ConfigurationInteractor,
): ConfigurationInteractor {
return if (ShadeWindowGoesAround.isEnabled) {
ConfigurationInteractorImpl(configurationRepository)
@@ -237,9 +238,23 @@ object ShadeDisplayAwareModule {
CoreStartable.NOP
}
}
+
+ @Provides
+ @ShadeOnDefaultDisplayWhenLocked
+ fun provideShadeOnDefaultDisplayWhenLocked(): Boolean = true
}
@Module
internal interface OptionalShadeDisplayAwareBindings {
@BindsOptionalOf fun bindOptionalOfWindowRootView(): WindowRootView
}
+
+/**
+ * Annotates the boolean value that defines whether the shade window should go back to the default
+ * display when the keyguard is visible.
+ *
+ * As of today (Dec 2024), This is a configuration parameter provided in the dagger graph as the
+ * final policy around keyguard display is still under discussion, and will be evaluated based on
+ * how well this solution behaves from the performance point of view.
+ */
+@Qualifier @Retention(AnnotationRetention.RUNTIME) annotation class ShadeOnDefaultDisplayWhenLocked
diff --git a/packages/SystemUI/src/com/android/systemui/shade/StatusBarLongPressGestureDetector.kt b/packages/SystemUI/src/com/android/systemui/shade/StatusBarLongPressGestureDetector.kt
index ae36e81c7b1f..29c7aa0680d3 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/StatusBarLongPressGestureDetector.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/StatusBarLongPressGestureDetector.kt
@@ -21,13 +21,18 @@ import android.view.GestureDetector
import android.view.GestureDetector.SimpleOnGestureListener
import android.view.MotionEvent
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Main
import javax.inject.Inject
/** Accepts touch events, detects long press, and calls ShadeViewController#onStatusBarLongPress. */
@SysUISingleton
class StatusBarLongPressGestureDetector
@Inject
-constructor(context: Context, val shadeViewController: ShadeViewController) {
+constructor(
+ // TODO b/383125226 - Make this class per-display
+ @Main context: Context,
+ val shadeViewController: ShadeViewController,
+) {
val gestureDetector =
GestureDetector(
context,
diff --git a/packages/SystemUI/src/com/android/systemui/shade/display/StatusBarTouchShadeDisplayPolicy.kt b/packages/SystemUI/src/com/android/systemui/shade/display/StatusBarTouchShadeDisplayPolicy.kt
index 22e9487af84c..30b086f03d66 100644
--- a/packages/SystemUI/src/com/android/systemui/shade/display/StatusBarTouchShadeDisplayPolicy.kt
+++ b/packages/SystemUI/src/com/android/systemui/shade/display/StatusBarTouchShadeDisplayPolicy.kt
@@ -22,34 +22,55 @@ import com.android.app.tracing.coroutines.launchTraced
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
import com.android.systemui.display.data.repository.DisplayRepository
+import com.android.systemui.keyguard.data.repository.KeyguardRepository
+import com.android.systemui.shade.ShadeOnDefaultDisplayWhenLocked
import com.android.systemui.shade.shared.flag.ShadeWindowGoesAround
import javax.inject.Inject
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.MutableStateFlow
+import kotlinx.coroutines.flow.SharingStarted
import kotlinx.coroutines.flow.StateFlow
import kotlinx.coroutines.flow.collectLatest
+import kotlinx.coroutines.flow.combine
import kotlinx.coroutines.flow.distinctUntilChanged
import kotlinx.coroutines.flow.map
+import kotlinx.coroutines.flow.stateIn
/**
* Moves the shade on the last display that received a status bar touch.
*
- * If the display is removed, falls back to the default one.
+ * If the display is removed, falls back to the default one. When [shadeOnDefaultDisplayWhenLocked]
+ * is true, the shade falls back to the default display when the keyguard is visible.
*/
@SysUISingleton
class StatusBarTouchShadeDisplayPolicy
@Inject
-constructor(displayRepository: DisplayRepository, @Background val backgroundScope: CoroutineScope) :
- ShadeDisplayPolicy {
- override val name: String
- get() = "status_bar_latest_touch"
+constructor(
+ displayRepository: DisplayRepository,
+ keyguardRepository: KeyguardRepository,
+ @Background val backgroundScope: CoroutineScope,
+ @ShadeOnDefaultDisplayWhenLocked val shadeOnDefaultDisplayWhenLocked: Boolean,
+) : ShadeDisplayPolicy {
+ override val name: String = "status_bar_latest_touch"
private val currentDisplayId = MutableStateFlow(Display.DEFAULT_DISPLAY)
private val availableDisplayIds: StateFlow<Set<Int>> = displayRepository.displayIds
- override val displayId: StateFlow<Int>
- get() = currentDisplayId
+ override val displayId: StateFlow<Int> =
+ if (shadeOnDefaultDisplayWhenLocked) {
+ keyguardRepository.isKeyguardShowing
+ .combine(currentDisplayId) { isKeyguardShowing, currentDisplayId ->
+ if (isKeyguardShowing) {
+ Display.DEFAULT_DISPLAY
+ } else {
+ currentDisplayId
+ }
+ }
+ .stateIn(backgroundScope, SharingStarted.WhileSubscribed(), currentDisplayId.value)
+ } else {
+ currentDisplayId
+ }
private var removalListener: Job? = null
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractor.kt
index 571a3e44d233..bbecde830a9f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/interactor/SingleNotificationChipInteractor.kt
@@ -57,6 +57,14 @@ constructor(
// top-level tag. It should instead be provided as the first string in each log message.
private val extraLogTag = "SingleChipInteractor[key=$key]"
+ init {
+ if (startingModel.promotedContent == null) {
+ logger.e({ "$str1: Starting model has promotedContent=null, which shouldn't happen" }) {
+ str1 = extraLogTag
+ }
+ }
+ }
+
private val _notificationModel = MutableStateFlow(startingModel)
/**
@@ -71,6 +79,14 @@ constructor(
}
return
}
+ if (model.promotedContent == null) {
+ logger.e({
+ "$str1: received model with promotedContent=null, which shouldn't happen"
+ }) {
+ str1 = extraLogTag
+ }
+ return
+ }
_notificationModel.value = model
}
@@ -99,6 +115,15 @@ constructor(
}
private fun ActiveNotificationModel.toNotificationChipModel(): NotificationChipModel? {
+ val promotedContent = this.promotedContent
+ if (promotedContent == null) {
+ logger.w({
+ "$str1: Can't show chip because promotedContent=null, which shouldn't happen"
+ }) {
+ str1 = extraLogTag
+ }
+ return null
+ }
val statusBarChipIconView = this.statusBarChipIconView
if (statusBarChipIconView == null) {
if (!StatusBarConnectedDisplays.isEnabled) {
@@ -111,7 +136,8 @@ constructor(
return null
}
}
- return NotificationChipModel(key, statusBarChipIconView, whenTime)
+
+ return NotificationChipModel(key, statusBarChipIconView, whenTime, promotedContent)
}
@AssistedFactory
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/model/NotificationChipModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/model/NotificationChipModel.kt
index 4588b19bd720..9f0638baec83 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/model/NotificationChipModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/domain/model/NotificationChipModel.kt
@@ -17,10 +17,13 @@
package com.android.systemui.statusbar.chips.notification.domain.model
import com.android.systemui.statusbar.StatusBarIconView
+import com.android.systemui.statusbar.notification.promoted.shared.model.PromotedNotificationContentModel
/** Modeling all the data needed to render a status bar notification chip. */
data class NotificationChipModel(
val key: String,
val statusBarChipIconView: StatusBarIconView?,
+ // TODO(b/364653005): Use [PromotedNotificationContentModel.time] instead of a custom field.
val whenTime: Long,
+ val promotedContent: PromotedNotificationContentModel,
)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt
index 2cd5bb339072..e2c886a0f680 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/notification/ui/viewmodel/NotifChipsViewModel.kt
@@ -59,8 +59,11 @@ constructor(
StatusBarConnectedDisplays.assertInNewMode()
OngoingActivityChipModel.ChipIcon.StatusBarNotificationIcon(this.key)
}
- // TODO(b/364653005): Use the notification color if applicable.
- val colors = ColorsModel.Themed
+ val colors =
+ ColorsModel.Custom(
+ backgroundColorInt = this.promotedContent.colors.backgroundColor,
+ primaryTextColorInt = this.promotedContent.colors.primaryTextColor,
+ )
val onClickListener =
View.OnClickListener {
// The notification pipeline needs everything to run on the main thread, so keep
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/ColorsModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/ColorsModel.kt
index 4de4597d0dd7..efedf41e4684 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/ColorsModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/chips/ui/model/ColorsModel.kt
@@ -40,20 +40,25 @@ sealed interface ColorsModel {
}
/**
- * The chip should have the given background color, and text color that matches dark/light
- * theme.
+ * The chip should have the given background color and primary text color.
+ *
+ * If [primaryTextColorInt] is null, the text color will match the current UI mode (light/dark).
*/
- data class Custom(val backgroundColorInt: Int) : ColorsModel {
+ data class Custom(val backgroundColorInt: Int, val primaryTextColorInt: Int? = null) :
+ ColorsModel {
override fun background(context: Context): ColorStateList =
ColorStateList.valueOf(backgroundColorInt)
- // TODO(b/361346412): When dark theme changes, the chip should automatically re-render with
+ // TODO(b/361346412): When UI mode changes, the chip should automatically re-render with
// the right text color. Right now, it has the right text color when the chip is first
- // created but the color doesn't update if dark theme changes.
- override fun text(context: Context) =
- context.getColor(
- com.android.internal.R.color.materialColorOnSurface
- )
+ // created but the color doesn't update if UI mode changes.
+ override fun text(context: Context): Int {
+ return primaryTextColorInt
+ ?: Utils.getColorAttrDefaultColor(
+ context,
+ com.android.internal.R.color.materialColorOnSurface,
+ )
+ }
}
/** The chip should have a red background with white text. */
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarConfigurationControllerStore.kt b/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarConfigurationControllerStore.kt
index 280d66bcb827..6cf2c73a7138 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarConfigurationControllerStore.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/data/repository/StatusBarConfigurationControllerStore.kt
@@ -18,9 +18,9 @@ package com.android.systemui.statusbar.data.repository
import android.view.WindowManager.LayoutParams.TYPE_STATUS_BAR
import com.android.systemui.CoreStartable
-import com.android.systemui.common.ui.GlobalConfig
import com.android.systemui.dagger.SysUISingleton
import com.android.systemui.dagger.qualifiers.Background
+import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.display.data.repository.DisplayRepository
import com.android.systemui.display.data.repository.DisplayWindowPropertiesRepository
import com.android.systemui.display.data.repository.PerDisplayStore
@@ -74,7 +74,7 @@ constructor(
@SysUISingleton
class SingleDisplayStatusBarConfigurationControllerStore
@Inject
-constructor(@GlobalConfig globalConfigurationController: ConfigurationController) :
+constructor(@Main globalConfigurationController: ConfigurationController) :
StatusBarConfigurationControllerStore,
PerDisplayStore<StatusBarConfigurationController> by SingleDisplayStore(
globalConfigurationController as StatusBarConfigurationController
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImpl.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImpl.java
index 0b188afa1c35..d0c02f77f382 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/headsup/HeadsUpManagerImpl.java
@@ -183,7 +183,7 @@ public class HeadsUpManagerImpl
@Inject
public HeadsUpManagerImpl(
- @NonNull final Context context,
+ @NonNull @ShadeDisplayAware final Context context,
HeadsUpManagerLogger logger,
StatusBarStateController statusBarStateController,
KeyguardBypassController bypassController,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconBuilder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconBuilder.kt
index 0f19d7288f6f..9dc3ed29570b 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconBuilder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/icon/IconBuilder.kt
@@ -18,13 +18,14 @@ package com.android.systemui.statusbar.notification.icon
import android.app.Notification
import android.content.Context
+import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.statusbar.StatusBarIconView
import com.android.systemui.statusbar.notification.collection.NotificationEntry
import com.android.systemui.statusbar.notification.contentDescForNotification
import javax.inject.Inject
/** Testable wrapper around Context. */
-class IconBuilder @Inject constructor(private val context: Context) {
+class IconBuilder @Inject constructor(@Main private val context: Context) {
@JvmOverloads
fun createIconView(
entry: NotificationEntry,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/PromotedNotificationContentExtractor.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/PromotedNotificationContentExtractor.kt
index 38eaf27ad358..e122ca888f45 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/PromotedNotificationContentExtractor.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/PromotedNotificationContentExtractor.kt
@@ -77,6 +77,13 @@ constructor(
contentBuilder.text = notification.text()
contentBuilder.skeletonLargeIcon = null // TODO
+ val colorsFromNotif = recoveredBuilder.getColors(/* header= */ false)
+ contentBuilder.colors =
+ PromotedNotificationContentModel.Colors(
+ backgroundColor = colorsFromNotif.backgroundColor,
+ primaryTextColor = colorsFromNotif.primaryTextColor,
+ )
+
recoveredBuilder.style?.extractContent(contentBuilder)
?: run { contentBuilder.style = Style.Ineligible }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/shared/model/PromotedNotificationContentModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/shared/model/PromotedNotificationContentModel.kt
index 41ee3b992c5a..0af40437828e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/shared/model/PromotedNotificationContentModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/promoted/shared/model/PromotedNotificationContentModel.kt
@@ -18,6 +18,7 @@ package com.android.systemui.statusbar.notification.promoted.shared.model
import android.annotation.DrawableRes
import android.graphics.drawable.Icon
+import androidx.annotation.ColorInt
import com.android.internal.widget.NotificationProgressModel
import com.android.systemui.statusbar.chips.notification.shared.StatusBarNotifChips
import com.android.systemui.statusbar.notification.promoted.PromotedNotificationUi
@@ -39,6 +40,7 @@ data class PromotedNotificationContentModel(
val title: CharSequence?,
val text: CharSequence?,
val skeletonLargeIcon: Icon?, // TODO(b/377568176): Make into an IconModel.
+ val colors: Colors,
val style: Style,
// for CallStyle:
@@ -61,6 +63,7 @@ data class PromotedNotificationContentModel(
var text: CharSequence? = null
var skeletonLargeIcon: Icon? = null
var style: Style = Style.Ineligible
+ var colors: Colors = Colors(backgroundColor = 0, primaryTextColor = 0)
// for CallStyle:
var personIcon: Icon? = null
@@ -83,6 +86,7 @@ data class PromotedNotificationContentModel(
title = title,
text = text,
skeletonLargeIcon = skeletonLargeIcon,
+ colors = colors,
style = style,
personIcon = personIcon,
personName = personName,
@@ -102,6 +106,9 @@ data class PromotedNotificationContentModel(
}
}
+ /** The colors used to display the notification. */
+ data class Colors(@ColorInt val backgroundColor: Int, @ColorInt val primaryTextColor: Int)
+
/** The promotion-eligible style of a notification, or [Style.Ineligible] if not. */
enum class Style {
BigPicture,
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt
index a8d59d83d1e9..6bfc9f07ffc4 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/row/ChannelEditorDialogController.kt
@@ -40,6 +40,7 @@ import android.widget.TextView
import com.android.internal.annotations.VisibleForTesting
import com.android.systemui.res.R
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.shade.ShadeDisplayAware
import javax.inject.Inject
private const val TAG = "ChannelDialogController"
@@ -58,11 +59,10 @@ private const val TAG = "ChannelDialogController"
*/
@SysUISingleton
class ChannelEditorDialogController @Inject constructor(
- c: Context,
+ @ShadeDisplayAware private val context: Context,
private val noMan: INotificationManager,
private val dialogBuilder: ChannelEditorDialog.Builder
) {
- val context: Context = c.applicationContext
private var prepared = false
private lateinit var dialog: ChannelEditorDialog
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerStartable.kt b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerStartable.kt
index 8f4279e80376..a324e6df8a33 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerStartable.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ConfigurationControllerStartable.kt
@@ -17,8 +17,8 @@
package com.android.systemui.statusbar.phone
import com.android.systemui.CoreStartable
-import com.android.systemui.common.ui.GlobalConfig
import com.android.systemui.dagger.SysUISingleton
+import com.android.systemui.dagger.qualifiers.Main
import com.android.systemui.statusbar.policy.ConfigurationController
import com.android.systemui.statusbar.policy.ConfigurationController.ConfigurationListener
import javax.inject.Inject
@@ -27,8 +27,8 @@ import javax.inject.Inject
class ConfigurationControllerStartable
@Inject
constructor(
- @GlobalConfig private val configurationController: ConfigurationController,
- private val listeners: Set<@JvmSuppressWildcards ConfigurationListener>
+ @Main private val configurationController: ConfigurationController,
+ private val listeners: Set<@JvmSuppressWildcards ConfigurationListener>,
) : CoreStartable {
override fun start() {
listeners.forEach { configurationController.addCallback(it) }
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileContentDescriptionViewBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileContentDescriptionViewBinder.kt
new file mode 100644
index 000000000000..c720b1df1e62
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileContentDescriptionViewBinder.kt
@@ -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 com.android.systemui.statusbar.pipeline.mobile.ui.binder
+
+import android.view.View
+import com.android.systemui.statusbar.pipeline.mobile.ui.model.MobileContentDescription
+
+object MobileContentDescriptionViewBinder {
+ fun bind(contentDescription: MobileContentDescription?, view: View) {
+ view.contentDescription =
+ when (contentDescription) {
+ null -> null
+ else -> contentDescription.loadContentDescription(view.context)
+ }
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt
index 31d349eb4cca..788f041b38c0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/binder/MobileIconBinder.kt
@@ -29,9 +29,9 @@ import androidx.core.view.isVisible
import androidx.lifecycle.Lifecycle
import androidx.lifecycle.lifecycleScope
import androidx.lifecycle.repeatOnLifecycle
+import com.android.app.tracing.coroutines.launchTraced as launch
import com.android.settingslib.graph.SignalDrawable
import com.android.systemui.Flags.statusBarStaticInoutIndicators
-import com.android.systemui.common.ui.binder.ContentDescriptionViewBinder
import com.android.systemui.common.ui.binder.IconViewBinder
import com.android.systemui.lifecycle.repeatWhenAttached
import com.android.systemui.plugins.DarkIconDispatcher
@@ -48,12 +48,8 @@ import com.android.systemui.statusbar.pipeline.shared.ui.binder.StatusBarViewBin
import kotlinx.coroutines.awaitCancellation
import kotlinx.coroutines.flow.MutableStateFlow
import kotlinx.coroutines.flow.distinctUntilChanged
-import com.android.app.tracing.coroutines.launchTraced as launch
-private data class Colors(
- @ColorInt val tint: Int,
- @ColorInt val contrast: Int,
-)
+private data class Colors(@ColorInt val tint: Int, @ColorInt val contrast: Int)
object MobileIconBinder {
/** Binds the view to the view-model, continuing to update the former based on the latter */
@@ -87,7 +83,7 @@ object MobileIconBinder {
MutableStateFlow(
Colors(
tint = DarkIconDispatcher.DEFAULT_ICON_TINT,
- contrast = DarkIconDispatcher.DEFAULT_INVERSE_ICON_TINT
+ contrast = DarkIconDispatcher.DEFAULT_INVERSE_ICON_TINT,
)
)
val decorTint: MutableStateFlow<Int> = MutableStateFlow(viewModel.defaultColor)
@@ -105,7 +101,7 @@ object MobileIconBinder {
viewModel.verboseLogger?.logBinderReceivedVisibility(
view,
viewModel.subscriptionId,
- isVisible
+ isVisible,
)
view.isVisible = isVisible
// [StatusIconContainer] can get out of sync sometimes. Make sure to
@@ -152,7 +148,7 @@ object MobileIconBinder {
launch {
viewModel.contentDescription.distinctUntilChanged().collect {
- ContentDescriptionViewBinder.bind(it, view)
+ MobileContentDescriptionViewBinder.bind(it, view)
}
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/model/MobileContentDescription.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/model/MobileContentDescription.kt
new file mode 100644
index 000000000000..84fa07379a49
--- /dev/null
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/model/MobileContentDescription.kt
@@ -0,0 +1,43 @@
+/*
+ * 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.statusbar.pipeline.mobile.ui.model
+
+import android.annotation.StringRes
+import android.content.Context
+import com.android.systemui.res.R
+
+sealed interface MobileContentDescription {
+ fun loadContentDescription(context: Context): String
+
+ /**
+ * Content description for cellular parameterizes the [networkName] which comes from the system
+ */
+ data class Cellular(val networkName: String, @StringRes val levelDescriptionRes: Int) :
+ MobileContentDescription {
+ override fun loadContentDescription(context: Context): String =
+ context.getString(
+ R.string.accessibility_phone_string_format,
+ networkName,
+ context.getString(levelDescriptionRes),
+ )
+ }
+
+ data class SatelliteContentDescription(@StringRes val resId: Int) : MobileContentDescription {
+ override fun loadContentDescription(context: Context): String =
+ context.getString(this.resId)
+ }
+}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt
index 103b0e3a6f27..0bd3426712bd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/pipeline/mobile/ui/viewmodel/MobileIconViewModel.kt
@@ -16,7 +16,6 @@
package com.android.systemui.statusbar.pipeline.mobile.ui.viewmodel
-import com.android.settingslib.AccessibilityContentDescriptions
import com.android.systemui.Flags.statusBarStaticInoutIndicators
import com.android.systemui.common.shared.model.ContentDescription
import com.android.systemui.common.shared.model.Icon
@@ -28,6 +27,7 @@ import com.android.systemui.statusbar.pipeline.airplane.domain.interactor.Airpla
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconInteractor
import com.android.systemui.statusbar.pipeline.mobile.domain.interactor.MobileIconsInteractor
import com.android.systemui.statusbar.pipeline.mobile.domain.model.SignalIconModel
+import com.android.systemui.statusbar.pipeline.mobile.ui.model.MobileContentDescription
import com.android.systemui.statusbar.pipeline.shared.ConnectivityConstants
import com.android.systemui.statusbar.pipeline.shared.data.model.DataActivityModel
import kotlinx.coroutines.CoroutineScope
@@ -50,7 +50,7 @@ interface MobileIconViewModelCommon {
/** True if this view should be visible at all. */
val isVisible: StateFlow<Boolean>
val icon: Flow<SignalIconModel>
- val contentDescription: Flow<ContentDescription?>
+ val contentDescription: Flow<MobileContentDescription?>
val roaming: Flow<Boolean>
/** The RAT icon (LTE, 3G, 5G, etc) to be displayed. Null if we shouldn't show anything */
val networkTypeIcon: Flow<Icon.Resource?>
@@ -95,10 +95,7 @@ class MobileIconViewModel(
}
private val satelliteProvider by lazy {
- CarrierBasedSatelliteViewModelImpl(
- subscriptionId,
- iconInteractor,
- )
+ CarrierBasedSatelliteViewModelImpl(subscriptionId, iconInteractor)
}
/**
@@ -123,7 +120,7 @@ class MobileIconViewModel(
override val icon: Flow<SignalIconModel> = vmProvider.flatMapLatest { it.icon }
- override val contentDescription: Flow<ContentDescription?> =
+ override val contentDescription: Flow<MobileContentDescription?> =
vmProvider.flatMapLatest { it.contentDescription }
override val roaming: Flow<Boolean> = vmProvider.flatMapLatest { it.roaming }
@@ -154,8 +151,7 @@ private class CarrierBasedSatelliteViewModelImpl(
override val isVisible: StateFlow<Boolean> = MutableStateFlow(true)
override val icon: Flow<SignalIconModel> = interactor.signalLevelIcon
- override val contentDescription: Flow<ContentDescription> =
- MutableStateFlow(ContentDescription.Loaded(""))
+ override val contentDescription: Flow<MobileContentDescription?> = MutableStateFlow(null)
/** These fields are not used for satellite icons currently */
override val roaming: Flow<Boolean> = flowOf(false)
@@ -206,27 +202,42 @@ private class CellularIconViewModel(
override val icon: Flow<SignalIconModel> = iconInteractor.signalLevelIcon
- override val contentDescription: Flow<ContentDescription?> =
- iconInteractor.signalLevelIcon
- .map {
- // We expect the signal icon to be cellular here since this is the cellular vm
- if (it !is SignalIconModel.Cellular) {
- null
- } else {
- val resId =
- AccessibilityContentDescriptions.getDescriptionForLevel(
- it.level,
- it.numberOfLevels
+ override val contentDescription: Flow<MobileContentDescription?> =
+ combine(iconInteractor.signalLevelIcon, iconInteractor.networkName) { icon, nameModel ->
+ when (icon) {
+ is SignalIconModel.Cellular ->
+ MobileContentDescription.Cellular(
+ nameModel.name,
+ icon.levelDescriptionRes(),
)
- if (resId != 0) {
- ContentDescription.Resource(resId)
- } else {
- null
- }
+ else -> null
}
}
.stateIn(scope, SharingStarted.WhileSubscribed(), null)
+ private fun SignalIconModel.Cellular.levelDescriptionRes() =
+ when (level) {
+ 0 -> R.string.accessibility_no_signal
+ 1 -> R.string.accessibility_one_bar
+ 2 -> R.string.accessibility_two_bars
+ 3 -> R.string.accessibility_three_bars
+ 4 -> {
+ if (numberOfLevels == 6) {
+ R.string.accessibility_four_bars
+ } else {
+ R.string.accessibility_signal_full
+ }
+ }
+ 5 -> {
+ if (numberOfLevels == 6) {
+ R.string.accessibility_signal_full
+ } else {
+ R.string.accessibility_no_signal
+ }
+ }
+ else -> R.string.accessibility_no_signal
+ }
+
private val showNetworkTypeIcon: Flow<Boolean> =
combine(
iconInteractor.isDataConnected,
@@ -248,10 +259,9 @@ private class CellularIconViewModel(
.stateIn(scope, SharingStarted.WhileSubscribed(), false)
override val networkTypeIcon: Flow<Icon.Resource?> =
- combine(
- iconInteractor.networkTypeIconGroup,
- showNetworkTypeIcon,
- ) { networkTypeIconGroup, shouldShow ->
+ combine(iconInteractor.networkTypeIconGroup, showNetworkTypeIcon) {
+ networkTypeIconGroup,
+ shouldShow ->
val desc =
if (networkTypeIconGroup.contentDescription != 0)
ContentDescription.Resource(networkTypeIconGroup.contentDescription)
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/dagger/StatusBarPolicyModule.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/dagger/StatusBarPolicyModule.java
index 9187e3c43380..d1e807f18196 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/dagger/StatusBarPolicyModule.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/dagger/StatusBarPolicyModule.java
@@ -23,7 +23,6 @@ import android.os.UserManager;
import com.android.internal.R;
import com.android.settingslib.devicestate.DeviceStateRotationLockSettingsManager;
import com.android.settingslib.notification.modes.ZenIconLoader;
-import com.android.systemui.common.ui.GlobalConfig;
import com.android.systemui.dagger.SysUISingleton;
import com.android.systemui.dagger.qualifiers.Application;
import com.android.systemui.dagger.qualifiers.Main;
@@ -111,7 +110,7 @@ public interface StatusBarPolicyModule {
* wrong updates in case of secondary displays.
*/
@Binds
- ConfigurationController bindConfigurationController(@GlobalConfig ConfigurationController impl);
+ ConfigurationController bindConfigurationController(@Main ConfigurationController impl);
/** */
@Binds
@@ -189,14 +188,14 @@ public interface StatusBarPolicyModule {
/** */
@Binds
@SysUISingleton
- @GlobalConfig
+ @Main
ConfigurationForwarder provideGlobalConfigurationForwarder(
- @GlobalConfig ConfigurationController configurationController);
+ @Main ConfigurationController configurationController);
/** */
@Provides
@SysUISingleton
- @GlobalConfig
+ @Main
static ConfigurationController provideGlobalConfigurationController(
@Application Context context, ConfigurationControllerImpl.Factory factory) {
return factory.create(context);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuAnimationControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuAnimationControllerTest.java
index 50d0049dbcd7..dddaabb66022 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuAnimationControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuAnimationControllerTest.java
@@ -26,10 +26,12 @@ import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.verifyNoMoreInteractions;
import android.graphics.PointF;
+
import android.testing.TestableLooper;
import android.view.View;
import android.view.ViewPropertyAnimator;
import android.view.WindowManager;
+import android.view.accessibility.AccessibilityManager;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.FlingAnimation;
@@ -49,6 +51,7 @@ import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.ArgumentCaptor;
+import org.mockito.Mock;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
@@ -69,13 +72,17 @@ public class MenuAnimationControllerTest extends SysuiTestCase {
@Rule
public MockitoRule mockito = MockitoJUnit.rule();
+ @Mock
+ private AccessibilityManager mAccessibilityManager;
+
@Before
public void setUp() throws Exception {
final WindowManager stubWindowManager = mContext.getSystemService(WindowManager.class);
final MenuViewAppearance stubMenuViewAppearance = new MenuViewAppearance(mContext,
stubWindowManager);
final SecureSettings secureSettings = TestUtils.mockSecureSettings();
- final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext, secureSettings);
+ final MenuViewModel stubMenuViewModel = new MenuViewModel(mContext, mAccessibilityManager,
+ secureSettings);
mMenuView = spy(new MenuView(mContext, stubMenuViewModel, stubMenuViewAppearance,
secureSettings));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerTest.java b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerTest.java
index f4580c173579..400b3b388c31 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/accessibility/floatingmenu/MenuViewLayerTest.java
@@ -159,7 +159,8 @@ public class MenuViewLayerTest extends SysuiTestCase {
new WindowMetrics(mDisplayBounds, fakeDisplayInsets(), /* density = */ 0.0f));
doReturn(mWindowMetrics).when(mStubWindowManager).getCurrentWindowMetrics();
- mMenuViewModel = new MenuViewModel(mSpyContext, mSecureSettings);
+ mMenuViewModel = new MenuViewModel(
+ mSpyContext, mStubAccessibilityManager, mSecureSettings);
MenuViewAppearance menuViewAppearance = new MenuViewAppearance(
mSpyContext, mStubWindowManager);
mMenuView = spy(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModelTest.kt b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModelTest.kt
index 4da7b2ac3700..e035a02ecf00 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModelTest.kt
+++ b/packages/SystemUI/tests/src/com/android/systemui/media/controls/ui/viewmodel/SeekBarViewModelTest.kt
@@ -64,9 +64,11 @@ public class SeekBarViewModelTest : SysuiTestCase() {
override fun executeOnDiskIO(runnable: Runnable) {
runnable.run()
}
+
override fun postToMainThread(runnable: Runnable) {
runnable.run()
}
+
override fun isMainThread(): Boolean {
return true
}
@@ -805,4 +807,32 @@ public class SeekBarViewModelTest : SysuiTestCase() {
fakeExecutor.runAllReady()
verify(mockController).unregisterCallback(any())
}
+
+ @Test
+ fun positionUpdatedWhileStopped() {
+ // When playback is stopped at one position
+ val firstPosition = 200L
+ val state =
+ PlaybackState.Builder().run {
+ setState(PlaybackState.STATE_STOPPED, firstPosition, 1f)
+ build()
+ }
+ whenever(mockController.playbackState).thenReturn(state)
+ val captor = ArgumentCaptor.forClass(MediaController.Callback::class.java)
+ viewModel.updateController(mockController)
+ verify(mockController).registerCallback(captor.capture())
+ assertThat(viewModel.progress.value!!.elapsedTime).isEqualTo(firstPosition.toInt())
+
+ // And the state is updated with a new position
+ val secondPosition = 42L
+ val secondState =
+ PlaybackState.Builder().run {
+ setState(PlaybackState.STATE_STOPPED, secondPosition, 1f)
+ build()
+ }
+ captor.value.onPlaybackStateChanged(secondState)
+
+ // THEN then elapsed time should be updated
+ assertThat(viewModel.progress.value!!.elapsedTime).isEqualTo(secondPosition.toInt())
+ }
}
diff --git a/services/core/java/com/android/server/am/BatteryStatsService.java b/services/core/java/com/android/server/am/BatteryStatsService.java
index c27126a01a32..aea24d978bee 100644
--- a/services/core/java/com/android/server/am/BatteryStatsService.java
+++ b/services/core/java/com/android/server/am/BatteryStatsService.java
@@ -1101,6 +1101,9 @@ public final class BatteryStatsService extends IBatteryStats.Stub
/** StatsPullAtomCallback for pulling BatteryUsageStats data. */
private class StatsPullAtomCallbackImpl implements StatsManager.StatsPullAtomCallback {
+ private static final long BATTERY_USAGE_STATS_PER_UID_MAX_STATS_AGE =
+ TimeUnit.HOURS.toMillis(2);
+
@Override
public int onPullAtom(int atomTag, List<StatsEvent> data) {
final BatteryUsageStats bus;
@@ -1168,7 +1171,8 @@ public final class BatteryStatsService extends IBatteryStats.Stub
.setMinConsumedPowerThreshold(minConsumedPowerThreshold);
if (isBatteryUsageStatsAccumulationSupported()) {
- query.accumulated();
+ query.accumulated()
+ .setMaxStatsAgeMs(BATTERY_USAGE_STATS_PER_UID_MAX_STATS_AGE);
}
bus = getBatteryUsageStats(List.of(query.build())).get(0);
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 09b8e212bfad..1799b7715e5c 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -4177,6 +4177,12 @@ public class AudioService extends IAudioService.Stub
// Stream mute changed, fire the intent.
Intent intent = new Intent(AudioManager.STREAM_MUTE_CHANGED_ACTION);
intent.putExtra(AudioManager.EXTRA_STREAM_VOLUME_MUTED, isMuted);
+ if (replaceStreamBtSco() && isStreamBluetoothSco(streamType)) {
+ intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,
+ AudioSystem.STREAM_BLUETOOTH_SCO);
+ // in this case broadcast for both sco and voice_call streams the mute status
+ sendBroadcastToAll(intent, null /* options */);
+ }
intent.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE, streamType);
sendBroadcastToAll(intent, null /* options */);
}
@@ -9670,9 +9676,16 @@ public class AudioService extends IAudioService.Stub
mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_VALUE, index);
mVolumeChanged.putExtra(AudioManager.EXTRA_PREV_VOLUME_STREAM_VALUE,
oldIndex);
-
- mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,
- mStreamType);
+ int extraStreamType = mStreamType;
+ // TODO: remove this when deprecating STREAM_BLUETOOTH_SCO
+ if (isStreamBluetoothSco(mStreamType)) {
+ mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,
+ AudioSystem.STREAM_BLUETOOTH_SCO);
+ extraStreamType = AudioSystem.STREAM_BLUETOOTH_SCO;
+ } else {
+ mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,
+ mStreamType);
+ }
mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE_ALIAS,
streamAlias);
@@ -9683,9 +9696,21 @@ public class AudioService extends IAudioService.Stub
" aliased streams: " + aliasStreamIndexes;
}
AudioService.sVolumeLogger.enqueue(new VolChangedBroadcastEvent(
- mStreamType, aliasStreamIndexesString, index, oldIndex));
+ extraStreamType, aliasStreamIndexesString, index, oldIndex));
+ if (extraStreamType != mStreamType) {
+ AudioService.sVolumeLogger.enqueue(new VolChangedBroadcastEvent(
+ mStreamType, aliasStreamIndexesString, index, oldIndex));
+ }
}
sendBroadcastToAll(mVolumeChanged, mVolumeChangedOptions);
+ if (extraStreamType != mStreamType) {
+ // send multiple intents in case we merged voice call and bt sco streams
+ mVolumeChanged.putExtra(AudioManager.EXTRA_VOLUME_STREAM_TYPE,
+ mStreamType);
+ // do not use the options in thid case which could discard
+ // the previous intent
+ sendBroadcastToAll(mVolumeChanged, null);
+ }
}
}
}
diff --git a/services/core/java/com/android/server/display/DisplayManagerService.java b/services/core/java/com/android/server/display/DisplayManagerService.java
index 452dc5f97d12..0b633bd9c549 100644
--- a/services/core/java/com/android/server/display/DisplayManagerService.java
+++ b/services/core/java/com/android/server/display/DisplayManagerService.java
@@ -2042,7 +2042,7 @@ public final class DisplayManagerService extends SystemService {
// handles stopping the projection.
Slog.w(TAG, "Content Recording: failed to start mirroring - "
+ "releasing virtual display " + displayId);
- releaseVirtualDisplayInternal(callback.asBinder(), callingUid);
+ releaseVirtualDisplayInternal(callback.asBinder());
return Display.INVALID_DISPLAY;
} else if (projection != null) {
// Indicate that this projection has been used to record, and can't be used
@@ -2131,7 +2131,7 @@ public final class DisplayManagerService extends SystemService {
// Something weird happened and the logical display was not created.
Slog.w(TAG, "Rejecting request to create virtual display "
+ "because the logical display was not created.");
- mVirtualDisplayAdapter.releaseVirtualDisplayLocked(callback.asBinder(), callingUid);
+ mVirtualDisplayAdapter.releaseVirtualDisplayLocked(callback.asBinder());
mDisplayDeviceRepo.onDisplayDeviceEvent(device,
DisplayAdapter.DISPLAY_DEVICE_EVENT_REMOVED);
return -1;
@@ -2158,14 +2158,14 @@ public final class DisplayManagerService extends SystemService {
}
}
- private void releaseVirtualDisplayInternal(IBinder appToken, int callingUid) {
+ private void releaseVirtualDisplayInternal(IBinder appToken) {
synchronized (mSyncRoot) {
if (mVirtualDisplayAdapter == null) {
return;
}
DisplayDevice device =
- mVirtualDisplayAdapter.releaseVirtualDisplayLocked(appToken, callingUid);
+ mVirtualDisplayAdapter.releaseVirtualDisplayLocked(appToken);
Slog.d(TAG, "Virtual Display: Display Device released");
if (device != null) {
// TODO: multi-display - handle virtual displays the same as other display adapters.
@@ -4789,10 +4789,9 @@ public final class DisplayManagerService extends SystemService {
@Override // Binder call
public void releaseVirtualDisplay(IVirtualDisplayCallback callback) {
- final int callingUid = Binder.getCallingUid();
final long token = Binder.clearCallingIdentity();
try {
- releaseVirtualDisplayInternal(callback.asBinder(), callingUid);
+ releaseVirtualDisplayInternal(callback.asBinder());
} finally {
Binder.restoreCallingIdentity(token);
}
diff --git a/services/core/java/com/android/server/display/DisplayPowerController.java b/services/core/java/com/android/server/display/DisplayPowerController.java
index ab80b14eee2f..f48fbea64f65 100644
--- a/services/core/java/com/android/server/display/DisplayPowerController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerController.java
@@ -3311,7 +3311,7 @@ final class DisplayPowerController implements AutomaticBrightnessController.Call
int displayId, SensorManager sensorManager) {
return new DisplayPowerProximityStateController(wakelockController, displayDeviceConfig,
looper, nudgeUpdatePowerState,
- displayId, sensorManager, /* injector= */ null);
+ displayId, sensorManager);
}
AutomaticBrightnessController getAutomaticBrightnessController(
diff --git a/services/core/java/com/android/server/display/DisplayPowerProximityStateController.java b/services/core/java/com/android/server/display/DisplayPowerProximityStateController.java
index 215932ca19be..35455c841c7b 100644
--- a/services/core/java/com/android/server/display/DisplayPowerProximityStateController.java
+++ b/services/core/java/com/android/server/display/DisplayPowerProximityStateController.java
@@ -16,6 +16,8 @@
package com.android.server.display;
+import android.annotation.IntDef;
+import android.annotation.Nullable;
import android.hardware.Sensor;
import android.hardware.SensorEvent;
import android.hardware.SensorEventListener;
@@ -34,6 +36,8 @@ import com.android.internal.annotations.VisibleForTesting;
import com.android.server.display.utils.SensorUtils;
import java.io.PrintWriter;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
/**
* Maintains the proximity state of the display.
@@ -42,18 +46,26 @@ import java.io.PrintWriter;
*/
public final class DisplayPowerProximityStateController {
@VisibleForTesting
- static final int MSG_PROXIMITY_SENSOR_DEBOUNCED = 1;
- @VisibleForTesting
static final int PROXIMITY_UNKNOWN = -1;
+ private static final int PROXIMITY_NEGATIVE = 0;
@VisibleForTesting
static final int PROXIMITY_POSITIVE = 1;
+
+ @IntDef(prefix = { "PROXIMITY_" }, value = {
+ PROXIMITY_UNKNOWN,
+ PROXIMITY_NEGATIVE,
+ PROXIMITY_POSITIVE
+ })
+ @Retention(RetentionPolicy.SOURCE)
+ @interface ProximityState {}
+
+ @VisibleForTesting
+ static final int MSG_PROXIMITY_SENSOR_DEBOUNCED = 1;
@VisibleForTesting
static final int PROXIMITY_SENSOR_POSITIVE_DEBOUNCE_DELAY = 0;
private static final int MSG_IGNORE_PROXIMITY = 2;
- private static final int PROXIMITY_NEGATIVE = 0;
-
private static final boolean DEBUG_PRETEND_PROXIMITY_SENSOR_ABSENT = false;
// Proximity sensor debounce delay in milliseconds for positive transitions.
@@ -73,7 +85,7 @@ public final class DisplayPowerProximityStateController {
private final DisplayPowerProximityStateHandler mHandler;
// A runnable to execute the utility to update the power state.
private final Runnable mNudgeUpdatePowerState;
- private Clock mClock;
+ private final Clock mClock;
// A listener which listen's to the events emitted by the proximity sensor.
private final SensorEventListener mProximitySensorListener = new SensorEventListener() {
@Override
@@ -117,9 +129,6 @@ public final class DisplayPowerProximityStateController {
// with the sensor manager.
private boolean mProximitySensorEnabled;
- // The raw non-debounced proximity sensor state.
- private int mPendingProximity = PROXIMITY_UNKNOWN;
-
// -1 if fully debounced. Else, represents the time in ms when the debounce suspend blocker will
// be removed. Applies for both positive and negative proximity flips.
private long mPendingProximityDebounceTime = -1;
@@ -128,8 +137,11 @@ public final class DisplayPowerProximityStateController {
// When the screen turns on again, we report user activity to the power manager.
private boolean mScreenOffBecauseOfProximity;
+ // The raw non-debounced proximity sensor state.
+ private @ProximityState int mPendingProximity = PROXIMITY_UNKNOWN;
+
// The debounced proximity sensor state.
- private int mProximity = PROXIMITY_UNKNOWN;
+ private @ProximityState int mProximity = PROXIMITY_UNKNOWN;
// The actual proximity sensor threshold value.
private float mProximityThreshold;
@@ -139,7 +151,7 @@ public final class DisplayPowerProximityStateController {
private boolean mSkipRampBecauseOfProximityChangeToNegative = false;
// The DisplayId of the associated Logical Display.
- private int mDisplayId;
+ private final int mDisplayId;
/**
* Create a new instance of DisplayPowerProximityStateController.
@@ -152,11 +164,18 @@ public final class DisplayPowerProximityStateController {
* @param displayId The DisplayId of the associated Logical Display.
* @param sensorManager The manager which lets us access the display's ProximitySensor
*/
- public DisplayPowerProximityStateController(
- WakelockController wakeLockController, DisplayDeviceConfig displayDeviceConfig,
- Looper looper,
+ public DisplayPowerProximityStateController(WakelockController wakeLockController,
+ DisplayDeviceConfig displayDeviceConfig, Looper looper,
+ Runnable nudgeUpdatePowerState, int displayId, SensorManager sensorManager) {
+ this(wakeLockController, displayDeviceConfig, looper, nudgeUpdatePowerState, displayId,
+ sensorManager, new Injector());
+ }
+
+ @VisibleForTesting
+ DisplayPowerProximityStateController(WakelockController wakeLockController,
+ DisplayDeviceConfig displayDeviceConfig, Looper looper,
Runnable nudgeUpdatePowerState, int displayId, SensorManager sensorManager,
- Injector injector) {
+ @Nullable Injector injector) {
if (injector == null) {
injector = new Injector();
}
@@ -437,7 +456,7 @@ public final class DisplayPowerProximityStateController {
if (mProximity != mPendingProximity) {
// if the status of the sensor changed, stop ignoring.
mIgnoreProximityUntilChanged = false;
- Slog.i(mTag, "No longer ignoring proximity [" + mPendingProximity + "]");
+ Slog.i(mTag, "Applying proximity: " + proximityToString(mPendingProximity));
}
// Sensor reading accepted. Apply the change then release the wake lock.
mProximity = mPendingProximity;
@@ -478,7 +497,7 @@ public final class DisplayPowerProximityStateController {
}
}
- private String proximityToString(int state) {
+ private String proximityToString(@ProximityState int state) {
switch (state) {
case PROXIMITY_UNKNOWN:
return "Unknown";
@@ -518,12 +537,12 @@ public final class DisplayPowerProximityStateController {
}
@VisibleForTesting
- int getPendingProximity() {
+ @ProximityState int getPendingProximity() {
return mPendingProximity;
}
@VisibleForTesting
- int getProximity() {
+ @ProximityState int getProximity() {
return mProximity;
}
@@ -550,7 +569,7 @@ public final class DisplayPowerProximityStateController {
@VisibleForTesting
static class Injector {
Clock createClock() {
- return () -> SystemClock.uptimeMillis();
+ return SystemClock::uptimeMillis;
}
}
}
diff --git a/services/core/java/com/android/server/display/LogicalDisplayMapper.java b/services/core/java/com/android/server/display/LogicalDisplayMapper.java
index c0903a9bafac..79592a656409 100644
--- a/services/core/java/com/android/server/display/LogicalDisplayMapper.java
+++ b/services/core/java/com/android/server/display/LogicalDisplayMapper.java
@@ -506,9 +506,6 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
return;
}
- Slog.i(TAG, "Requesting Transition to state: " + state.getIdentifier() + ", from state="
- + mDeviceState.getIdentifier() + ", interactive=" + mInteractive
- + ", mBootCompleted=" + mBootCompleted);
// As part of a state transition, we may need to turn off some displays temporarily so that
// the transition is smooth. Plus, on some devices, only one internal displays can be
// on at a time. We use LogicalDisplay.setIsInTransition to mark a display that needs to be
@@ -522,6 +519,11 @@ class LogicalDisplayMapper implements DisplayDeviceRepository.Listener {
final boolean sleepDevice = shouldDeviceBePutToSleep(mPendingDeviceState, mDeviceState,
mInteractive, mBootCompleted);
+ Slog.i(TAG, "Requesting Transition to state: " + state.getIdentifier() + ", from state="
+ + mDeviceState.getIdentifier() + ", interactive=" + mInteractive
+ + ", mBootCompleted=" + mBootCompleted + ", wakeDevice=" + wakeDevice
+ + ", sleepDevice=" + sleepDevice);
+
// If all displays are off already, we can just transition here, unless we are trying to
// wake or sleep the device as part of this transition. In that case defer the final
// transition until later once the device is awake/asleep.
diff --git a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java
index 836f4ede8f57..f14e452ab8d3 100644
--- a/services/core/java/com/android/server/display/VirtualDisplayAdapter.java
+++ b/services/core/java/com/android/server/display/VirtualDisplayAdapter.java
@@ -91,6 +91,13 @@ public class VirtualDisplayAdapter extends DisplayAdapter {
private final ArrayMap<IBinder, VirtualDisplayDevice> mVirtualDisplayDevices = new ArrayMap<>();
+ // When a virtual display is created, the mapping (appToken -> ownerUid) is stored here. That
+ // way, when the display is released later, we can retrieve the ownerUid and decrement
+ // the number of virtual displays that exist for that ownerUid. We can't use
+ // Binder.getCallingUid() because the display might be released by the system process and not
+ // the process that created the display.
+ private final ArrayMap<IBinder, Integer> mOwnerUids = new ArrayMap<>();
+
private final int mMaxDevices;
private final int mMaxDevicesPerPackage;
private final SparseIntArray mNoOfDevicesPerPackage = new SparseIntArray();
@@ -194,6 +201,7 @@ public class VirtualDisplayAdapter extends DisplayAdapter {
mVirtualDisplayDevices.put(appToken, device);
if (getFeatureFlags().isVirtualDisplayLimitEnabled()) {
mNoOfDevicesPerPackage.put(ownerUid, noOfDevices + 1);
+ mOwnerUids.put(appToken, ownerUid);
}
try {
@@ -205,7 +213,7 @@ public class VirtualDisplayAdapter extends DisplayAdapter {
appToken.linkToDeath(device, 0);
} catch (RemoteException ex) {
Slog.e(TAG, "Virtual Display: error while setting up VirtualDisplayDevice", ex);
- removeVirtualDisplayDeviceLocked(appToken, ownerUid);
+ removeVirtualDisplayDeviceLocked(appToken);
device.destroyLocked(false);
return null;
}
@@ -252,12 +260,10 @@ public class VirtualDisplayAdapter extends DisplayAdapter {
/**
* Release a virtual display that was previously created
* @param appToken The token to identify the display
- * @param ownerUid The UID of the package, used to keep track of and limit the number of
- * displays created per package
* @return The display device that has been removed
*/
- public DisplayDevice releaseVirtualDisplayLocked(IBinder appToken, int ownerUid) {
- VirtualDisplayDevice device = removeVirtualDisplayDeviceLocked(appToken, ownerUid);
+ public DisplayDevice releaseVirtualDisplayLocked(IBinder appToken) {
+ VirtualDisplayDevice device = removeVirtualDisplayDeviceLocked(appToken);
if (device != null) {
Slog.v(TAG, "Release VirtualDisplay " + device.mName);
device.destroyLocked(true);
@@ -299,11 +305,13 @@ public class VirtualDisplayAdapter extends DisplayAdapter {
}
}
- private VirtualDisplayDevice removeVirtualDisplayDeviceLocked(IBinder appToken, int ownerUid) {
- int noOfDevices = mNoOfDevicesPerPackage.get(ownerUid, /* valueIfKeyNotFound= */ 0);
+ private VirtualDisplayDevice removeVirtualDisplayDeviceLocked(IBinder appToken) {
if (getFeatureFlags().isVirtualDisplayLimitEnabled()) {
+ int ownerUid = mOwnerUids.get(appToken);
+ int noOfDevices = mNoOfDevicesPerPackage.get(ownerUid, /* valueIfKeyNotFound= */ 0);
if (noOfDevices <= 1) {
mNoOfDevicesPerPackage.delete(ownerUid);
+ mOwnerUids.remove(appToken);
} else {
mNoOfDevicesPerPackage.put(ownerUid, noOfDevices - 1);
}
@@ -378,7 +386,7 @@ public class VirtualDisplayAdapter extends DisplayAdapter {
@Override
public void binderDied() {
synchronized (getSyncRoot()) {
- removeVirtualDisplayDeviceLocked(mAppToken, mOwnerUid);
+ removeVirtualDisplayDeviceLocked(mAppToken);
Slog.i(TAG, "Virtual display device released because application token died: "
+ mOwnerPackageName);
destroyLocked(false);
diff --git a/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java b/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
index 585fc44fa452..78bd41bd2e11 100644
--- a/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
+++ b/services/core/java/com/android/server/display/feature/DisplayManagerFlags.java
@@ -93,6 +93,10 @@ public class DisplayManagerFlags {
com.android.graphics.surfaceflinger.flags.Flags.FLAG_ENABLE_SMALL_AREA_DETECTION,
com.android.graphics.surfaceflinger.flags.Flags::enableSmallAreaDetection);
+ private final FlagState mDisplayConfigErrorHalFlagState = new FlagState(
+ com.android.graphics.surfaceflinger.flags.Flags.FLAG_DISPLAY_CONFIG_ERROR_HAL,
+ com.android.graphics.surfaceflinger.flags.Flags::displayConfigErrorHal);
+
private final FlagState mBrightnessIntRangeUserPerceptionFlagState = new FlagState(
Flags.FLAG_BRIGHTNESS_INT_RANGE_USER_PERCEPTION,
Flags::brightnessIntRangeUserPerception);
@@ -361,6 +365,10 @@ public class DisplayManagerFlags {
return mSmallAreaDetectionFlagState.isEnabled();
}
+ public boolean isDisplayConfigErrorHalEnabled() {
+ return mDisplayConfigErrorHalFlagState.isEnabled();
+ }
+
public boolean isBrightnessIntRangeUserPerceptionEnabled() {
return mBrightnessIntRangeUserPerceptionFlagState.isEnabled();
}
@@ -591,6 +599,7 @@ public class DisplayManagerFlags {
pw.println(" " + mPowerThrottlingClamperFlagState);
pw.println(" " + mEvenDimmerFlagState);
pw.println(" " + mSmallAreaDetectionFlagState);
+ pw.println(" " + mDisplayConfigErrorHalFlagState);
pw.println(" " + mBrightnessIntRangeUserPerceptionFlagState);
pw.println(" " + mRestrictDisplayModes);
pw.println(" " + mBrightnessWearBedtimeModeClamperFlagState);
diff --git a/services/core/java/com/android/server/display/mode/DisplayModeDirector.java b/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
index 8423e1911764..02e2882442bf 100644
--- a/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
+++ b/services/core/java/com/android/server/display/mode/DisplayModeDirector.java
@@ -136,6 +136,7 @@ public class DisplayModeDirector {
private final ProximitySensorObserver mSensorObserver;
private final HbmObserver mHbmObserver;
private final SkinThermalStatusObserver mSkinThermalStatusObserver;
+ private final ModeChangeObserver mModeChangeObserver;
@Nullable
private final SystemRequestObserver mSystemRequestObserver;
@@ -247,6 +248,7 @@ public class DisplayModeDirector {
mDisplayObserver = new DisplayObserver(context, handler, mVotesStorage, injector);
mSensorObserver = new ProximitySensorObserver(mVotesStorage, injector);
mSkinThermalStatusObserver = new SkinThermalStatusObserver(injector, mVotesStorage);
+ mModeChangeObserver = new ModeChangeObserver(mVotesStorage, injector, handler.getLooper());
mHbmObserver = new HbmObserver(injector, mVotesStorage, BackgroundThread.getHandler(),
mDeviceConfigDisplaySettings);
if (displayManagerFlags.isRestrictDisplayModesEnabled()) {
@@ -275,6 +277,9 @@ public class DisplayModeDirector {
mSensorObserver.observe();
mHbmObserver.observe();
mSkinThermalStatusObserver.observe();
+ if (mDisplayManagerFlags.isDisplayConfigErrorHalEnabled()) {
+ mModeChangeObserver.observe();
+ }
synchronized (mLock) {
// We may have a listener already registered before the call to start, so go ahead and
// notify them to pick up our newly initialized state.
diff --git a/services/core/java/com/android/server/display/mode/ModeChangeObserver.java b/services/core/java/com/android/server/display/mode/ModeChangeObserver.java
new file mode 100644
index 000000000000..bbc13cc6ae7e
--- /dev/null
+++ b/services/core/java/com/android/server/display/mode/ModeChangeObserver.java
@@ -0,0 +1,108 @@
+/*
+ * 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.display.mode;
+
+import android.os.Looper;
+import android.util.Slog;
+import android.util.SparseArray;
+import android.view.Display;
+import android.view.DisplayAddress;
+import android.view.DisplayEventReceiver;
+
+import com.android.internal.annotations.KeepForWeakReference;
+
+import java.util.HashSet;
+import java.util.Set;
+
+final class ModeChangeObserver {
+ private static final String TAG = "ModeChangeObserver";
+
+ private final VotesStorage mVotesStorage;
+ private final DisplayModeDirector.Injector mInjector;
+
+ @SuppressWarnings("unused")
+ @KeepForWeakReference
+ private DisplayEventReceiver mModeChangeListener;
+ private final SparseArray<Set<Integer>> mRejectedModesByDisplay = new SparseArray<>();
+ private Looper mLooper;
+
+ ModeChangeObserver(VotesStorage votesStorage, DisplayModeDirector.Injector injector,
+ Looper looper) {
+ mVotesStorage = votesStorage;
+ mInjector = injector;
+ mLooper = looper;
+ }
+
+ void observe() {
+ mModeChangeListener = new DisplayEventReceiver(mLooper) {
+ @Override
+ public void onModeRejected(long physicalDisplayId, int modeId) {
+ Slog.d(TAG, "Mode Rejected event received");
+ int displayId = getLogicalDisplayId(physicalDisplayId);
+ if (displayId < 0) {
+ Slog.e(TAG, "Logical Display Id not found");
+ return;
+ }
+ populateRejectedModesListByDisplay(displayId, modeId);
+ }
+
+ @Override
+ public void onHotplug(long timestampNanos, long physicalDisplayId, boolean connected) {
+ Slog.d(TAG, "Hotplug event received");
+ if (!connected) {
+ int displayId = getLogicalDisplayId(physicalDisplayId);
+ if (displayId < 0) {
+ Slog.e(TAG, "Logical Display Id not found");
+ return;
+ }
+ clearRejectedModesListByDisplay(displayId);
+ }
+ }
+ };
+ }
+
+ private int getLogicalDisplayId(long rejectedModePhysicalDisplayId) {
+ Display[] displays = mInjector.getDisplays();
+
+ for (Display display : displays) {
+ DisplayAddress address = display.getAddress();
+ if (address instanceof DisplayAddress.Physical physical) {
+ long physicalDisplayId = physical.getPhysicalDisplayId();
+ if (physicalDisplayId == rejectedModePhysicalDisplayId) {
+ return display.getDisplayId();
+ }
+ }
+ }
+ return -1;
+ }
+
+ private void populateRejectedModesListByDisplay(int displayId, int rejectedModeId) {
+ Set<Integer> alreadyRejectedModes = mRejectedModesByDisplay.get(displayId);
+ if (alreadyRejectedModes == null) {
+ alreadyRejectedModes = new HashSet<>();
+ mRejectedModesByDisplay.put(displayId, alreadyRejectedModes);
+ }
+ alreadyRejectedModes.add(rejectedModeId);
+ mVotesStorage.updateVote(displayId, Vote.PRIORITY_REJECTED_MODES,
+ Vote.forRejectedModes(alreadyRejectedModes));
+ }
+
+ private void clearRejectedModesListByDisplay(int displayId) {
+ mRejectedModesByDisplay.remove(displayId);
+ mVotesStorage.updateVote(displayId, Vote.PRIORITY_REJECTED_MODES, null);
+ }
+}
diff --git a/services/core/java/com/android/server/display/mode/RejectedModesVote.java b/services/core/java/com/android/server/display/mode/RejectedModesVote.java
new file mode 100644
index 000000000000..db8c8527844b
--- /dev/null
+++ b/services/core/java/com/android/server/display/mode/RejectedModesVote.java
@@ -0,0 +1,40 @@
+/*
+ * 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.display.mode;
+
+import android.annotation.NonNull;
+
+import java.util.Collections;
+import java.util.Set;
+
+public class RejectedModesVote implements Vote {
+
+ final Set<Integer> mModeIds;
+
+ RejectedModesVote(Set<Integer> modeIds) {
+ mModeIds = Collections.unmodifiableSet(modeIds);
+ }
+ @Override
+ public void updateSummary(@NonNull VoteSummary summary) {
+ summary.rejectedModeIds.addAll(mModeIds);
+ }
+
+ @Override
+ public String toString() {
+ return "RejectedModesVote{ mModeIds=" + mModeIds + " }";
+ }
+}
diff --git a/services/core/java/com/android/server/display/mode/Vote.java b/services/core/java/com/android/server/display/mode/Vote.java
index f5abb0561ce7..428ccedf8760 100644
--- a/services/core/java/com/android/server/display/mode/Vote.java
+++ b/services/core/java/com/android/server/display/mode/Vote.java
@@ -25,6 +25,7 @@ import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.List;
+import java.util.Set;
interface Vote {
// DEFAULT_RENDER_FRAME_RATE votes for render frame rate [0, DEFAULT]. As the lowest
@@ -82,68 +83,73 @@ interface Vote {
int PRIORITY_APP_REQUEST_SIZE = 7;
+ // PRIORITY_REJECTED_MODES rejects the modes for which the mode config failed
+ // so that the modeset can be retried for next available mode after filtering
+ // out the rejected modes for the connected display
+ int PRIORITY_REJECTED_MODES = 8;
+
// PRIORITY_USER_SETTING_PEAK_REFRESH_RATE restricts physical refresh rate to
// [0, max(PEAK, MIN)], depending on user settings peakRR/minRR values
- int PRIORITY_USER_SETTING_PEAK_REFRESH_RATE = 8;
+ int PRIORITY_USER_SETTING_PEAK_REFRESH_RATE = 9;
// PRIORITY_USER_SETTING_PEAK_RENDER_FRAME_RATE has a higher priority than
// PRIORITY_USER_SETTING_PEAK_REFRESH_RATE and will limit render rate to [0, max(PEAK, MIN)]
// in case physical refresh rate vote is discarded (due to other high priority votes),
// render rate vote can still apply
- int PRIORITY_USER_SETTING_PEAK_RENDER_FRAME_RATE = 9;
+ int PRIORITY_USER_SETTING_PEAK_RENDER_FRAME_RATE = 10;
// Restrict all displays physical refresh rate to 60Hz when external display is connected.
// It votes [59Hz, 61Hz].
- int PRIORITY_SYNCHRONIZED_REFRESH_RATE = 10;
+ int PRIORITY_SYNCHRONIZED_REFRESH_RATE = 11;
// PRIORITY_SYNCHRONIZED_RENDER_FRAME_RATE has a higher priority than
// PRIORITY_SYNCHRONIZED_REFRESH_RATE and will limit render rate to [59Hz, 61Hz].
// In case physical refresh rate vote discarded (due to physical refresh rate not supported),
// render rate vote can still apply.
- int PRIORITY_SYNCHRONIZED_RENDER_FRAME_RATE = 11;
+ int PRIORITY_SYNCHRONIZED_RENDER_FRAME_RATE = 12;
// Restrict displays max available resolution and refresh rates. It votes [0, LIMIT]
- int PRIORITY_LIMIT_MODE = 12;
+ int PRIORITY_LIMIT_MODE = 13;
// To avoid delay in switching between 60HZ -> 90HZ when activating LHBM, set refresh
// rate to max value (same as for PRIORITY_UDFPS) on lock screen
- int PRIORITY_AUTH_OPTIMIZER_RENDER_FRAME_RATE = 13;
+ int PRIORITY_AUTH_OPTIMIZER_RENDER_FRAME_RATE = 14;
// For concurrent displays we want to limit refresh rate on all displays
- int PRIORITY_LAYOUT_LIMITED_REFRESH_RATE = 14;
+ int PRIORITY_LAYOUT_LIMITED_REFRESH_RATE = 15;
// For concurrent displays we want to limit refresh rate on all displays
- int PRIORITY_LAYOUT_LIMITED_FRAME_RATE = 15;
+ int PRIORITY_LAYOUT_LIMITED_FRAME_RATE = 16;
// For internal application to limit display modes to specific ids
- int PRIORITY_SYSTEM_REQUESTED_MODES = 16;
+ int PRIORITY_SYSTEM_REQUESTED_MODES = 17;
// PRIORITY_LOW_POWER_MODE_MODES limits display modes to specific refreshRate-vsync pairs if
// Settings.Global.LOW_POWER_MODE is on.
// Lower priority that PRIORITY_LOW_POWER_MODE_RENDER_RATE and if discarded (due to other
// higher priority votes), render rate limit can still apply
- int PRIORITY_LOW_POWER_MODE_MODES = 17;
+ int PRIORITY_LOW_POWER_MODE_MODES = 18;
// PRIORITY_LOW_POWER_MODE_RENDER_RATE force the render frame rate to [0, 60HZ] if
// Settings.Global.LOW_POWER_MODE is on.
- int PRIORITY_LOW_POWER_MODE_RENDER_RATE = 18;
+ int PRIORITY_LOW_POWER_MODE_RENDER_RATE = 19;
// PRIORITY_FLICKER_REFRESH_RATE_SWITCH votes for disabling refresh rate switching. If the
// higher priority voters' result is a range, it will fix the rate to a single choice.
// It's used to avoid refresh rate switches in certain conditions which may result in the
// user seeing the display flickering when the switches occur.
- int PRIORITY_FLICKER_REFRESH_RATE_SWITCH = 19;
+ int PRIORITY_FLICKER_REFRESH_RATE_SWITCH = 20;
// Force display to [0, 60HZ] if skin temperature is at or above CRITICAL.
- int PRIORITY_SKIN_TEMPERATURE = 20;
+ int PRIORITY_SKIN_TEMPERATURE = 21;
// The proximity sensor needs the refresh rate to be locked in order to function, so this is
// set to a high priority.
- int PRIORITY_PROXIMITY = 21;
+ int PRIORITY_PROXIMITY = 22;
// The Under-Display Fingerprint Sensor (UDFPS) needs the refresh rate to be locked in order
// to function, so this needs to be the highest priority of all votes.
- int PRIORITY_UDFPS = 22;
+ int PRIORITY_UDFPS = 23;
@IntDef(prefix = { "PRIORITY_" }, value = {
PRIORITY_DEFAULT_RENDER_FRAME_RATE,
@@ -154,6 +160,7 @@ interface Vote {
PRIORITY_APP_REQUEST_RENDER_FRAME_RATE_RANGE,
PRIORITY_APP_REQUEST_BASE_MODE_REFRESH_RATE,
PRIORITY_APP_REQUEST_SIZE,
+ PRIORITY_REJECTED_MODES,
PRIORITY_USER_SETTING_PEAK_REFRESH_RATE,
PRIORITY_USER_SETTING_PEAK_RENDER_FRAME_RATE,
PRIORITY_SYNCHRONIZED_REFRESH_RATE,
@@ -245,6 +252,10 @@ interface Vote {
return new SupportedModesVote(modeIds);
}
+ static Vote forRejectedModes(Set<Integer> modeIds) {
+ return new RejectedModesVote(modeIds);
+ }
+
static String priorityToString(int priority) {
switch (priority) {
case PRIORITY_APP_REQUEST_BASE_MODE_REFRESH_RATE:
@@ -253,6 +264,8 @@ interface Vote {
return "PRIORITY_APP_REQUEST_RENDER_FRAME_RATE_RANGE";
case PRIORITY_APP_REQUEST_SIZE:
return "PRIORITY_APP_REQUEST_SIZE";
+ case PRIORITY_REJECTED_MODES:
+ return "PRIORITY_REJECTED_MODES";
case PRIORITY_DEFAULT_RENDER_FRAME_RATE:
return "PRIORITY_DEFAULT_REFRESH_RATE";
case PRIORITY_FLICKER_REFRESH_RATE:
diff --git a/services/core/java/com/android/server/display/mode/VoteSummary.java b/services/core/java/com/android/server/display/mode/VoteSummary.java
index 00a922630d8e..41664930fc2e 100644
--- a/services/core/java/com/android/server/display/mode/VoteSummary.java
+++ b/services/core/java/com/android/server/display/mode/VoteSummary.java
@@ -55,6 +55,11 @@ final class VoteSummary {
@Nullable
public List<Integer> supportedModeIds;
+ /**
+ * set of rejected modes due to mode config failure for connected display
+ */
+ public Set<Integer> rejectedModeIds = new HashSet<>();
+
final boolean mIsDisplayResolutionRangeVotingEnabled;
private final boolean mSupportedModesVoteEnabled;
@@ -132,6 +137,9 @@ final class VoteSummary {
if (!validateModeSupported(mode)) {
continue;
}
+ if (!validateModeRejected(mode)) {
+ continue;
+ }
if (!validateModeSize(mode)) {
continue;
}
@@ -285,6 +293,22 @@ final class VoteSummary {
return false;
}
+ private boolean validateModeRejected(Display.Mode mode) {
+ if (rejectedModeIds == null) {
+ return true;
+ }
+ if (!rejectedModeIds.contains(mode.getModeId())) {
+ return true;
+ }
+ if (mLoggingEnabled) {
+ Slog.w(TAG, "Discarding mode" + mode.getModeId()
+ + ", is a rejectedMode"
+ + ": mode.modeId=" + mode.getModeId()
+ + ", rejectedModeIds=" + rejectedModeIds);
+ }
+ return false;
+ }
+
private boolean validateRefreshRatesSupported(Display.Mode mode) {
if (supportedRefreshRates == null || !mSupportedModesVoteEnabled) {
return true;
@@ -397,6 +421,7 @@ final class VoteSummary {
requestedRefreshRates.clear();
supportedRefreshRates = null;
supportedModeIds = null;
+ rejectedModeIds.clear();
if (mLoggingEnabled) {
Slog.i(TAG, "Summary reset: " + this);
}
@@ -421,6 +446,7 @@ final class VoteSummary {
+ ", requestRefreshRates=" + requestedRefreshRates
+ ", supportedRefreshRates=" + supportedRefreshRates
+ ", supportedModeIds=" + supportedModeIds
+ + ", rejectedModeIds=" + rejectedModeIds
+ ", mIsDisplayResolutionRangeVotingEnabled="
+ mIsDisplayResolutionRangeVotingEnabled
+ ", mSupportedModesVoteEnabled=" + mSupportedModesVoteEnabled
diff --git a/services/core/java/com/android/server/media/quality/MediaQualityService.java b/services/core/java/com/android/server/media/quality/MediaQualityService.java
index 1673b8e6a0af..f363d5852354 100644
--- a/services/core/java/com/android/server/media/quality/MediaQualityService.java
+++ b/services/core/java/com/android/server/media/quality/MediaQualityService.java
@@ -31,6 +31,7 @@ import android.media.quality.PictureProfile;
import android.media.quality.PictureProfileHandle;
import android.media.quality.SoundProfile;
import android.media.quality.SoundProfileHandle;
+import android.os.Binder;
import android.os.PersistableBundle;
import android.os.UserHandle;
import android.util.Log;
@@ -58,6 +59,7 @@ public class MediaQualityService extends SystemService {
private static final boolean DEBUG = false;
private static final String TAG = "MediaQualityService";
+ private static final int MAX_UUID_GENERATION_ATTEMPTS = 10;
private final Context mContext;
private final MediaQualityDbHelper mMediaQualityDbHelper;
private final BiMap<Long, String> mPictureProfileTempIdMap;
@@ -85,12 +87,12 @@ public class MediaQualityService extends SystemService {
public PictureProfile createPictureProfile(PictureProfile pp, UserHandle user) {
SQLiteDatabase db = mMediaQualityDbHelper.getWritableDatabase();
- ContentValues values = new ContentValues();
- values.put(BaseParameters.PARAMETER_TYPE, pp.getProfileType());
- values.put(BaseParameters.PARAMETER_NAME, pp.getName());
- values.put(BaseParameters.PARAMETER_PACKAGE, pp.getPackageName());
- values.put(BaseParameters.PARAMETER_INPUT_ID, pp.getInputId());
- values.put(mMediaQualityDbHelper.SETTINGS, persistableBundleToJson(pp.getParameters()));
+ ContentValues values = getContentValues(null,
+ pp.getProfileType(),
+ pp.getName(),
+ pp.getPackageName(),
+ pp.getInputId(),
+ pp.getParameters());
// id is auto-generated by SQLite upon successful insertion of row
Long id = db.insert(mMediaQualityDbHelper.PICTURE_QUALITY_TABLE_NAME,
@@ -102,7 +104,18 @@ public class MediaQualityService extends SystemService {
@Override
public void updatePictureProfile(String id, PictureProfile pp, UserHandle user) {
- // TODO: implement
+ Long intId = mPictureProfileTempIdMap.inverse().get(id);
+
+ ContentValues values = getContentValues(intId,
+ pp.getProfileType(),
+ pp.getName(),
+ pp.getPackageName(),
+ pp.getInputId(),
+ pp.getParameters());
+
+ SQLiteDatabase db = mMediaQualityDbHelper.getWritableDatabase();
+ db.replace(mMediaQualityDbHelper.PICTURE_QUALITY_TABLE_NAME,
+ null, values);
}
@Override
@@ -157,6 +170,11 @@ public class MediaQualityService extends SystemService {
@Override
public List<PictureProfile> getAvailablePictureProfiles(
boolean includeParams, UserHandle user) {
+ String[] packageNames = mContext.getPackageManager().getPackagesForUid(
+ Binder.getCallingUid());
+ if (packageNames != null && packageNames.length == 1 && !packageNames[0].isEmpty()) {
+ return getPictureProfilesByPackage(packageNames[0], includeParams, user);
+ }
return new ArrayList<>();
}
@@ -191,12 +209,12 @@ public class MediaQualityService extends SystemService {
public SoundProfile createSoundProfile(SoundProfile sp, UserHandle user) {
SQLiteDatabase db = mMediaQualityDbHelper.getWritableDatabase();
- ContentValues values = new ContentValues();
- values.put(BaseParameters.PARAMETER_TYPE, sp.getProfileType());
- values.put(BaseParameters.PARAMETER_NAME, sp.getName());
- values.put(BaseParameters.PARAMETER_PACKAGE, sp.getPackageName());
- values.put(BaseParameters.PARAMETER_INPUT_ID, sp.getInputId());
- values.put(mMediaQualityDbHelper.SETTINGS, persistableBundleToJson(sp.getParameters()));
+ ContentValues values = getContentValues(null,
+ sp.getProfileType(),
+ sp.getName(),
+ sp.getPackageName(),
+ sp.getInputId(),
+ sp.getParameters());
// id is auto-generated by SQLite upon successful insertion of row
Long id = db.insert(mMediaQualityDbHelper.SOUND_QUALITY_TABLE_NAME,
@@ -207,8 +225,18 @@ public class MediaQualityService extends SystemService {
}
@Override
- public void updateSoundProfile(String id, SoundProfile pp, UserHandle user) {
- // TODO: implement
+ public void updateSoundProfile(String id, SoundProfile sp, UserHandle user) {
+ Long intId = mSoundProfileTempIdMap.inverse().get(id);
+
+ ContentValues values = getContentValues(intId,
+ sp.getProfileType(),
+ sp.getName(),
+ sp.getPackageName(),
+ sp.getInputId(),
+ sp.getParameters());
+
+ SQLiteDatabase db = mMediaQualityDbHelper.getWritableDatabase();
+ db.replace(mMediaQualityDbHelper.SOUND_QUALITY_TABLE_NAME, null, values);
}
@Override
@@ -263,6 +291,11 @@ public class MediaQualityService extends SystemService {
@Override
public List<SoundProfile> getAvailableSoundProfiles(
boolean includeParams, UserHandle user) {
+ String[] packageNames = mContext.getPackageManager().getPackagesForUid(
+ Binder.getCallingUid());
+ if (packageNames != null && packageNames.length == 1 && !packageNames[0].isEmpty()) {
+ return getSoundProfilesByPackage(packageNames[0], includeParams, user);
+ }
return new ArrayList<>();
}
@@ -285,11 +318,16 @@ public class MediaQualityService extends SystemService {
private void populateTempIdMap(BiMap<Long, String> map, Long id) {
if (id != null && map.get(id) == null) {
- String uuid = UUID.randomUUID().toString();
- while (map.inverse().containsKey(uuid)) {
+ String uuid;
+ int attempts = 0;
+ while (attempts < MAX_UUID_GENERATION_ATTEMPTS) {
uuid = UUID.randomUUID().toString();
+ if (!map.inverse().containsKey(uuid)) {
+ map.put(id, uuid);
+ return;
+ }
+ attempts++;
}
- map.put(id, uuid);
}
}
@@ -316,7 +354,7 @@ public class MediaQualityService extends SystemService {
return json.toString();
}
- private PersistableBundle jsonToBundle(String jsonString) {
+ private PersistableBundle jsonToPersistableBundle(String jsonString) {
PersistableBundle bundle = new PersistableBundle();
if (jsonString != null) {
JSONObject jsonObject = null;
@@ -347,6 +385,30 @@ public class MediaQualityService extends SystemService {
return bundle;
}
+ private ContentValues getContentValues(Long dbId, Integer profileType, String name,
+ String packageName, String inputId, PersistableBundle params) {
+ ContentValues values = new ContentValues();
+ if (dbId != null) {
+ values.put(BaseParameters.PARAMETER_ID, dbId);
+ }
+ if (profileType != null) {
+ values.put(BaseParameters.PARAMETER_TYPE, profileType);
+ }
+ if (name != null) {
+ values.put(BaseParameters.PARAMETER_NAME, name);
+ }
+ if (packageName != null) {
+ values.put(BaseParameters.PARAMETER_PACKAGE, packageName);
+ }
+ if (inputId != null) {
+ values.put(BaseParameters.PARAMETER_INPUT_ID, inputId);
+ }
+ if (params != null) {
+ values.put(mMediaQualityDbHelper.SETTINGS, persistableBundleToJson(params));
+ }
+ return values;
+ }
+
private String[] getAllMediaProfileColumns() {
return new String[]{
BaseParameters.PARAMETER_ID,
@@ -365,7 +427,7 @@ public class MediaQualityService extends SystemService {
getName(cursor),
getInputId(cursor),
getPackageName(cursor),
- jsonToBundle(getSettingsString(cursor)),
+ jsonToPersistableBundle(getSettingsString(cursor)),
PictureProfileHandle.NONE
);
}
@@ -377,7 +439,7 @@ public class MediaQualityService extends SystemService {
getName(cursor),
getInputId(cursor),
getPackageName(cursor),
- jsonToBundle(getSettingsString(cursor)),
+ jsonToPersistableBundle(getSettingsString(cursor)),
SoundProfileHandle.NONE
);
}
diff --git a/services/core/java/com/android/server/media/quality/OWNERS b/services/core/java/com/android/server/media/quality/OWNERS
index e455846dd75d..7171aa4ce9b6 100644
--- a/services/core/java/com/android/server/media/quality/OWNERS
+++ b/services/core/java/com/android/server/media/quality/OWNERS
@@ -1,2 +1,3 @@
shubang@google.com
-haofanw@google.com \ No newline at end of file
+haofanw@google.com
+pkandhalu@google.com \ No newline at end of file
diff --git a/services/core/java/com/android/server/pm/InstallDependencyHelper.java b/services/core/java/com/android/server/pm/InstallDependencyHelper.java
index c0ddebeb9868..837adf004df7 100644
--- a/services/core/java/com/android/server/pm/InstallDependencyHelper.java
+++ b/services/core/java/com/android/server/pm/InstallDependencyHelper.java
@@ -78,24 +78,22 @@ public class InstallDependencyHelper {
mPackageInstallerService = packageInstallerService;
}
- void resolveLibraryDependenciesIfNeeded(PackageLite pkg, Computer snapshot, int userId,
- Handler handler, OutcomeReceiver<Void, PackageManagerException> origCallback) {
+ void resolveLibraryDependenciesIfNeeded(List<SharedLibraryInfo> missingLibraries,
+ PackageLite pkg, Computer snapshot, int userId, Handler handler,
+ OutcomeReceiver<Void, PackageManagerException> origCallback) {
CallOnceProxy callback = new CallOnceProxy(handler, origCallback);
try {
- resolveLibraryDependenciesIfNeededInternal(pkg, snapshot, userId, handler, callback);
- } catch (PackageManagerException e) {
- callback.onError(e);
+ resolveLibraryDependenciesIfNeededInternal(
+ missingLibraries, pkg, snapshot, userId, handler, callback);
} catch (Exception e) {
onError(callback, e.getMessage());
}
}
- private void resolveLibraryDependenciesIfNeededInternal(PackageLite pkg, Computer snapshot,
- int userId, Handler handler, CallOnceProxy callback) throws PackageManagerException {
- final List<SharedLibraryInfo> missing =
- mSharedLibraries.collectMissingSharedLibraryInfos(pkg);
-
+ private void resolveLibraryDependenciesIfNeededInternal(List<SharedLibraryInfo> missing,
+ PackageLite pkg, Computer snapshot, int userId, Handler handler,
+ CallOnceProxy callback) {
if (missing.isEmpty()) {
if (DEBUG) {
Slog.d(TAG, "No missing dependency for " + pkg.getPackageName());
@@ -129,6 +127,11 @@ public class InstallDependencyHelper {
}
}
+ List<SharedLibraryInfo> getMissingSharedLibraries(PackageLite pkg)
+ throws PackageManagerException {
+ return mSharedLibraries.collectMissingSharedLibraryInfos(pkg);
+ }
+
void notifySessionComplete(int sessionId) {
if (DEBUG) {
Slog.d(TAG, "Session complete for " + sessionId);
diff --git a/services/core/java/com/android/server/pm/InstallRequest.java b/services/core/java/com/android/server/pm/InstallRequest.java
index b0fe3a97af6e..c96c160deb0f 100644
--- a/services/core/java/com/android/server/pm/InstallRequest.java
+++ b/services/core/java/com/android/server/pm/InstallRequest.java
@@ -170,6 +170,8 @@ final class InstallRequest {
private final boolean mHasAppMetadataFileFromInstaller;
private boolean mKeepArtProfile = false;
+ private final boolean mDependencyInstallerEnabled;
+ private final int mMissingSharedLibraryCount;
// New install
InstallRequest(InstallingSession params) {
@@ -190,6 +192,8 @@ final class InstallRequest {
mRequireUserAction = params.mRequireUserAction;
mPreVerifiedDomains = params.mPreVerifiedDomains;
mHasAppMetadataFileFromInstaller = params.mHasAppMetadataFile;
+ mDependencyInstallerEnabled = params.mDependencyInstallerEnabled;
+ mMissingSharedLibraryCount = params.mMissingSharedLibraryCount;
}
// Install existing package as user
@@ -209,6 +213,8 @@ final class InstallRequest {
mInstallerUidForInstallExisting = installerUid;
mSystem = isSystem;
mHasAppMetadataFileFromInstaller = false;
+ mDependencyInstallerEnabled = false;
+ mMissingSharedLibraryCount = 0;
}
// addForInit
@@ -231,6 +237,8 @@ final class InstallRequest {
mRequireUserAction = USER_ACTION_UNSPECIFIED;
mDisabledPs = disabledPs;
mHasAppMetadataFileFromInstaller = false;
+ mDependencyInstallerEnabled = false;
+ mMissingSharedLibraryCount = 0;
}
@Nullable
@@ -1069,4 +1077,12 @@ final class InstallRequest {
boolean isKeepArtProfile() {
return mKeepArtProfile;
}
+
+ int getMissingSharedLibraryCount() {
+ return mMissingSharedLibraryCount;
+ }
+
+ boolean isDependencyInstallerEnabled() {
+ return mDependencyInstallerEnabled;
+ }
}
diff --git a/services/core/java/com/android/server/pm/InstallingSession.java b/services/core/java/com/android/server/pm/InstallingSession.java
index ccc117566989..6a2bf83ba368 100644
--- a/services/core/java/com/android/server/pm/InstallingSession.java
+++ b/services/core/java/com/android/server/pm/InstallingSession.java
@@ -103,6 +103,8 @@ class InstallingSession {
final DomainSet mPreVerifiedDomains;
final boolean mHasAppMetadataFile;
@Nullable final String mDexoptCompilerFilter;
+ final boolean mDependencyInstallerEnabled;
+ final int mMissingSharedLibraryCount;
// For move install
InstallingSession(OriginInfo originInfo, MoveInfo moveInfo, IPackageInstallObserver2 observer,
@@ -138,13 +140,16 @@ class InstallingSession {
mPreVerifiedDomains = null;
mHasAppMetadataFile = false;
mDexoptCompilerFilter = null;
+ mDependencyInstallerEnabled = false;
+ mMissingSharedLibraryCount = 0;
}
InstallingSession(int sessionId, File stagedDir, IPackageInstallObserver2 observer,
PackageInstaller.SessionParams sessionParams, InstallSource installSource,
UserHandle user, SigningDetails signingDetails, int installerUid,
PackageLite packageLite, DomainSet preVerifiedDomains, PackageManagerService pm,
- boolean hasAppMetadatafile) {
+ boolean hasAppMetadatafile, boolean dependencyInstallerEnabled,
+ int missingSharedLibraryCount) {
mPm = pm;
mUser = user;
mOriginInfo = OriginInfo.fromStagedFile(stagedDir);
@@ -175,6 +180,8 @@ class InstallingSession {
mPreVerifiedDomains = preVerifiedDomains;
mHasAppMetadataFile = hasAppMetadatafile;
mDexoptCompilerFilter = sessionParams.dexoptCompilerFilter;
+ mDependencyInstallerEnabled = dependencyInstallerEnabled;
+ mMissingSharedLibraryCount = missingSharedLibraryCount;
}
@Override
diff --git a/services/core/java/com/android/server/pm/PackageInstallerSession.java b/services/core/java/com/android/server/pm/PackageInstallerSession.java
index 891d66a5d238..c6760431116e 100644
--- a/services/core/java/com/android/server/pm/PackageInstallerSession.java
+++ b/services/core/java/com/android/server/pm/PackageInstallerSession.java
@@ -31,6 +31,7 @@ import static android.content.pm.PackageManager.INSTALL_FAILED_INSUFFICIENT_STOR
import static android.content.pm.PackageManager.INSTALL_FAILED_INTERNAL_ERROR;
import static android.content.pm.PackageManager.INSTALL_FAILED_INVALID_APK;
import static android.content.pm.PackageManager.INSTALL_FAILED_MEDIA_UNAVAILABLE;
+import static android.content.pm.PackageManager.INSTALL_FAILED_MISSING_SHARED_LIBRARY;
import static android.content.pm.PackageManager.INSTALL_FAILED_MISSING_SPLIT;
import static android.content.pm.PackageManager.INSTALL_FAILED_PRE_APPROVAL_NOT_AVAILABLE;
import static android.content.pm.PackageManager.INSTALL_FAILED_SESSION_INVALID;
@@ -109,6 +110,7 @@ import android.content.pm.PackageInstaller.UserActionReason;
import android.content.pm.PackageManager;
import android.content.pm.PackageManager.PackageInfoFlags;
import android.content.pm.PackageManagerInternal;
+import android.content.pm.SharedLibraryInfo;
import android.content.pm.SigningDetails;
import android.content.pm.dex.DexMetadataHelper;
import android.content.pm.parsing.ApkLite;
@@ -540,6 +542,9 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
@GuardedBy("mLock")
private DomainSet mPreVerifiedDomains;
+ private AtomicBoolean mDependencyInstallerEnabled = new AtomicBoolean();
+ private AtomicInteger mMissingSharedLibraryCount = new AtomicInteger();
+
static class FileEntry {
private final int mIndex;
private final InstallationFile mFile;
@@ -3232,6 +3237,7 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
if (Flags.sdkDependencyInstaller()
&& params.isAutoInstallDependenciesEnabled
&& !isMultiPackage()) {
+ mDependencyInstallerEnabled.set(true);
resolveLibraryDependenciesIfNeeded();
} else {
install();
@@ -3241,8 +3247,20 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
private void resolveLibraryDependenciesIfNeeded() {
synchronized (mLock) {
- mInstallDependencyHelper.resolveLibraryDependenciesIfNeeded(mPackageLite,
- mPm.snapshotComputer(), userId, mHandler,
+ List<SharedLibraryInfo> missingLibraries = new ArrayList<>();
+ try {
+ missingLibraries = mInstallDependencyHelper.getMissingSharedLibraries(mPackageLite);
+ } catch (PackageManagerException e) {
+ handleDependencyResolutionFailure(e);
+ } catch (Exception e) {
+ handleDependencyResolutionFailure(
+ new PackageManagerException(
+ INSTALL_FAILED_MISSING_SHARED_LIBRARY, e.getMessage()));
+ }
+
+ mMissingSharedLibraryCount.set(missingLibraries.size());
+ mInstallDependencyHelper.resolveLibraryDependenciesIfNeeded(missingLibraries,
+ mPackageLite, mPm.snapshotComputer(), userId, mHandler,
new OutcomeReceiver<>() {
@Override
@@ -3252,14 +3270,21 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
@Override
public void onError(@NonNull PackageManagerException e) {
- final String completeMsg = ExceptionUtils.getCompleteMessage(e);
- setSessionFailed(e.error, completeMsg);
- onSessionDependencyResolveFailure(e.error, completeMsg);
+ handleDependencyResolutionFailure(e);
}
});
}
}
+ private void handleDependencyResolutionFailure(@NonNull PackageManagerException e) {
+ final String completeMsg = ExceptionUtils.getCompleteMessage(e);
+ setSessionFailed(e.error, completeMsg);
+ onSessionDependencyResolveFailure(e.error, completeMsg);
+ PackageMetrics.onDependencyInstallationFailure(
+ sessionId, getPackageName(), e.error, mInstallerUid, params,
+ mMissingSharedLibraryCount.get());
+ }
+
/**
* Stages this session for install and returns a
* {@link InstallingSession} representing this new staged state.
@@ -3327,7 +3352,8 @@ public class PackageInstallerSession extends IPackageInstallerSession.Stub {
synchronized (mLock) {
return new InstallingSession(sessionId, stageDir, localObserver, params, mInstallSource,
user, mSigningDetails, mInstallerUid, mPackageLite, mPreVerifiedDomains, mPm,
- mHasAppMetadataFile);
+ mHasAppMetadataFile, mDependencyInstallerEnabled.get(),
+ mMissingSharedLibraryCount.get());
}
}
diff --git a/services/core/java/com/android/server/pm/PackageMetrics.java b/services/core/java/com/android/server/pm/PackageMetrics.java
index 0acadb129f2b..856d6a726da5 100644
--- a/services/core/java/com/android/server/pm/PackageMetrics.java
+++ b/services/core/java/com/android/server/pm/PackageMetrics.java
@@ -32,7 +32,9 @@ import android.app.admin.SecurityLog;
import android.content.ComponentName;
import android.content.Intent;
import android.content.pm.ActivityInfo;
+import android.content.pm.DataLoaderType;
import android.content.pm.Flags;
+import android.content.pm.PackageInstaller;
import android.content.pm.PackageManager;
import android.content.pm.ResolveInfo;
import android.content.pm.parsing.ApkLiteParseUtils;
@@ -173,7 +175,10 @@ final class PackageMetrics {
mInstallRequest.isInstallInherit() /* is_inherit */,
mInstallRequest.isInstallForUsers() /* is_installing_existing_as_user */,
mInstallRequest.isInstallMove() /* is_move_install */,
- false /* is_staged */
+ false /* is_staged */,
+ mInstallRequest
+ .isDependencyInstallerEnabled() /* is_install_dependencies_enabled */,
+ mInstallRequest.getMissingSharedLibraryCount() /* missing_dependencies_count */
);
}
@@ -323,7 +328,53 @@ final class PackageMetrics {
verifyingSession.isInherit() /* is_inherit */,
false /* is_installing_existing_as_user */,
false /* is_move_install */,
- verifyingSession.isStaged() /* is_staged */
+ verifyingSession.isStaged() /* is_staged */,
+ false /* is_install_dependencies_enabled */,
+ 0 /* missing_dependencies_count */
+ );
+ }
+
+ static void onDependencyInstallationFailure(
+ int sessionId, String packageName, int errorCode, int installerPackageUid,
+ PackageInstaller.SessionParams params, int missingDependenciesCount) {
+ if (params == null) {
+ return;
+ }
+ int dataLoaderType = DataLoaderType.NONE;
+ if (params.dataLoaderParams != null) {
+ dataLoaderType = params.dataLoaderParams.getType();
+ }
+
+ FrameworkStatsLog.write(FrameworkStatsLog.PACKAGE_INSTALLATION_SESSION_REPORTED,
+ sessionId /* session_id */,
+ packageName /* package_name */,
+ INVALID_UID /* uid */,
+ null /* user_ids */,
+ null /* user_types */,
+ null /* original_user_ids */,
+ null /* original_user_types */,
+ errorCode /* public_return_code */,
+ 0 /* internal_error_code */,
+ 0 /* apks_size_bytes */,
+ 0 /* version_code */,
+ null /* install_steps */,
+ null /* step_duration_millis */,
+ 0 /* total_duration_millis */,
+ 0 /* install_flags */,
+ installerPackageUid /* installer_package_uid */,
+ INVALID_UID /* original_installer_package_uid */,
+ dataLoaderType /* data_loader_type */,
+ params.requireUserAction /* user_action_required_type */,
+ (params.installFlags & PackageManager.INSTALL_INSTANT_APP) != 0 /* is_instant */,
+ false /* is_replace */,
+ false /* is_system */,
+ params.mode
+ == PackageInstaller.SessionParams.MODE_INHERIT_EXISTING /* is_inherit */,
+ false /* is_installing_existing_as_user */,
+ false /* is_move_install */,
+ params.isStaged /* is_staged */,
+ true /* is_install_dependencies_enabled */,
+ missingDependenciesCount /* missing_dependencies_count */
);
}
diff --git a/services/core/java/com/android/server/pm/VerifyingSession.java b/services/core/java/com/android/server/pm/VerifyingSession.java
index 542ae8eb9207..dd60a155f2fb 100644
--- a/services/core/java/com/android/server/pm/VerifyingSession.java
+++ b/services/core/java/com/android/server/pm/VerifyingSession.java
@@ -16,11 +16,7 @@
package com.android.server.pm;
-import static android.content.Intent.EXTRA_LONG_VERSION_CODE;
-import static android.content.Intent.EXTRA_PACKAGE_NAME;
-import static android.content.Intent.EXTRA_VERSION_CODE;
import static android.content.pm.PackageInstaller.SessionParams.MODE_INHERIT_EXISTING;
-import static android.content.pm.PackageManager.EXTRA_VERIFICATION_ID;
import static android.content.pm.PackageManager.INSTALL_SUCCEEDED;
import static android.content.pm.PackageManager.MATCH_DEBUG_TRIAGED_MISSING;
import static android.content.pm.SigningDetails.SignatureSchemeVersion.SIGNING_BLOCK_V4;
@@ -40,9 +36,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.AppOpsManager;
import android.app.BroadcastOptions;
-import android.content.BroadcastReceiver;
import android.content.ComponentName;
-import android.content.Context;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.content.pm.DataLoaderType;
@@ -68,7 +62,6 @@ import android.os.UserHandle;
import android.os.UserManager;
import android.os.incremental.IncrementalManager;
import android.provider.DeviceConfig;
-import android.provider.Settings;
import android.text.TextUtils;
import android.util.Pair;
import android.util.Slog;
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 36bc0b93cd7c..ce8dc69e4b26 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -7093,7 +7093,11 @@ public final class PowerManagerService extends SystemService
if ((flags & PowerManager.GO_TO_SLEEP_FLAG_SOFT_SLEEP) != 0) {
if (mFoldGracePeriodProvider.isEnabled()) {
if (!powerGroup.hasWakeLockKeepingScreenOnLocked()) {
+ Slog.d(TAG, "Showing dismissible keyguard");
mNotifier.showDismissibleKeyguard();
+ } else {
+ Slog.i(TAG, "There is a screen wake lock present: "
+ + "sleep request will be ignored");
}
continue; // never actually goes to sleep for SOFT_SLEEP
} else {
diff --git a/services/core/java/com/android/server/power/stats/BatteryUsageStatsProvider.java b/services/core/java/com/android/server/power/stats/BatteryUsageStatsProvider.java
index 63e8d9973237..8c588b4c9b98 100644
--- a/services/core/java/com/android/server/power/stats/BatteryUsageStatsProvider.java
+++ b/services/core/java/com/android/server/power/stats/BatteryUsageStatsProvider.java
@@ -195,23 +195,22 @@ public class BatteryUsageStatsProvider {
mLastAccumulationMonotonicHistorySize = historySize;
}
- handler.post(() -> accumulateBatteryUsageStats(stats));
+ // No need to store the accumulated stats asynchronously, as the entire accumulation
+ // operation is async
+ handler.post(() -> accumulateBatteryUsageStats(stats, false));
}
/**
* Computes BatteryUsageStats for the period since the last accumulated stats were stored,
- * adds them to the accumulated stats and saves the result.
+ * adds them to the accumulated stats and asynchronously saves the result.
*/
public void accumulateBatteryUsageStats(BatteryStatsImpl stats) {
- AccumulatedBatteryUsageStats accumulatedStats = loadAccumulatedBatteryUsageStats();
+ accumulateBatteryUsageStats(stats, true);
+ }
- final BatteryUsageStatsQuery query = new BatteryUsageStatsQuery.Builder()
- .setMaxStatsAgeMs(0)
- .includeProcessStateData()
- .includePowerStateData()
- .includeScreenStateData()
- .build();
- updateAccumulatedBatteryUsageStats(accumulatedStats, stats, query);
+ private void accumulateBatteryUsageStats(BatteryStatsImpl stats, boolean storeAsync) {
+ AccumulatedBatteryUsageStats accumulatedStats = loadAccumulatedBatteryUsageStats();
+ updateAccumulatedBatteryUsageStats(accumulatedStats, stats);
PowerStatsSpan powerStatsSpan = new PowerStatsSpan(AccumulatedBatteryUsageStatsSection.ID);
powerStatsSpan.addSection(
@@ -220,8 +219,13 @@ public class BatteryUsageStatsProvider {
accumulatedStats.startWallClockTime,
accumulatedStats.endMonotonicTime - accumulatedStats.startMonotonicTime);
mMonotonicClock.write();
- mPowerStatsStore.storePowerStatsSpanAsync(powerStatsSpan,
- accumulatedStats.builder::discard);
+ if (storeAsync) {
+ mPowerStatsStore.storePowerStatsSpanAsync(powerStatsSpan,
+ accumulatedStats.builder::discard);
+ } else {
+ mPowerStatsStore.storePowerStatsSpan(powerStatsSpan);
+ accumulatedStats.builder.discard();
+ }
}
/**
@@ -269,7 +273,7 @@ public class BatteryUsageStatsProvider {
BatteryUsageStats batteryUsageStats;
if ((query.getFlags()
& BatteryUsageStatsQuery.FLAG_BATTERY_USAGE_STATS_ACCUMULATED) != 0) {
- batteryUsageStats = getAccumulatedBatteryUsageStats(stats, query, currentTimeMs);
+ batteryUsageStats = getAccumulatedBatteryUsageStats(stats, query);
} else if (query.getAggregatedToTimestamp() == 0) {
BatteryUsageStats.Builder builder = computeBatteryUsageStats(stats, query,
query.getMonotonicStartTime(),
@@ -288,9 +292,13 @@ public class BatteryUsageStatsProvider {
}
private BatteryUsageStats getAccumulatedBatteryUsageStats(BatteryStatsImpl stats,
- BatteryUsageStatsQuery query, long currentTimeMs) {
+ BatteryUsageStatsQuery query) {
AccumulatedBatteryUsageStats accumulatedStats = loadAccumulatedBatteryUsageStats();
- updateAccumulatedBatteryUsageStats(accumulatedStats, stats, query);
+ if (accumulatedStats.endMonotonicTime == MonotonicClock.UNDEFINED
+ || mMonotonicClock.monotonicTime() - accumulatedStats.endMonotonicTime
+ > query.getMaxStatsAge()) {
+ updateAccumulatedBatteryUsageStats(accumulatedStats, stats);
+ }
return accumulatedStats.builder.build();
}
@@ -321,7 +329,7 @@ public class BatteryUsageStatsProvider {
}
private void updateAccumulatedBatteryUsageStats(AccumulatedBatteryUsageStats accumulatedStats,
- BatteryStatsImpl stats, BatteryUsageStatsQuery query) {
+ BatteryStatsImpl stats) {
long startMonotonicTime = accumulatedStats.endMonotonicTime;
if (startMonotonicTime == MonotonicClock.UNDEFINED) {
startMonotonicTime = stats.getMonotonicStartTime();
@@ -333,6 +341,7 @@ public class BatteryUsageStatsProvider {
accumulatedStats.builder = new BatteryUsageStats.Builder(
stats.getCustomEnergyConsumerNames(), true, true, true, 0);
accumulatedStats.startWallClockTime = stats.getStartClockTime();
+ accumulatedStats.startMonotonicTime = stats.getMonotonicStartTime();
accumulatedStats.builder.setStatsStartTimestamp(accumulatedStats.startWallClockTime);
}
@@ -342,7 +351,7 @@ public class BatteryUsageStatsProvider {
accumulatedStats.builder.setStatsDuration(endWallClockTime - startMonotonicTime);
mPowerAttributor.estimatePowerConsumption(accumulatedStats.builder, stats.getHistory(),
- startMonotonicTime, MonotonicClock.UNDEFINED);
+ startMonotonicTime, endMonotonicTime);
populateGeneralInfo(accumulatedStats.builder, stats);
}
diff --git a/services/core/java/com/android/server/power/stats/processor/PowerStatsAggregator.java b/services/core/java/com/android/server/power/stats/processor/PowerStatsAggregator.java
index dcdd3bd8b3fa..1b864bbe479c 100644
--- a/services/core/java/com/android/server/power/stats/processor/PowerStatsAggregator.java
+++ b/services/core/java/com/android/server/power/stats/processor/PowerStatsAggregator.java
@@ -23,6 +23,7 @@ import android.util.SparseBooleanArray;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.os.BatteryStatsHistory;
import com.android.internal.os.BatteryStatsHistoryIterator;
+import com.android.internal.os.MonotonicClock;
import java.util.function.Consumer;
@@ -169,10 +170,15 @@ public class PowerStatsAggregator {
}
}
}
- if (lastTime > baseTime) {
- mStats.setDuration(lastTime - baseTime);
- mStats.finish(lastTime);
- consumer.accept(mStats);
+ if (startedSession) {
+ if (endTimeMs != MonotonicClock.UNDEFINED) {
+ lastTime = endTimeMs;
+ }
+ if (lastTime > baseTime) {
+ mStats.setDuration(lastTime - baseTime);
+ mStats.finish(lastTime);
+ consumer.accept(mStats);
+ }
}
mStats.reset(); // to free up memory
diff --git a/services/core/java/com/android/server/wm/ActivityRecord.java b/services/core/java/com/android/server/wm/ActivityRecord.java
index 3467f947ece4..5989fc8465c6 100644
--- a/services/core/java/com/android/server/wm/ActivityRecord.java
+++ b/services/core/java/com/android/server/wm/ActivityRecord.java
@@ -3212,8 +3212,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
* will be ignored.
*/
boolean isUniversalResizeable() {
- final boolean isLargeScreen = mDisplayContent != null && mDisplayContent.getConfiguration()
- .smallestScreenWidthDp >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP
+ final boolean isLargeScreen = mDisplayContent != null && mDisplayContent.isLargeScreen()
&& mDisplayContent.getIgnoreOrientationRequest();
if (!canBeUniversalResizeable(info.applicationInfo, mWmService, isLargeScreen,
true /* forActivity */)) {
@@ -4585,6 +4584,19 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
}
}
+ /**
+ * Returns {@code true} if the requested orientation of this activity is the same as the
+ * resolved orientation of the from activity.
+ */
+ private boolean isStartingOrientationCompatible(@NonNull ActivityRecord fromActivity) {
+ final int fromOrientation = fromActivity.getConfiguration().orientation;
+ final int requestedOrientation = getRequestedConfigurationOrientation();
+ if (requestedOrientation == ORIENTATION_UNDEFINED) {
+ return fromOrientation == getConfiguration().orientation;
+ }
+ return fromOrientation == requestedOrientation;
+ }
+
private boolean transferStartingWindow(@NonNull ActivityRecord fromActivity) {
final WindowState tStartingWindow = fromActivity.mStartingWindow;
if (tStartingWindow != null && fromActivity.mStartingSurface != null) {
@@ -4604,13 +4616,7 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
}
// Do not transfer if the orientation doesn't match, redraw starting window while it is
// on top will cause flicker.
- final int fromOrientation = fromActivity.getConfiguration().orientation;
- final int requestedOrientation = getRequestedConfigurationOrientation();
- if (requestedOrientation == ORIENTATION_UNDEFINED) {
- if (fromOrientation != getConfiguration().orientation) {
- return false;
- }
- } else if (fromOrientation != requestedOrientation) {
+ if (!isStartingOrientationCompatible(fromActivity)) {
return false;
}
@@ -4708,6 +4714,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
}
return true;
} else if (fromActivity.mStartingData != null) {
+ if (fromActivity.mStartingData instanceof SnapshotStartingData
+ && !isStartingOrientationCompatible(fromActivity)) {
+ // Do not transfer because the snapshot will be distorted in different orientation.
+ return false;
+ }
// The previous app was getting ready to show a
// starting window, but hasn't yet done so. Steal it!
ProtoLog.v(WM_DEBUG_STARTING_WINDOW,
@@ -5408,10 +5419,16 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
}
void setDeferHidingClient() {
+ if (Flags.removeDeferHidingClient()) {
+ return;
+ }
mDeferHidingClient = true;
}
void clearDeferHidingClient() {
+ if (Flags.removeDeferHidingClient()) {
+ return;
+ }
if (!mDeferHidingClient) return;
mDeferHidingClient = false;
if (!mVisibleRequested) {
@@ -7141,9 +7158,11 @@ final class ActivityRecord extends WindowToken implements WindowManagerService.A
@Override
void setClientVisible(boolean clientVisible) {
- // TODO(shell-transitions): Remove mDeferHidingClient once everything is shell-transitions.
- // pip activities should just remain in clientVisible.
- if (!clientVisible && mDeferHidingClient) return;
+ if (!Flags.removeDeferHidingClient()) {
+ // TODO(shell-transitions): Remove mDeferHidingClient once everything is
+ // shell-transitions. pip activities should just remain in clientVisible.
+ if (!clientVisible && mDeferHidingClient) return;
+ }
super.setClientVisible(clientVisible);
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index c2141a7103be..f8086615b7d1 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -439,6 +439,10 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
*/
private boolean mSandboxDisplayApis = true;
+ /** Whether {@link #setIgnoreOrientationRequest} is called to override the default policy. */
+ @VisibleForTesting
+ boolean mHasSetIgnoreOrientationRequest;
+
/**
* Overridden display density for current user. Initialized with {@link #mInitialDisplayDensity}
* but can be set from Settings or via shell command "adb shell wm density".
@@ -6722,8 +6726,25 @@ class DisplayContent extends RootDisplayArea implements WindowManagerPolicy.Disp
return mDisplayPolicy.getSystemUiContext();
}
+ /** Returns {@code} true if the smallest screen width dp >= 600. */
+ boolean isLargeScreen() {
+ return getConfiguration().smallestScreenWidthDp
+ >= WindowManager.LARGE_SCREEN_SMALLEST_SCREEN_WIDTH_DP;
+ }
+
+ @Override
+ boolean getIgnoreOrientationRequest() {
+ if (mHasSetIgnoreOrientationRequest
+ || !com.android.window.flags.Flags.universalResizableByDefault()) {
+ return super.getIgnoreOrientationRequest();
+ }
+ // Large screen (sw >= 600dp) ignores orientation request by default.
+ return isLargeScreen() && !mWmService.isIgnoreOrientationRequestDisabled();
+ }
+
@Override
boolean setIgnoreOrientationRequest(boolean ignoreOrientationRequest) {
+ mHasSetIgnoreOrientationRequest = true;
if (mSetIgnoreOrientationRequest == ignoreOrientationRequest) return false;
final boolean rotationChanged = super.setIgnoreOrientationRequest(ignoreOrientationRequest);
mWmService.mDisplayWindowSettings.setIgnoreOrientationRequest(
diff --git a/services/core/java/com/android/server/wm/DisplayWindowSettings.java b/services/core/java/com/android/server/wm/DisplayWindowSettings.java
index f6d05d08cb04..f0ba822c37c5 100644
--- a/services/core/java/com/android/server/wm/DisplayWindowSettings.java
+++ b/services/core/java/com/android/server/wm/DisplayWindowSettings.java
@@ -374,9 +374,9 @@ class DisplayWindowSettings {
final DisplayInfo displayInfo = dc.getDisplayInfo();
final SettingsProvider.SettingsEntry settings = mSettingsProvider.getSettings(displayInfo);
- final boolean ignoreOrientationRequest = settings.mIgnoreOrientationRequest != null
- ? settings.mIgnoreOrientationRequest : false;
- dc.setIgnoreOrientationRequest(ignoreOrientationRequest);
+ if (settings.mIgnoreOrientationRequest != null) {
+ dc.setIgnoreOrientationRequest(settings.mIgnoreOrientationRequest);
+ }
dc.getDisplayRotation().resetAllowAllRotations();
}
diff --git a/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java b/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java
index 4230cd868c03..cba606cf2b0c 100644
--- a/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java
+++ b/services/core/java/com/android/server/wm/ImeInsetsSourceProvider.java
@@ -324,7 +324,8 @@ final class ImeInsetsSourceProvider extends InsetsSourceProvider {
if (target != imeControlTarget) {
// TODO(b/353463205): check if fromUser=false is correct here
boolean imeVisible = target.isRequestedVisible(WindowInsets.Type.ime());
- ImeTracker.Token statsToken = ImeTracker.forLogging().onStart(ImeTracker.TYPE_HIDE,
+ ImeTracker.Token statsToken = ImeTracker.forLogging().onStart(
+ imeVisible ? ImeTracker.TYPE_SHOW : ImeTracker.TYPE_HIDE,
ImeTracker.ORIGIN_SERVER,
imeVisible ? SoftInputShowHideReason.SHOW_INPUT_TARGET_CHANGED
: SoftInputShowHideReason.HIDE_INPUT_TARGET_CHANGED,
diff --git a/services/core/java/com/android/server/wm/RootWindowContainer.java b/services/core/java/com/android/server/wm/RootWindowContainer.java
index 46312aff1fb6..b3b8c6eab25e 100644
--- a/services/core/java/com/android/server/wm/RootWindowContainer.java
+++ b/services/core/java/com/android/server/wm/RootWindowContainer.java
@@ -156,6 +156,7 @@ import com.android.server.policy.PermissionPolicyInternal;
import com.android.server.policy.WindowManagerPolicy;
import com.android.server.utils.Slogf;
import com.android.server.wm.utils.RegionUtils;
+import com.android.window.flags.Flags;
import java.io.FileDescriptor;
import java.io.PrintWriter;
@@ -262,6 +263,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
int mCurrentUser;
/** Root task id of the front root task when user switched, indexed by userId. */
SparseIntArray mUserRootTaskInFront = new SparseIntArray(2);
+ SparseArray<IntArray> mUserVisibleRootTasks = new SparseArray<>();
/**
* A list of tokens that cause the top activity to be put to sleep.
@@ -1924,7 +1926,18 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
// appropriate.
removeRootTasksInWindowingModes(WINDOWING_MODE_PINNED);
- mUserRootTaskInFront.put(mCurrentUser, focusRootTaskId);
+ if (Flags.enableTopVisibleRootTaskPerUserTracking()) {
+ final IntArray visibleRootTasks = new IntArray();
+ forAllRootTasks(rootTask -> {
+ if (mCurrentUser == rootTask.mUserId && rootTask.isVisibleRequested()) {
+ visibleRootTasks.add(rootTask.getRootTaskId());
+ }
+ }, /* traverseTopToBottom */ false);
+ mUserVisibleRootTasks.put(mCurrentUser, visibleRootTasks);
+ } else {
+ mUserRootTaskInFront.put(mCurrentUser, focusRootTaskId);
+ }
+
mCurrentUser = userId;
mTaskSupervisor.mStartingUsers.add(uss);
@@ -1937,22 +1950,60 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
Slog.i(TAG, "Persisting top task because it belongs to an always-visible user");
// For a normal user-switch, we will restore the new user's task. But if the pre-switch
// top task is an always-visible (Communal) one, keep it even after the switch.
- mUserRootTaskInFront.put(mCurrentUser, focusRootTaskId);
+ if (Flags.enableTopVisibleRootTaskPerUserTracking()) {
+ final IntArray rootTasks = mUserVisibleRootTasks.get(mCurrentUser);
+ rootTasks.add(focusRootTaskId);
+ mUserVisibleRootTasks.put(mCurrentUser, rootTasks);
+ } else {
+ mUserRootTaskInFront.put(mCurrentUser, focusRootTaskId);
+ }
+
}
final int restoreRootTaskId = mUserRootTaskInFront.get(userId);
+ final IntArray rootTaskIdsToRestore = mUserVisibleRootTasks.get(userId);
+ boolean homeInFront = false;
+ if (Flags.enableTopVisibleRootTaskPerUserTracking()) {
+ if (rootTaskIdsToRestore == null) {
+ // If there are no root tasks saved, try restore id 0 which should create and launch
+ // the home task.
+ handleRootTaskLaunchOnUserSwitch(/* restoreRootTaskId */INVALID_TASK_ID);
+ homeInFront = true;
+ } else {
+ for (int i = 0; i < rootTaskIdsToRestore.size(); i++) {
+ handleRootTaskLaunchOnUserSwitch(rootTaskIdsToRestore.get(i));
+ }
+ // Check if the top task is type home
+ if (rootTaskIdsToRestore.size() > 0) {
+ final int topRootTaskId = rootTaskIdsToRestore.get(
+ rootTaskIdsToRestore.size() - 1);
+ homeInFront = isHomeTask(topRootTaskId);
+ }
+ }
+ } else {
+ handleRootTaskLaunchOnUserSwitch(restoreRootTaskId);
+ // Check if the top task is type home
+ homeInFront = isHomeTask(restoreRootTaskId);
+ }
+ return homeInFront;
+ }
+
+ private boolean isHomeTask(int taskId) {
+ final Task rootTask = getRootTask(taskId);
+ return rootTask != null && rootTask.isActivityTypeHome();
+ }
+
+ private void handleRootTaskLaunchOnUserSwitch(int restoreRootTaskId) {
Task rootTask = getRootTask(restoreRootTaskId);
if (rootTask == null) {
rootTask = getDefaultTaskDisplayArea().getOrCreateRootHomeTask();
}
- final boolean homeInFront = rootTask.isActivityTypeHome();
if (rootTask.isOnHomeDisplay()) {
rootTask.moveToFront("switchUserOnHomeDisplay");
} else {
// Root task was moved to another display while user was swapped out.
resumeHomeActivity(null, "switchUserOnOtherDisplay", getDefaultTaskDisplayArea());
}
- return homeInFront;
}
/** Returns whether the given user is to be always-visible (e.g. a communal profile). */
@@ -1963,7 +2014,11 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
}
void removeUser(int userId) {
- mUserRootTaskInFront.delete(userId);
+ if (Flags.enableTopVisibleRootTaskPerUserTracking()) {
+ mUserVisibleRootTasks.delete(userId);
+ } else {
+ mUserRootTaskInFront.delete(userId);
+ }
}
/**
@@ -1976,7 +2031,13 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
rootTask = getDefaultTaskDisplayArea().getOrCreateRootHomeTask();
}
- mUserRootTaskInFront.put(userId, rootTask.getRootTaskId());
+ if (Flags.enableTopVisibleRootTaskPerUserTracking()) {
+ final IntArray rootTasks = mUserVisibleRootTasks.get(userId, new IntArray());
+ rootTasks.add(rootTask.getRootTaskId());
+ mUserVisibleRootTasks.put(userId, rootTasks);
+ } else {
+ mUserRootTaskInFront.put(userId, rootTask.getRootTaskId());
+ }
}
}
@@ -2124,7 +2185,7 @@ class RootWindowContainer extends WindowContainer<DisplayContent>
if (!tf.isOrganizedTaskFragment()) {
return;
}
- tf.resetAdjacentTaskFragment();
+ tf.clearAdjacentTaskFragments();
tf.setCompanionTaskFragment(null /* companionTaskFragment */);
tf.setAnimationParams(TaskFragmentAnimationParams.DEFAULT);
if (tf.getTopNonFinishingActivity() != null) {
diff --git a/services/core/java/com/android/server/wm/TaskFragment.java b/services/core/java/com/android/server/wm/TaskFragment.java
index 51b8bd1f0091..9fb5bea132ef 100644
--- a/services/core/java/com/android/server/wm/TaskFragment.java
+++ b/services/core/java/com/android/server/wm/TaskFragment.java
@@ -94,6 +94,7 @@ import android.graphics.Point;
import android.graphics.Rect;
import android.os.IBinder;
import android.os.UserHandle;
+import android.util.ArraySet;
import android.util.DisplayMetrics;
import android.util.Slog;
import android.util.proto.ProtoOutputStream;
@@ -239,12 +240,20 @@ class TaskFragment extends WindowContainer<WindowContainer> {
/** This task fragment will be removed when the cleanup of its children are done. */
private boolean mIsRemovalRequested;
- /** The TaskFragment that is adjacent to this one. */
+ /** @deprecated b/373709676 replace with {@link #mAdjacentTaskFragments} */
+ @Deprecated
@Nullable
private TaskFragment mAdjacentTaskFragment;
/**
- * Unlike the {@link mAdjacentTaskFragment}, the companion TaskFragment is not always visually
+ * The TaskFragments that are adjacent to each other, including this TaskFragment.
+ * All TaskFragments in this set share the same set instance.
+ */
+ @Nullable
+ private AdjacentSet mAdjacentTaskFragments;
+
+ /**
+ * Unlike the {@link #mAdjacentTaskFragments}, the companion TaskFragment is not always visually
* adjacent to this one, but this TaskFragment will be removed by the organizer if the
* companion TaskFragment is removed.
*/
@@ -442,15 +451,24 @@ class TaskFragment extends WindowContainer<WindowContainer> {
return service.mWindowOrganizerController.getTaskFragment(token);
}
- void setAdjacentTaskFragment(@Nullable TaskFragment taskFragment) {
- if (mAdjacentTaskFragment == taskFragment) {
- return;
- }
- resetAdjacentTaskFragment();
- if (taskFragment != null) {
+ /** @deprecated b/373709676 replace with {@link #setAdjacentTaskFragments}. */
+ @Deprecated
+ void setAdjacentTaskFragment(@NonNull TaskFragment taskFragment) {
+ if (!Flags.allowMultipleAdjacentTaskFragments()) {
+ if (mAdjacentTaskFragment == taskFragment) {
+ return;
+ }
+ resetAdjacentTaskFragment();
mAdjacentTaskFragment = taskFragment;
taskFragment.setAdjacentTaskFragment(this);
+ return;
}
+
+ setAdjacentTaskFragments(new AdjacentSet(this, taskFragment));
+ }
+
+ void setAdjacentTaskFragments(@NonNull AdjacentSet adjacentTaskFragments) {
+ adjacentTaskFragments.setAsAdjacent();
}
void setCompanionTaskFragment(@Nullable TaskFragment companionTaskFragment) {
@@ -461,7 +479,14 @@ class TaskFragment extends WindowContainer<WindowContainer> {
return mCompanionTaskFragment;
}
- void resetAdjacentTaskFragment() {
+ /** @deprecated b/373709676 replace with {@link #clearAdjacentTaskFragments()}. */
+ @Deprecated
+ private void resetAdjacentTaskFragment() {
+ if (Flags.allowMultipleAdjacentTaskFragments()) {
+ throw new IllegalStateException("resetAdjacentTaskFragment shouldn't be called when"
+ + " allowMultipleAdjacentTaskFragments is enabled. Use either"
+ + " #clearAdjacentTaskFragments or #removeFromAdjacentTaskFragments");
+ }
// Reset the adjacent TaskFragment if its adjacent TaskFragment is also this TaskFragment.
if (mAdjacentTaskFragment != null && mAdjacentTaskFragment.mAdjacentTaskFragment == this) {
mAdjacentTaskFragment.mAdjacentTaskFragment = null;
@@ -471,6 +496,57 @@ class TaskFragment extends WindowContainer<WindowContainer> {
mDelayLastActivityRemoval = false;
}
+ void clearAdjacentTaskFragments() {
+ if (!Flags.allowMultipleAdjacentTaskFragments()) {
+ resetAdjacentTaskFragment();
+ return;
+ }
+
+ if (mAdjacentTaskFragments != null) {
+ mAdjacentTaskFragments.clear();
+ }
+ }
+
+ void removeFromAdjacentTaskFragments() {
+ if (!Flags.allowMultipleAdjacentTaskFragments()) {
+ resetAdjacentTaskFragment();
+ return;
+ }
+
+ if (mAdjacentTaskFragments != null) {
+ mAdjacentTaskFragments.remove(this);
+ }
+ }
+
+ // TODO(b/373709676): update usages.
+ /** @deprecated b/373709676 replace with {@link #getAdjacentTaskFragments()}. */
+ @Deprecated
+ @Nullable
+ TaskFragment getAdjacentTaskFragment() {
+ return mAdjacentTaskFragment;
+ }
+
+ @Nullable
+ AdjacentSet getAdjacentTaskFragments() {
+ return mAdjacentTaskFragments;
+ }
+
+ boolean hasAdjacentTaskFragment() {
+ if (!Flags.allowMultipleAdjacentTaskFragments()) {
+ return mAdjacentTaskFragment != null;
+ }
+ return mAdjacentTaskFragments != null;
+ }
+
+ boolean isAdjacentTo(@NonNull TaskFragment other) {
+ if (!Flags.allowMultipleAdjacentTaskFragments()) {
+ return mAdjacentTaskFragment == other;
+ }
+ return other != this
+ && mAdjacentTaskFragments != null
+ && mAdjacentTaskFragments.contains(other);
+ }
+
void setTaskFragmentOrganizer(@NonNull TaskFragmentOrganizerToken organizer, int uid,
@NonNull String processName) {
mTaskFragmentOrganizer = ITaskFragmentOrganizer.Stub.asInterface(organizer.asBinder());
@@ -566,10 +642,6 @@ class TaskFragment extends WindowContainer<WindowContainer> {
return isEmbedded() && mPinned;
}
- TaskFragment getAdjacentTaskFragment() {
- return mAdjacentTaskFragment;
- }
-
/** Returns the currently topmost resumed activity. */
@Nullable
ActivityRecord getTopResumedActivity() {
@@ -616,7 +688,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
mResumedActivity = r;
final ActivityRecord topResumed = mTaskSupervisor.updateTopResumedActivityIfNeeded(reason);
if (mResumedActivity != null && topResumed != null && topResumed.isEmbedded()
- && topResumed.getTaskFragment().getAdjacentTaskFragment() == this) {
+ && topResumed.getTaskFragment().isAdjacentTo(this)) {
// Explicitly updates the last resumed Activity if the resumed activity is
// adjacent to the top-resumed embedded activity.
mAtmService.setLastResumedActivityUncheckLocked(mResumedActivity, reason);
@@ -2036,7 +2108,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
private boolean shouldReportOrientationUnspecified() {
// Apps and their containers are not allowed to specify orientation from adjacent
// TaskFragment.
- return getAdjacentTaskFragment() != null && isVisibleRequested();
+ return hasAdjacentTaskFragment() && isVisibleRequested();
}
@Override
@@ -3086,7 +3158,7 @@ class TaskFragment extends WindowContainer<WindowContainer> {
EventLogTags.writeWmTfRemoved(System.identityHashCode(this), getTaskId());
}
mIsRemovalRequested = false;
- resetAdjacentTaskFragment();
+ removeFromAdjacentTaskFragments();
cleanUpEmbeddedTaskFragment();
final boolean shouldExecuteAppTransition =
mClearedTaskFragmentForPip && isTaskVisibleRequested();
@@ -3267,9 +3339,16 @@ class TaskFragment extends WindowContainer<WindowContainer> {
sb.append(" organizerProc=");
sb.append(mTaskFragmentOrganizerProcessName);
}
- if (mAdjacentTaskFragment != null) {
- sb.append(" adjacent=");
- sb.append(mAdjacentTaskFragment);
+ if (Flags.allowMultipleAdjacentTaskFragments()) {
+ if (mAdjacentTaskFragments != null) {
+ sb.append(" adjacent=");
+ sb.append(mAdjacentTaskFragments);
+ }
+ } else {
+ if (mAdjacentTaskFragment != null) {
+ sb.append(" adjacent=");
+ sb.append(mAdjacentTaskFragment);
+ }
}
sb.append('}');
return sb.toString();
@@ -3385,4 +3464,94 @@ class TaskFragment extends WindowContainer<WindowContainer> {
proto.end(token);
}
+
+ /** Set of {@link TaskFragment}s that are adjacent to each other. */
+ static class AdjacentSet {
+ private final ArraySet<TaskFragment> mAdjacentSet;
+
+ AdjacentSet(@NonNull TaskFragment... taskFragments) {
+ this(new ArraySet<>(taskFragments));
+ }
+
+ AdjacentSet(@NonNull ArraySet<TaskFragment> taskFragments) {
+ if (!Flags.allowMultipleAdjacentTaskFragments()) {
+ throw new IllegalStateException("allowMultipleAdjacentTaskFragments must be"
+ + " enabled to set more than two TaskFragments adjacent to each other.");
+ }
+ if (taskFragments.size() < 2) {
+ throw new IllegalArgumentException("Adjacent TaskFragments must contain at least"
+ + " two TaskFragments, but only " + taskFragments.size()
+ + " were provided.");
+ }
+ mAdjacentSet = taskFragments;
+ }
+
+ /** Updates each {@link TaskFragment} in the set to be adjacent to each other. */
+ private void setAsAdjacent() {
+ if (mAdjacentSet.isEmpty()
+ || equals(mAdjacentSet.valueAt(0).mAdjacentTaskFragments)) {
+ // No need to update if any TaskFragment in the set has already been updated to the
+ // same set.
+ return;
+ }
+ for (int i = mAdjacentSet.size() - 1; i >= 0; i--) {
+ final TaskFragment taskFragment = mAdjacentSet.valueAt(i);
+ taskFragment.removeFromAdjacentTaskFragments();
+ taskFragment.mAdjacentTaskFragments = this;
+ }
+ }
+
+ /** Removes the {@link TaskFragment} from the adjacent set. */
+ private void remove(@NonNull TaskFragment taskFragment) {
+ taskFragment.mAdjacentTaskFragments = null;
+ taskFragment.mDelayLastActivityRemoval = false;
+ mAdjacentSet.remove(taskFragment);
+ if (mAdjacentSet.size() < 2) {
+ // To be considered as adjacent, there must be at least 2 TaskFragments in the set.
+ clear();
+ }
+ }
+
+ /** Clears the adjacent relationship. */
+ private void clear() {
+ for (int i = mAdjacentSet.size() - 1; i >= 0; i--) {
+ final TaskFragment taskFragment = mAdjacentSet.valueAt(i);
+ // Clear all reference.
+ taskFragment.mAdjacentTaskFragments = null;
+ taskFragment.mDelayLastActivityRemoval = false;
+ }
+ mAdjacentSet.clear();
+ }
+
+ /** Whether the {@link TaskFragment} is in this adjacent set. */
+ boolean contains(@NonNull TaskFragment taskFragment) {
+ return mAdjacentSet.contains(taskFragment);
+ }
+
+ @Override
+ public boolean equals(@Nullable Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (!(o instanceof AdjacentSet other)) {
+ return false;
+ }
+ return mAdjacentSet.equals(other.mAdjacentSet);
+ }
+
+ @Override
+ public String toString() {
+ final StringBuilder sb = new StringBuilder();
+ sb.append("AdjacentSet{");
+ final int size = mAdjacentSet.size();
+ for (int i = 0; i < size; i++) {
+ if (i != 0) {
+ sb.append(", ");
+ }
+ sb.append(mAdjacentSet.valueAt(i));
+ }
+ sb.append("}");
+ return sb.toString();
+ }
+ }
}
diff --git a/services/core/java/com/android/server/wm/Transition.java b/services/core/java/com/android/server/wm/Transition.java
index 1fc609b7d03a..bcd12f253299 100644
--- a/services/core/java/com/android/server/wm/Transition.java
+++ b/services/core/java/com/android/server/wm/Transition.java
@@ -1870,7 +1870,13 @@ class Transition implements BLASTSyncEngine.TransactionReadyListener {
final DisplayArea<?> da = wc.asDisplayArea();
if (da == null) continue;
if (da.isVisibleRequested()) {
- mController.mValidateDisplayVis.remove(da);
+ final int inValidateList = mController.mValidateDisplayVis.indexOf(da);
+ if (inValidateList >= 0
+ // The display-area is visible, but if we only detect a non-visibility
+ // change, then we shouldn't remove the validator.
+ && !mChanges.get(da).mVisible) {
+ mController.mValidateDisplayVis.remove(inValidateList);
+ }
} else {
// In case something accidentally hides a displayarea and nothing shows it again.
mController.mValidateDisplayVis.add(da);
diff --git a/services/core/java/com/android/server/wm/WindowOrganizerController.java b/services/core/java/com/android/server/wm/WindowOrganizerController.java
index 66921ff3adeb..fb197c566b7d 100644
--- a/services/core/java/com/android/server/wm/WindowOrganizerController.java
+++ b/services/core/java/com/android/server/wm/WindowOrganizerController.java
@@ -1155,7 +1155,7 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
} else if (!task.mCreatedByOrganizer) {
throw new UnsupportedOperationException(
"Cannot set non-organized task as adjacent flag root: " + wc);
- } else if (task.getAdjacentTaskFragment() == null && !clearRoot) {
+ } else if (!task.hasAdjacentTaskFragment() && !clearRoot) {
throw new UnsupportedOperationException(
"Cannot set non-adjacent task as adjacent flag root: " + wc);
}
@@ -1645,9 +1645,15 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
opType, exception);
break;
}
- if (taskFragment.getAdjacentTaskFragment() != secondaryTaskFragment) {
+ if (!taskFragment.isAdjacentTo(secondaryTaskFragment)) {
// Only have lifecycle effect if the adjacent changed.
- taskFragment.setAdjacentTaskFragment(secondaryTaskFragment);
+ if (Flags.allowMultipleAdjacentTaskFragments()) {
+ // Activity Embedding only set two TFs adjacent.
+ taskFragment.setAdjacentTaskFragments(
+ new TaskFragment.AdjacentSet(taskFragment, secondaryTaskFragment));
+ } else {
+ taskFragment.setAdjacentTaskFragment(secondaryTaskFragment);
+ }
effects |= TRANSACT_EFFECTS_LIFECYCLE;
}
@@ -1663,21 +1669,25 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
break;
}
case OP_TYPE_CLEAR_ADJACENT_TASK_FRAGMENTS: {
- final TaskFragment adjacentTaskFragment = taskFragment.getAdjacentTaskFragment();
- if (adjacentTaskFragment == null) {
+ if (!taskFragment.hasAdjacentTaskFragment()) {
break;
}
- taskFragment.resetAdjacentTaskFragment();
- effects |= TRANSACT_EFFECTS_LIFECYCLE;
- // Clear the focused app if the focused app is no longer visible after reset the
- // adjacent TaskFragments.
+ // Check if the focused app is in the adjacent set that will be cleared.
final ActivityRecord focusedApp = taskFragment.getDisplayContent().mFocusedApp;
final TaskFragment focusedTaskFragment = focusedApp != null
? focusedApp.getTaskFragment()
: null;
- if ((focusedTaskFragment == taskFragment
- || focusedTaskFragment == adjacentTaskFragment)
+ final boolean wasFocusedInAdjacent = focusedTaskFragment == taskFragment
+ || (focusedTaskFragment != null
+ && taskFragment.isAdjacentTo(focusedTaskFragment));
+
+ taskFragment.removeFromAdjacentTaskFragments();
+ effects |= TRANSACT_EFFECTS_LIFECYCLE;
+
+ // Clear the focused app if the focused app is no longer visible after reset the
+ // adjacent TaskFragments.
+ if (wasFocusedInAdjacent
&& !focusedTaskFragment.shouldBeVisible(null /* starting */)) {
focusedTaskFragment.getDisplayContent().setFocusedApp(null /* newFocus */);
}
@@ -2191,26 +2201,60 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
}
private int setAdjacentRootsHierarchyOp(WindowContainerTransaction.HierarchyOp hop) {
- final WindowContainer wc1 = WindowContainer.fromBinder(hop.getContainer());
- if (wc1 == null || !wc1.isAttached()) {
- Slog.e(TAG, "Attempt to operate on unknown or detached container: " + wc1);
- return TRANSACT_EFFECTS_NONE;
- }
- final TaskFragment root1 = wc1.asTaskFragment();
- final WindowContainer wc2 = WindowContainer.fromBinder(hop.getAdjacentRoot());
- if (wc2 == null || !wc2.isAttached()) {
- Slog.e(TAG, "Attempt to operate on unknown or detached container: " + wc2);
- return TRANSACT_EFFECTS_NONE;
- }
- final TaskFragment root2 = wc2.asTaskFragment();
- if (!root1.mCreatedByOrganizer || !root2.mCreatedByOrganizer) {
- throw new IllegalArgumentException("setAdjacentRootsHierarchyOp: Not created by"
- + " organizer root1=" + root1 + " root2=" + root2);
- }
- if (root1.getAdjacentTaskFragment() == root2) {
+ if (!Flags.allowMultipleAdjacentTaskFragments()) {
+ final WindowContainer wc1 = WindowContainer.fromBinder(hop.getContainer());
+ if (wc1 == null || !wc1.isAttached()) {
+ Slog.e(TAG, "Attempt to operate on unknown or detached container: " + wc1);
+ return TRANSACT_EFFECTS_NONE;
+ }
+ final TaskFragment root1 = wc1.asTaskFragment();
+ final WindowContainer wc2 = WindowContainer.fromBinder(hop.getAdjacentRoot());
+ if (wc2 == null || !wc2.isAttached()) {
+ Slog.e(TAG, "Attempt to operate on unknown or detached container: " + wc2);
+ return TRANSACT_EFFECTS_NONE;
+ }
+ final TaskFragment root2 = wc2.asTaskFragment();
+ if (!root1.mCreatedByOrganizer || !root2.mCreatedByOrganizer) {
+ throw new IllegalArgumentException("setAdjacentRootsHierarchyOp: Not created by"
+ + " organizer root1=" + root1 + " root2=" + root2);
+ }
+ if (root1.isAdjacentTo(root2)) {
+ return TRANSACT_EFFECTS_NONE;
+ }
+ root1.setAdjacentTaskFragment(root2);
+ return TRANSACT_EFFECTS_LIFECYCLE;
+ }
+
+ final IBinder[] containers = hop.getContainers();
+ final ArraySet<TaskFragment> adjacentRoots = new ArraySet<>();
+ for (IBinder container : containers) {
+ final WindowContainer wc = WindowContainer.fromBinder(container);
+ if (wc == null || !wc.isAttached()) {
+ Slog.e(TAG, "Attempt to operate on unknown or detached container: " + wc);
+ return TRANSACT_EFFECTS_NONE;
+ }
+ final Task root = wc.asTask();
+ if (root == null) {
+ // Only support Task. Use WCT#setAdjacentTaskFragments for non-Task TaskFragment.
+ throw new IllegalArgumentException("setAdjacentRootsHierarchyOp: Not called with"
+ + " Task. wc=" + wc);
+ }
+ if (!root.mCreatedByOrganizer) {
+ throw new IllegalArgumentException("setAdjacentRootsHierarchyOp: Not created by"
+ + " organizer root=" + root);
+ }
+ if (adjacentRoots.contains(root)) {
+ throw new IllegalArgumentException("setAdjacentRootsHierarchyOp: called with same"
+ + " root twice=" + root);
+ }
+ adjacentRoots.add(root);
+ }
+ final TaskFragment root0 = adjacentRoots.valueAt(0);
+ final TaskFragment.AdjacentSet adjacentSet = new TaskFragment.AdjacentSet(adjacentRoots);
+ if (adjacentSet.equals(root0.getAdjacentTaskFragments())) {
return TRANSACT_EFFECTS_NONE;
}
- root1.setAdjacentTaskFragment(root2);
+ root0.setAdjacentTaskFragments(adjacentSet);
return TRANSACT_EFFECTS_LIFECYCLE;
}
@@ -2225,10 +2269,10 @@ class WindowOrganizerController extends IWindowOrganizerController.Stub
throw new IllegalArgumentException("clearAdjacentRootsHierarchyOp: Not created by"
+ " organizer root=" + root);
}
- if (root.getAdjacentTaskFragment() == null) {
+ if (!root.hasAdjacentTaskFragment()) {
return TRANSACT_EFFECTS_NONE;
}
- root.resetAdjacentTaskFragment();
+ root.removeFromAdjacentTaskFragments();
return TRANSACT_EFFECTS_LIFECYCLE;
}
diff --git a/services/credentials/java/com/android/server/credentials/CredentialManagerUi.java b/services/credentials/java/com/android/server/credentials/CredentialManagerUi.java
index 0c9a89bb0a30..8533eafaf9e0 100644
--- a/services/credentials/java/com/android/server/credentials/CredentialManagerUi.java
+++ b/services/credentials/java/com/android/server/credentials/CredentialManagerUi.java
@@ -114,7 +114,7 @@ public class CredentialManagerUi {
/** Creates intent that is ot be invoked to cancel an in-progress UI session. */
public Intent createCancelIntent(IBinder requestId, String packageName) {
return IntentFactory.createCancelUiIntent(mContext, requestId,
- /*shouldShowCancellationUi=*/ true, packageName);
+ /*shouldShowCancellationUi=*/ true, packageName, mUserId);
}
/**
@@ -177,7 +177,7 @@ public class CredentialManagerUi {
IntentCreationResult intentCreationResult = IntentFactory
.createCredentialSelectorIntentForCredMan(mContext, requestInfo, providerDataList,
- new ArrayList<>(disabledProviderDataList), mResultReceiver);
+ new ArrayList<>(disabledProviderDataList), mResultReceiver, mUserId);
requestSessionMetric.collectUiConfigurationResults(
mContext, intentCreationResult, mUserId);
Intent intent = intentCreationResult.getIntent();
@@ -211,7 +211,7 @@ public class CredentialManagerUi {
RequestSessionMetric requestSessionMetric) {
IntentCreationResult intentCreationResult = IntentFactory
.createCredentialSelectorIntentForAutofill(mContext, requestInfo, new ArrayList<>(),
- mResultReceiver);
+ mResultReceiver, mUserId);
requestSessionMetric.collectUiConfigurationResults(
mContext, intentCreationResult, mUserId);
return intentCreationResult.getIntent();
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 365cbaed2aac..724f083018f2 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/DisplayManagerServiceTest.java
@@ -3708,7 +3708,7 @@ public class DisplayManagerServiceTest {
eq(config));
bs.releaseVirtualDisplay(mMockAppToken);
- verify(mMockVirtualDisplayAdapter).releaseVirtualDisplayLocked(binder, callingUid);
+ verify(mMockVirtualDisplayAdapter).releaseVirtualDisplayLocked(binder);
}
@Test
diff --git a/services/tests/displayservicetests/src/com/android/server/display/VirtualDisplayAdapterTest.java b/services/tests/displayservicetests/src/com/android/server/display/VirtualDisplayAdapterTest.java
index dbd5c65f9ba3..9287b3004279 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/VirtualDisplayAdapterTest.java
+++ b/services/tests/displayservicetests/src/com/android/server/display/VirtualDisplayAdapterTest.java
@@ -118,14 +118,13 @@ public class VirtualDisplayAdapterTest {
public void testCreateAndReleaseVirtualDisplay() {
VirtualDisplayConfig config = new VirtualDisplayConfig.Builder("test", /* width= */ 1,
/* height= */ 1, /* densityDpi= */ 1).build();
- int ownerUid = 10;
DisplayDevice result = mAdapter.createVirtualDisplayLocked(mMockCallback,
- /* projection= */ null, ownerUid, /* packageName= */ "testpackage",
+ /* projection= */ null, /* ownerUid= */ 10, /* packageName= */ "testpackage",
/* uniqueId= */ "uniqueId", /* surface= */ null, /* flags= */ 0, config);
assertNotNull(result);
- result = mAdapter.releaseVirtualDisplayLocked(mMockBinder, ownerUid);
+ result = mAdapter.releaseVirtualDisplayLocked(mMockBinder);
assertNotNull(result);
}
@@ -230,7 +229,6 @@ public class VirtualDisplayAdapterTest {
// Displays for the same package
for (int i = 0; i < MAX_DEVICES_PER_PACKAGE * 2; i++) {
- // Same owner UID
IVirtualDisplayCallback callback = createCallback();
DisplayDevice device = mAdapter.createVirtualDisplayLocked(callback,
mMediaProjectionMock, 1234, "test.package", "123",
@@ -240,7 +238,6 @@ public class VirtualDisplayAdapterTest {
// Displays for different packages
for (int i = 0; i < MAX_DEVICES * 2; i++) {
- // Same owner UID
IVirtualDisplayCallback callback = createCallback();
DisplayDevice device = mAdapter.createVirtualDisplayLocked(callback,
mMediaProjectionMock, 1234 + i, "test.package", "123",
@@ -270,8 +267,7 @@ public class VirtualDisplayAdapterTest {
}
// Release one display
- DisplayDevice device = mAdapter.releaseVirtualDisplayLocked(callbacks.get(0).asBinder(),
- ownerUid);
+ DisplayDevice device = mAdapter.releaseVirtualDisplayLocked(callbacks.get(0).asBinder());
assertNotNull(device);
callbacks.remove(0);
@@ -292,7 +288,7 @@ public class VirtualDisplayAdapterTest {
// Release all the displays
for (IVirtualDisplayCallback cb : callbacks) {
- device = mAdapter.releaseVirtualDisplayLocked(cb.asBinder(), ownerUid);
+ device = mAdapter.releaseVirtualDisplayLocked(cb.asBinder());
assertNotNull(device);
}
callbacks.clear();
@@ -342,8 +338,7 @@ public class VirtualDisplayAdapterTest {
}
// Release one display
- DisplayDevice device = mAdapter.releaseVirtualDisplayLocked(callbacks.get(0).asBinder(),
- firstOwnerUid);
+ DisplayDevice device = mAdapter.releaseVirtualDisplayLocked(callbacks.get(0).asBinder());
assertNotNull(device);
callbacks.remove(0);
@@ -363,9 +358,8 @@ public class VirtualDisplayAdapterTest {
assertNull(device);
// Release all the displays
- for (int i = 0; i < callbacks.size(); i++) {
- device = mAdapter.releaseVirtualDisplayLocked(callbacks.get(i).asBinder(),
- firstOwnerUid + i);
+ for (IVirtualDisplayCallback iVirtualDisplayCallback : callbacks) {
+ device = mAdapter.releaseVirtualDisplayLocked(iVirtualDisplayCallback.asBinder());
assertNotNull(device);
}
callbacks.clear();
diff --git a/services/tests/displayservicetests/src/com/android/server/display/mode/RejectedModesVoteTest.kt b/services/tests/displayservicetests/src/com/android/server/display/mode/RejectedModesVoteTest.kt
new file mode 100644
index 000000000000..dd3211d0ef83
--- /dev/null
+++ b/services/tests/displayservicetests/src/com/android/server/display/mode/RejectedModesVoteTest.kt
@@ -0,0 +1,58 @@
+/*
+ * 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.display.mode
+
+import androidx.test.ext.junit.runners.AndroidJUnit4
+import androidx.test.filters.SmallTest
+import com.google.common.truth.Truth.assertThat
+import org.junit.Before
+import org.junit.Test
+import org.junit.runner.RunWith
+
+@SmallTest
+@RunWith(AndroidJUnit4::class)
+class RejectedModesVoteTest {
+ private val rejectedModes = setOf(1, 2)
+
+ private val otherMode = 2
+
+ private lateinit var rejectedModesVote: RejectedModesVote
+
+ @Before
+ fun setUp() {
+ rejectedModesVote = RejectedModesVote(rejectedModes)
+ }
+
+ @Test
+ fun addsRejectedModeIds_summaryIsEmpty() {
+ val summary = createVotesSummary()
+
+ rejectedModesVote.updateSummary(summary)
+
+ assertThat(summary.rejectedModeIds).containsExactlyElementsIn(rejectedModes)
+ }
+
+ @Test
+ fun addsRejectedModeIds_summaryIsNotEmpty() {
+ val summary = createVotesSummary()
+ summary.rejectedModeIds.add(otherMode)
+
+ rejectedModesVote.updateSummary(summary)
+
+ assertThat(summary.rejectedModeIds).containsExactlyElementsIn(rejectedModes + otherMode)
+ }
+} \ No newline at end of file
diff --git a/services/tests/displayservicetests/src/com/android/server/display/mode/VoteSummaryTest.kt b/services/tests/displayservicetests/src/com/android/server/display/mode/VoteSummaryTest.kt
index 239e59b69187..958cf21a38a2 100644
--- a/services/tests/displayservicetests/src/com/android/server/display/mode/VoteSummaryTest.kt
+++ b/services/tests/displayservicetests/src/com/android/server/display/mode/VoteSummaryTest.kt
@@ -186,6 +186,44 @@ class VoteSummaryTest {
assertThat(result).hasSize(1)
}
+
+ enum class RejectedModesTestCase(
+ internal val summaryRejectedModes: Set<Int>?,
+ val modesToFilter: Array<Display.Mode>,
+ val expectedModeIds: Set<Int>
+ ) {
+ HAS_NO_MATCHING_VOTE(
+ setOf(4, 5),
+ arrayOf(createMode(1, 90f, 90f),
+ createMode(2, 90f, 60f),
+ createMode(3, 60f, 90f)),
+ setOf(1, 2, 3)
+ ),
+ HAS_SINGLE_MATCHING_VOTE(
+ setOf(1),
+ arrayOf(createMode(1, 90f, 90f),
+ createMode(2, 90f, 60f),
+ createMode(3, 60f, 90f)),
+ setOf(2, 3)
+ ),
+ HAS_MULTIPLE_MATCHING_VOTES(
+ setOf(1, 2),
+ arrayOf(createMode(1, 90f, 90f),
+ createMode(2, 90f, 60f),
+ createMode(3, 60f, 90f)),
+ setOf(3)
+ ),
+ }
+
+ @Test
+ fun testFilterModes_rejectedModes(@TestParameter testCase: RejectedModesTestCase) {
+ val summary = createSummary()
+ summary.rejectedModeIds = testCase.summaryRejectedModes
+
+ val result = summary.filterModes(testCase.modesToFilter)
+
+ assertThat(result.map {it.modeId}).containsExactlyElementsIn(testCase.expectedModeIds)
+ }
}
diff --git a/services/tests/dreamservicetests/src/com/android/server/dreams/DreamControllerTest.java b/services/tests/dreamservicetests/src/com/android/server/dreams/DreamControllerTest.java
index 874e99173c63..495e853370ee 100644
--- a/services/tests/dreamservicetests/src/com/android/server/dreams/DreamControllerTest.java
+++ b/services/tests/dreamservicetests/src/com/android/server/dreams/DreamControllerTest.java
@@ -46,7 +46,6 @@ import android.os.RemoteException;
import android.os.test.TestLooper;
import android.service.dreams.IDreamService;
-import androidx.test.filters.FlakyTest;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;
@@ -108,10 +107,8 @@ public class DreamControllerTest {
.thenReturn(Context.ACTIVITY_TASK_SERVICE);
final PowerManager powerManager = new PowerManager(mContext, mPowerManager, null, null);
- when(mContext.getSystemService(Context.POWER_SERVICE))
+ when(mContext.getSystemService(PowerManager.class))
.thenReturn(powerManager);
- when(mContext.getSystemServiceName(PowerManager.class))
- .thenReturn(Context.POWER_SERVICE);
when(mContext.getResources()).thenReturn(mResources);
mToken = new Binder();
@@ -234,8 +231,13 @@ public class DreamControllerTest {
}
@Test
- @FlakyTest(bugId = 293109503)
public void serviceDisconnect_resetsScreenTimeout() throws RemoteException {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_resetScreenTimeoutOnUnexpectedDreamExit))
+ .thenReturn(true);
+ // Recreate DreamManager because the configuration gets retrieved in the constructor
+ mDreamController = new DreamController(mContext, mHandler, mListener);
+
// Start dream.
mDreamController.startDream(mToken, mDreamName, false /*isPreview*/, false /*doze*/,
0 /*userId*/, null /*wakeLock*/, mOverlayName, "test" /*reason*/);
@@ -254,8 +256,13 @@ public class DreamControllerTest {
}
@Test
- @FlakyTest(bugId = 293109503)
public void binderDied_resetsScreenTimeout() throws RemoteException {
+ when(mResources.getBoolean(
+ com.android.internal.R.bool.config_resetScreenTimeoutOnUnexpectedDreamExit))
+ .thenReturn(true);
+ // Recreate DreamManager because the configuration gets retrieved in the constructor
+ mDreamController = new DreamController(mContext, mHandler, mListener);
+
// Start dream.
mDreamController.startDream(mToken, mDreamName, false /*isPreview*/, false /*doze*/,
0 /*userId*/, null /*wakeLock*/, mOverlayName, "test" /*reason*/);
diff --git a/services/tests/mockingservicestests/src/com/android/server/pm/InstallDependencyHelperTest.java b/services/tests/mockingservicestests/src/com/android/server/pm/InstallDependencyHelperTest.java
index 0304a74f7654..cd8d415bdfa2 100644
--- a/services/tests/mockingservicestests/src/com/android/server/pm/InstallDependencyHelperTest.java
+++ b/services/tests/mockingservicestests/src/com/android/server/pm/InstallDependencyHelperTest.java
@@ -21,11 +21,7 @@ import static android.content.pm.Flags.FLAG_SDK_DEPENDENCY_INSTALLER;
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.fail;
-import static org.mockito.ArgumentMatchers.any;
-import static org.mockito.ArgumentMatchers.eq;
-import static org.mockito.Mockito.doThrow;
import static org.mockito.Mockito.mock;
-import static org.mockito.Mockito.when;
import android.content.Context;
import android.content.pm.SharedLibraryInfo;
@@ -90,32 +86,15 @@ public class InstallDependencyHelperTest {
}
@Test
- public void testResolveLibraryDependenciesIfNeeded_errorInSharedLibrariesImpl()
- throws Exception {
- doThrow(new PackageManagerException(new Exception("xyz")))
- .when(mSharedLibraries).collectMissingSharedLibraryInfos(any());
-
- PackageLite pkg = getPackageLite(TEST_APP_USING_SDK1_AND_SDK2);
- CallbackHelper callback = new CallbackHelper(/*expectSuccess=*/ false);
- mInstallDependencyHelper.resolveLibraryDependenciesIfNeeded(pkg, mComputer,
- 0, mHandler, callback);
- callback.assertFailure();
-
- assertThat(callback.error).hasMessageThat().contains("xyz");
- }
-
- @Test
public void testResolveLibraryDependenciesIfNeeded_failsToBind() throws Exception {
// Return a non-empty list as missing dependency
PackageLite pkg = getPackageLite(TEST_APP_USING_SDK1_AND_SDK2);
List<SharedLibraryInfo> missingDependency = Collections.singletonList(
mock(SharedLibraryInfo.class));
- when(mSharedLibraries.collectMissingSharedLibraryInfos(eq(pkg)))
- .thenReturn(missingDependency);
CallbackHelper callback = new CallbackHelper(/*expectSuccess=*/ false);
- mInstallDependencyHelper.resolveLibraryDependenciesIfNeeded(pkg, mComputer,
- 0, mHandler, callback);
+ mInstallDependencyHelper.resolveLibraryDependenciesIfNeeded(missingDependency, pkg,
+ mComputer, 0, mHandler, callback);
callback.assertFailure();
assertThat(callback.error).hasMessageThat().contains(
@@ -128,12 +107,10 @@ public class InstallDependencyHelperTest {
// Return an empty list as missing dependency
PackageLite pkg = getPackageLite(TEST_APP_USING_SDK1_AND_SDK2);
List<SharedLibraryInfo> missingDependency = Collections.emptyList();
- when(mSharedLibraries.collectMissingSharedLibraryInfos(eq(pkg)))
- .thenReturn(missingDependency);
CallbackHelper callback = new CallbackHelper(/*expectSuccess=*/ true);
- mInstallDependencyHelper.resolveLibraryDependenciesIfNeeded(pkg, mComputer,
- 0, mHandler, callback);
+ mInstallDependencyHelper.resolveLibraryDependenciesIfNeeded(missingDependency, pkg,
+ mComputer, 0, mHandler, callback);
callback.assertSuccess();
}
diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsProviderTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsProviderTest.java
index 709f83ba907d..73dcfe77e67f 100644
--- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsProviderTest.java
+++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsProviderTest.java
@@ -36,6 +36,7 @@ import android.os.BatteryStats;
import android.os.BatteryUsageStats;
import android.os.BatteryUsageStatsQuery;
import android.os.ConditionVariable;
+import android.os.Handler;
import android.os.Parcel;
import android.os.Process;
import android.os.UidBatteryConsumer;
@@ -81,8 +82,9 @@ public class BatteryUsageStatsProviderTest {
.setAveragePower(PowerProfile.POWER_BATTERY_CAPACITY, 4000.0);
private MockClock mMockClock = mStatsRule.getMockClock();
- private MonotonicClock mMonotonicClock = new MonotonicClock(666777, mMockClock);
+ private MonotonicClock mMonotonicClock = mStatsRule.getMonotonicClock();
private Context mContext;
+ private PowerStatsStore mPowerStatsStore;
@Before
public void setup() throws IOException {
@@ -93,6 +95,9 @@ public class BatteryUsageStatsProviderTest {
} else {
mContext = InstrumentationRegistry.getContext();
}
+ mPowerStatsStore = spy(new PowerStatsStore(
+ new File(mStatsRule.getHistoryDir(), getClass().getSimpleName()),
+ mStatsRule.getHandler()));
}
@Test
@@ -274,10 +279,7 @@ public class BatteryUsageStatsProviderTest {
powerAttributor.setPowerComponentSupported(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT,
true);
- BatteryUsageStatsProvider provider = new BatteryUsageStatsProvider(mContext,
- powerAttributor, mStatsRule.getPowerProfile(),
- mStatsRule.getCpuScalingPolicies(), mock(PowerStatsStore.class), 0, mMockClock,
- mMonotonicClock);
+ BatteryUsageStatsProvider provider = createBatteryUsageStatsProvider(0);
return provider.getBatteryUsageStats(batteryStats, BatteryUsageStatsQuery.DEFAULT);
}
@@ -331,30 +333,30 @@ public class BatteryUsageStatsProviderTest {
BatteryStats.HistoryItem item;
assertThat(item = iterator.next()).isNotNull();
- assertHistoryItem(item,
+ assertHistoryItem(batteryStats, item,
BatteryStats.HistoryItem.CMD_RESET, BatteryStats.HistoryItem.EVENT_NONE,
null, 0, 3_600_000, 90, 1_000_000);
assertThat(item = iterator.next()).isNotNull();
- assertHistoryItem(item,
+ assertHistoryItem(batteryStats, item,
BatteryStats.HistoryItem.CMD_UPDATE, BatteryStats.HistoryItem.EVENT_NONE,
null, 0, 3_600_000, 90, 1_000_000);
assertThat(item.states & BatteryStats.HistoryItem.STATE_CPU_RUNNING_FLAG).isNotEqualTo(0);
assertThat(item = iterator.next()).isNotNull();
- assertHistoryItem(item,
+ assertHistoryItem(batteryStats, item,
BatteryStats.HistoryItem.CMD_UPDATE, BatteryStats.HistoryItem.EVENT_NONE,
null, 0, 3_600_000, 90, 2_000_000);
assertThat(item.states & BatteryStats.HistoryItem.STATE_CPU_RUNNING_FLAG).isEqualTo(0);
assertThat(item = iterator.next()).isNotNull();
- assertHistoryItem(item,
+ assertHistoryItem(batteryStats, item,
BatteryStats.HistoryItem.CMD_UPDATE,
BatteryStats.HistoryItem.EVENT_ALARM | BatteryStats.HistoryItem.EVENT_FLAG_START,
"foo", APP_UID, 3_600_000, 90, 3_000_000);
assertThat(item = iterator.next()).isNotNull();
- assertHistoryItem(item,
+ assertHistoryItem(batteryStats, item,
BatteryStats.HistoryItem.CMD_UPDATE,
BatteryStats.HistoryItem.EVENT_ALARM | BatteryStats.HistoryItem.EVENT_FLAG_FINISH,
"foo", APP_UID, 3_600_000, 90, 3_001_000);
@@ -441,14 +443,15 @@ public class BatteryUsageStatsProviderTest {
assertThat(item.eventTag.string).startsWith(uid + " ");
assertThat(item.batteryChargeUah).isEqualTo(3_600_000);
assertThat(item.batteryLevel).isEqualTo(90);
- assertThat(item.time).isEqualTo((long) 1_000_000);
+ assertThat(item.time).isEqualTo(batteryStats.getMonotonicStartTime() + 1_000_000);
}
assertThat(expectedUid).isEqualTo(200);
}
- private void assertHistoryItem(BatteryStats.HistoryItem item, int command, int eventCode,
- String tag, int uid, int batteryChargeUah, int batteryLevel, long elapsedTimeMs) {
+ private void assertHistoryItem(MockBatteryStatsImpl batteryStats, BatteryStats.HistoryItem item,
+ int command, int eventCode, String tag, int uid, int batteryChargeUah, int batteryLevel,
+ long elapsedTimeMs) {
assertThat(item.cmd).isEqualTo(command);
assertThat(item.eventCode).isEqualTo(eventCode);
if (tag == null) {
@@ -460,7 +463,7 @@ public class BatteryUsageStatsProviderTest {
assertThat(item.batteryChargeUah).isEqualTo(batteryChargeUah);
assertThat(item.batteryLevel).isEqualTo(batteryLevel);
- assertThat(item.time).isEqualTo(elapsedTimeMs);
+ assertThat(item.time).isEqualTo(batteryStats.getMonotonicStartTime() + elapsedTimeMs);
}
@Test
@@ -566,38 +569,66 @@ public class BatteryUsageStatsProviderTest {
assertThat(stats.getStatsStartTimestamp()).isEqualTo(5 * MINUTE_IN_MS);
assertThat(stats.getStatsEndTimestamp()).isEqualTo(55 * MINUTE_IN_MS);
- assertThat(stats.getAggregateBatteryConsumer(
- BatteryUsageStats.AGGREGATE_BATTERY_CONSUMER_SCOPE_DEVICE)
- .getConsumedPower(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT))
- .isWithin(0.0001)
- .of(180.0); // 360 mA * 0.5 hours
- assertThat(stats.getAggregateBatteryConsumer(
- BatteryUsageStats.AGGREGATE_BATTERY_CONSUMER_SCOPE_DEVICE)
- .getUsageDurationMillis(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT))
- .isEqualTo((10 + 20) * MINUTE_IN_MS);
- final UidBatteryConsumer uidBatteryConsumer = stats.getUidBatteryConsumers().stream()
- .filter(uid -> uid.getUid() == APP_UID).findFirst().get();
- assertThat(uidBatteryConsumer
- .getConsumedPower(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT))
- .isWithin(0.1)
- .of(180.0);
+ assertBatteryConsumer(stats, 180.0, (10 + 20) * MINUTE_IN_MS);
+ assertBatteryConsumer(stats, APP_UID, 180.0, (10 + 20) * MINUTE_IN_MS);
stats.close();
}
@Test
public void accumulateBatteryUsageStats() throws Throwable {
- accumulateBatteryUsageStats(10000000, 1);
+ MockBatteryStatsImpl batteryStats = mStatsRule.getBatteryStats();
+ accumulateBatteryUsageStats(batteryStats, 10000000, 0);
// Accumulate every 200 bytes of battery history
- accumulateBatteryUsageStats(200, 2);
- accumulateBatteryUsageStats(50, 5);
+ accumulateBatteryUsageStats(batteryStats, 200, 2);
+ accumulateBatteryUsageStats(batteryStats, 50, 4);
// Accumulate on every invocation of accumulateBatteryUsageStats
- accumulateBatteryUsageStats(0, 7);
+ accumulateBatteryUsageStats(batteryStats, 0, 7);
}
- private void accumulateBatteryUsageStats(int accumulatedBatteryUsageStatsSpanSize,
- int expectedNumberOfUpdates) throws Throwable {
- BatteryStatsImpl batteryStats = spy(mStatsRule.getBatteryStats());
+ @Test
+ public void getAccumulatedBatteryUsageStats() throws Throwable {
+ MockBatteryStatsImpl batteryStats = mStatsRule.getBatteryStats();
+
+ // Only accumulate the first 25 minutes
+ accumulateBatteryUsageStats(batteryStats, 200, 1);
+
+ BatteryUsageStatsProvider batteryUsageStatsProvider = createBatteryUsageStatsProvider(200);
+
+ // At this point the last stored accumulated stats are `115 - 30 = 85` minutes old
+ BatteryUsageStats stats = batteryUsageStatsProvider.getBatteryUsageStats(batteryStats,
+ new BatteryUsageStatsQuery.Builder()
+ .accumulated()
+ .setMaxStatsAgeMs(90 * MINUTE_IN_MS)
+ .build());
+
+ assertThat(stats.getStatsStartTimestamp()).isEqualTo(5 * MINUTE_IN_MS);
+ assertThat(stats.getStatsEndTimestamp()).isEqualTo(30 * MINUTE_IN_MS);
+ assertBatteryConsumer(stats, 60.0, 10 * MINUTE_IN_MS);
+ assertBatteryConsumer(stats, APP_UID, 60.0, 10 * MINUTE_IN_MS);
+
+ stats.close();
+
+ // Now force the usage stats to catch up to the current time
+ stats = batteryUsageStatsProvider.getBatteryUsageStats(batteryStats,
+ new BatteryUsageStatsQuery.Builder()
+ .accumulated()
+ .setMaxStatsAgeMs(5 * MINUTE_IN_MS)
+ .build());
+
+ assertThat(stats.getStatsStartTimestamp()).isEqualTo(5 * MINUTE_IN_MS);
+ assertThat(stats.getStatsEndTimestamp()).isEqualTo(115 * MINUTE_IN_MS);
+ assertBatteryConsumer(stats, 360.0, 60 * MINUTE_IN_MS);
+ assertBatteryConsumer(stats, APP_UID, 360.0, 60 * MINUTE_IN_MS);
+
+ stats.close();
+ }
+
+ private void accumulateBatteryUsageStats(MockBatteryStatsImpl batteryStatsImpl,
+ int accumulatedBatteryUsageStatsSpanSize, int expectedNumberOfUpdates)
+ throws Throwable {
+ Handler handler = mStatsRule.getHandler();
+ MockBatteryStatsImpl batteryStats = spy(batteryStatsImpl);
// Note - these two are in microseconds
when(batteryStats.computeBatteryTimeRemaining(anyLong())).thenReturn(111_000L);
when(batteryStats.computeChargeTimeRemaining(anyLong())).thenReturn(777_000L);
@@ -610,82 +641,76 @@ public class BatteryUsageStatsProviderTest {
batteryStats.resetAllStatsAndHistoryLocked(BatteryStatsImpl.RESET_REASON_ADB_COMMAND);
}
- PowerStatsStore powerStatsStore = spy(new PowerStatsStore(
- new File(mStatsRule.getHistoryDir(), getClass().getSimpleName()),
- mStatsRule.getHandler()));
- powerStatsStore.reset();
+ mPowerStatsStore.reset();
int[] count = new int[1];
doAnswer(inv -> {
count[0]++;
- return null;
- }).when(powerStatsStore).storePowerStatsSpan(any(PowerStatsSpan.class));
+ return inv.callRealMethod();
+ }).when(mPowerStatsStore).storePowerStatsSpan(any(PowerStatsSpan.class));
- MultiStatePowerAttributor powerAttributor = new MultiStatePowerAttributor(mContext,
- powerStatsStore, mStatsRule.getPowerProfile(), mStatsRule.getCpuScalingPolicies(),
- () -> 3500);
- for (int powerComponentId = 0; powerComponentId < BatteryConsumer.POWER_COMPONENT_COUNT;
- powerComponentId++) {
- powerAttributor.setPowerComponentSupported(powerComponentId, true);
- }
- powerAttributor.setPowerComponentSupported(BatteryConsumer.POWER_COMPONENT_ANY, true);
-
- BatteryUsageStatsProvider provider = new BatteryUsageStatsProvider(mContext,
- powerAttributor, mStatsRule.getPowerProfile(),
- mStatsRule.getCpuScalingPolicies(), powerStatsStore,
- accumulatedBatteryUsageStatsSpanSize, mMockClock, mMonotonicClock);
+ BatteryUsageStatsProvider batteryUsageStatsProvider = createBatteryUsageStatsProvider(
+ accumulatedBatteryUsageStatsSpanSize);
- provider.accumulateBatteryUsageStatsAsync(batteryStats, mStatsRule.getHandler());
+ batteryUsageStatsProvider.accumulateBatteryUsageStatsAsync(batteryStats, handler);
+ setTime(10 * MINUTE_IN_MS);
synchronized (batteryStats) {
batteryStats.noteFlashlightOnLocked(APP_UID,
10 * MINUTE_IN_MS, 10 * MINUTE_IN_MS);
}
- provider.accumulateBatteryUsageStatsAsync(batteryStats, mStatsRule.getHandler());
+ batteryUsageStatsProvider.accumulateBatteryUsageStatsAsync(batteryStats, handler);
+ setTime(20 * MINUTE_IN_MS);
synchronized (batteryStats) {
batteryStats.noteFlashlightOffLocked(APP_UID,
20 * MINUTE_IN_MS, 20 * MINUTE_IN_MS);
}
- provider.accumulateBatteryUsageStatsAsync(batteryStats, mStatsRule.getHandler());
+ batteryUsageStatsProvider.accumulateBatteryUsageStatsAsync(batteryStats, handler);
+ setTime(30 * MINUTE_IN_MS);
synchronized (batteryStats) {
batteryStats.noteFlashlightOnLocked(APP_UID,
30 * MINUTE_IN_MS, 30 * MINUTE_IN_MS);
}
- provider.accumulateBatteryUsageStatsAsync(batteryStats, mStatsRule.getHandler());
+ batteryUsageStatsProvider.accumulateBatteryUsageStatsAsync(batteryStats, handler);
+ // Make sure the accumulated stats are computed and saved before generating more history
+ mStatsRule.waitForBackgroundThread();
+
+ setTime(50 * MINUTE_IN_MS);
synchronized (batteryStats) {
batteryStats.noteFlashlightOffLocked(APP_UID,
50 * MINUTE_IN_MS, 50 * MINUTE_IN_MS);
}
setTime(55 * MINUTE_IN_MS);
- provider.accumulateBatteryUsageStatsAsync(batteryStats, mStatsRule.getHandler());
+ batteryUsageStatsProvider.accumulateBatteryUsageStatsAsync(batteryStats, handler);
// This section has not been saved yet, but should be added to the accumulated totals
+ setTime(80 * MINUTE_IN_MS);
synchronized (batteryStats) {
batteryStats.noteFlashlightOnLocked(APP_UID,
80 * MINUTE_IN_MS, 80 * MINUTE_IN_MS);
}
- provider.accumulateBatteryUsageStatsAsync(batteryStats, mStatsRule.getHandler());
+ batteryUsageStatsProvider.accumulateBatteryUsageStatsAsync(batteryStats, handler);
+ setTime(110 * MINUTE_IN_MS);
synchronized (batteryStats) {
batteryStats.noteFlashlightOffLocked(APP_UID,
110 * MINUTE_IN_MS, 110 * MINUTE_IN_MS);
}
setTime(115 * MINUTE_IN_MS);
- // Pick up the remainder of battery history that has not yet been accumulated
- provider.accumulateBatteryUsageStats(batteryStats);
+ batteryUsageStatsProvider.accumulateBatteryUsageStatsAsync(batteryStats, handler);
mStatsRule.waitForBackgroundThread();
- BatteryUsageStats stats = provider.getBatteryUsageStats(batteryStats,
+ BatteryUsageStats stats = batteryUsageStatsProvider.getBatteryUsageStats(batteryStats,
new BatteryUsageStatsQuery.Builder().accumulated().build());
assertThat(stats.getStatsStartTimestamp()).isEqualTo(5 * MINUTE_IN_MS);
@@ -696,29 +721,55 @@ public class BatteryUsageStatsProviderTest {
assertThat(stats.getBatteryCapacity()).isEqualTo(4000); // from PowerProfile
// Total: 10 + 20 + 30 = 60
- assertThat(stats.getAggregateBatteryConsumer(
- BatteryUsageStats.AGGREGATE_BATTERY_CONSUMER_SCOPE_DEVICE)
+ assertBatteryConsumer(stats, 360.0, 60 * MINUTE_IN_MS);
+ assertBatteryConsumer(stats, APP_UID, 360.0, 60 * MINUTE_IN_MS);
+ stats.close();
+
+ mStatsRule.waitForBackgroundThread();
+
+ assertThat(count[0]).isEqualTo(expectedNumberOfUpdates);
+ }
+
+ private BatteryUsageStatsProvider createBatteryUsageStatsProvider(
+ int accumulatedBatteryUsageStatsSpanSize) {
+ MultiStatePowerAttributor powerAttributor = new MultiStatePowerAttributor(mContext,
+ mPowerStatsStore, mStatsRule.getPowerProfile(), mStatsRule.getCpuScalingPolicies(),
+ () -> 3500);
+ for (int powerComponentId = 0; powerComponentId < BatteryConsumer.POWER_COMPONENT_COUNT;
+ powerComponentId++) {
+ powerAttributor.setPowerComponentSupported(powerComponentId, true);
+ }
+ powerAttributor.setPowerComponentSupported(BatteryConsumer.POWER_COMPONENT_ANY, true);
+
+ return new BatteryUsageStatsProvider(mContext, powerAttributor,
+ mStatsRule.getPowerProfile(), mStatsRule.getCpuScalingPolicies(), mPowerStatsStore,
+ accumulatedBatteryUsageStatsSpanSize, mMockClock, mMonotonicClock);
+ }
+
+ private static void assertBatteryConsumer(BatteryUsageStats stats, double expectedPowerMah,
+ long expectedDurationMs) {
+ AggregateBatteryConsumer aggregatedConsumer = stats.getAggregateBatteryConsumer(
+ BatteryUsageStats.AGGREGATE_BATTERY_CONSUMER_SCOPE_DEVICE);
+ assertThat(aggregatedConsumer
.getConsumedPower(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT))
.isWithin(0.0001)
- .of(360.0); // 360 mA * 1.0 hour
- assertThat(stats.getAggregateBatteryConsumer(
- BatteryUsageStats.AGGREGATE_BATTERY_CONSUMER_SCOPE_DEVICE)
+ .of(expectedPowerMah);
+ assertThat(aggregatedConsumer
.getUsageDurationMillis(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT))
- .isEqualTo(60 * MINUTE_IN_MS);
+ .isEqualTo(expectedDurationMs);
+ }
+ private static void assertBatteryConsumer(BatteryUsageStats stats, int uid,
+ double expectedPowerMah, long expectedDurationMs) {
final UidBatteryConsumer uidBatteryConsumer = stats.getUidBatteryConsumers().stream()
- .filter(uid -> uid.getUid() == APP_UID).findFirst().get();
+ .filter(u -> u.getUid() == uid).findFirst().get();
assertThat(uidBatteryConsumer
.getConsumedPower(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT))
.isWithin(0.1)
- .of(360.0);
+ .of(expectedPowerMah);
assertThat(uidBatteryConsumer
.getUsageDurationMillis(BatteryConsumer.POWER_COMPONENT_FLASHLIGHT))
- .isEqualTo(60 * MINUTE_IN_MS);
-
- assertThat(count[0]).isEqualTo(expectedNumberOfUpdates);
-
- stats.close();
+ .isEqualTo(expectedDurationMs);
}
private void setTime(long timeMs) {
diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsRule.java b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsRule.java
index a3c7ece386c7..9e7e0b646047 100644
--- a/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsRule.java
+++ b/services/tests/powerstatstests/src/com/android/server/power/stats/BatteryUsageStatsRule.java
@@ -41,6 +41,7 @@ import android.util.SparseArray;
import android.util.Xml;
import com.android.internal.os.CpuScalingPolicies;
+import com.android.internal.os.MonotonicClock;
import com.android.internal.os.PowerProfile;
import com.android.internal.power.EnergyConsumerStats;
@@ -65,6 +66,7 @@ public class BatteryUsageStatsRule implements TestRule {
private final PowerProfile mPowerProfile;
private final MockClock mMockClock = new MockClock();
+ private final MonotonicClock mMonotonicClock = new MonotonicClock(666777, mMockClock);
private String mTestName;
private boolean mCreateTempDirectory;
private File mHistoryDir;
@@ -118,7 +120,7 @@ public class BatteryUsageStatsRule implements TestRule {
clearDirectory();
}
mBatteryStats = new MockBatteryStatsImpl(mBatteryStatsConfigBuilder.build(),
- mMockClock, mHistoryDir, mHandler, new PowerStatsUidResolver());
+ mMockClock, mMonotonicClock, mHistoryDir, mHandler, new PowerStatsUidResolver());
mBatteryStats.setPowerProfile(mPowerProfile);
mBatteryStats.setCpuScalingPolicies(new CpuScalingPolicies(mCpusByPolicy, mFreqsByPolicy));
synchronized (mBatteryStats) {
@@ -144,6 +146,10 @@ public class BatteryUsageStatsRule implements TestRule {
return mMockClock;
}
+ public MonotonicClock getMonotonicClock() {
+ return mMonotonicClock;
+ }
+
public Handler getHandler() {
return mHandler;
}
diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/MockBatteryStatsImpl.java b/services/tests/powerstatstests/src/com/android/server/power/stats/MockBatteryStatsImpl.java
index b374a3202fa2..9a38209a7d17 100644
--- a/services/tests/powerstatstests/src/com/android/server/power/stats/MockBatteryStatsImpl.java
+++ b/services/tests/powerstatstests/src/com/android/server/power/stats/MockBatteryStatsImpl.java
@@ -77,9 +77,15 @@ public class MockBatteryStatsImpl extends BatteryStatsImpl {
new PowerStatsUidResolver());
}
- MockBatteryStatsImpl(BatteryStatsConfig config, Clock clock, File historyDirectory,
- Handler handler, PowerStatsUidResolver powerStatsUidResolver) {
- super(config, clock, new MonotonicClock(0, clock), historyDirectory, handler,
+ MockBatteryStatsImpl(BatteryStatsConfig config, Clock clock,
+ File historyDirectory, Handler handler, PowerStatsUidResolver powerStatsUidResolver) {
+ this(config, clock, new MonotonicClock(0, clock), historyDirectory, handler,
+ powerStatsUidResolver);
+ }
+
+ MockBatteryStatsImpl(BatteryStatsConfig config, Clock clock, MonotonicClock monotonicClock,
+ File historyDirectory, Handler handler, PowerStatsUidResolver powerStatsUidResolver) {
+ super(config, clock, monotonicClock, historyDirectory, handler,
mock(PlatformIdleStateCallback.class), mock(EnergyStatsRetriever.class),
mock(UserInfoProvider.class), mockPowerProfile(),
new CpuScalingPolicies(new SparseArray<>(), new SparseArray<>()),
diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsAggregatorTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsAggregatorTest.java
index f312bedca82c..3bdbcb50e601 100644
--- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsAggregatorTest.java
+++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsAggregatorTest.java
@@ -263,6 +263,34 @@ public class PowerStatsAggregatorTest {
});
}
+ @Test
+ public void emptyHistory() {
+ PowerStats.Descriptor descriptor = new PowerStats.Descriptor(TEST_POWER_COMPONENT,
+ "majorDrain", 1, null, 0, 1, new PersistableBundle());
+ PowerStats powerStats = new PowerStats(descriptor);
+
+ mHistory.forceRecordAllHistory();
+
+ advance(1000);
+
+ long firstItemTimestamp = mMonotonicClock.monotonicTime();
+ powerStats.stats = new long[]{24};
+ mHistory.recordPowerStats(mClock.realtime, mClock.uptime, powerStats);
+
+ advance(1000);
+
+ long secondItemTimestamp = mMonotonicClock.monotonicTime();
+ powerStats.stats = new long[]{42};
+ mHistory.recordPowerStats(mClock.realtime, mClock.uptime, powerStats);
+
+ mAggregator.aggregatePowerStats(mHistory, firstItemTimestamp + 1, secondItemTimestamp,
+ stats -> {
+ mAggregatedStatsCount++;
+ });
+
+ assertThat(mAggregatedStatsCount).isEqualTo(0);
+ }
+
private void advance(long durationMs) {
mClock.realtime += durationMs;
mClock.uptime += durationMs;
diff --git a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsExporterTest.java b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsExporterTest.java
index 38fe6134d992..d243f92a139f 100644
--- a/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsExporterTest.java
+++ b/services/tests/powerstatstests/src/com/android/server/power/stats/processor/PowerStatsExporterTest.java
@@ -408,7 +408,7 @@ public class PowerStatsExporterTest {
BatteryUsageStats.Builder builder = new BatteryUsageStats.Builder(
new String[]{"cu570m"},
/* includeProcessStateData */ true, true, true, /* powerThreshold */ 0);
- exportAggregatedPowerStats(builder, 3700, 6700);
+ exportAggregatedPowerStats(builder, 3700, 7500);
BatteryUsageStats actual = builder.build();
String message = "Actual BatteryUsageStats: " + actual;
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
index d4a921c5f00a..1b0d9dc3b170 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityRecordTests.java
@@ -554,6 +554,7 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
public void testSetRequestedOrientationUpdatesConfiguration() throws Exception {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final ActivityRecord activity = new ActivityBuilder(mAtm)
.setCreateTask(true)
.setConfigChanges(ORIENTATION_CONFIG_CHANGES)
@@ -641,6 +642,7 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
public void ignoreRequestedOrientationForResizableInSplitWindows() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final ActivityRecord activity = createActivityWith2LevelTask();
final Task task = activity.getTask();
final Task rootTask = activity.getRootTask();
@@ -685,6 +687,7 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
public void respectRequestedOrientationForNonResizableInSplitWindows() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final TaskDisplayArea tda = mDisplayContent.getDefaultTaskDisplayArea();
spyOn(tda);
doReturn(true).when(tda).supportsNonResizableMultiWindow();
@@ -1906,6 +1909,7 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
public void testActivityOnCancelFixedRotationTransform() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final ActivityRecord activity = createActivityWithTask();
final DisplayRotation displayRotation = activity.mDisplayContent.getDisplayRotation();
final RemoteDisplayChangeController remoteDisplayChangeController = activity
@@ -2054,6 +2058,7 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
public void testFixedRotationSnapshotStartingWindow() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final ActivityRecord activity = createActivityWithTask();
// TaskSnapshotSurface requires a fullscreen opaque window.
final WindowManager.LayoutParams params = new WindowManager.LayoutParams(
@@ -2278,6 +2283,7 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
public void testSupportsFreeform() {
final ActivityRecord activity = new ActivityBuilder(mAtm)
+ .setComponent(getUniqueComponentName(mContext.getPackageName()))
.setCreateTask(true)
.setResizeMode(ActivityInfo.RESIZE_MODE_UNRESIZEABLE)
.setScreenOrientation(SCREEN_ORIENTATION_LANDSCAPE)
@@ -2410,6 +2416,7 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
public void testOrientationForScreenOrientationBehind() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final Task task = createTask(mDisplayContent);
// Activity below
new ActivityBuilder(mAtm)
@@ -2507,6 +2514,7 @@ public class ActivityRecordTests extends WindowTestsBase {
@SetupWindows(addWindows = W_ACTIVITY)
@Test
public void testLandscapeSeascapeRotationByApp() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final Task task = new TaskBuilder(mSupervisor)
.setDisplay(mDisplayContent).setCreateActivity(true).build();
final ActivityRecord activity = task.getTopNonFinishingActivity();
@@ -2572,6 +2580,7 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
@Presubmit
public void testGetOrientation() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
// ActivityBuilder will resume top activities and cause the activity been added into
// opening apps list. Since this test is focus on the effect of visible on getting
// orientation, we skip app transition to avoid interference.
@@ -2663,8 +2672,8 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
public void testSetOrientation_restrictedByTargetSdk() {
mSetFlagsRule.enableFlags(Flags.FLAG_UNIVERSAL_RESIZABLE_BY_DEFAULT);
- mDisplayContent.setIgnoreOrientationRequest(true);
makeDisplayLargeScreen(mDisplayContent);
+ assertTrue(mDisplayContent.getIgnoreOrientationRequest());
assertSetOrientation(Build.VERSION_CODES.CUR_DEVELOPMENT, CATEGORY_SOCIAL, false);
assertSetOrientation(Build.VERSION_CODES.CUR_DEVELOPMENT, CATEGORY_GAME, true);
@@ -2702,6 +2711,7 @@ public class ActivityRecordTests extends WindowTestsBase {
@Test
public void testRespectTopFullscreenOrientation() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build();
final Configuration displayConfig = activity.mDisplayContent.getConfiguration();
final Configuration activityConfig = activity.getConfiguration();
diff --git a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
index e0b29c937381..1cb1e3cae413 100644
--- a/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/ActivityTaskManagerServiceTests.java
@@ -511,6 +511,7 @@ public class ActivityTaskManagerServiceTests extends WindowTestsBase {
@Test
public void testSupportsMultiWindow_nonResizable() {
final ActivityRecord activity = new ActivityBuilder(mAtm)
+ .setComponent(getUniqueComponentName(mContext.getPackageName()))
.setCreateTask(true)
.setResizeMode(RESIZE_MODE_UNRESIZEABLE)
.build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/BackNavigationControllerTests.java b/services/tests/wmtests/src/com/android/server/wm/BackNavigationControllerTests.java
index 40da9ea2d718..579ed6659976 100644
--- a/services/tests/wmtests/src/com/android/server/wm/BackNavigationControllerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/BackNavigationControllerTests.java
@@ -365,8 +365,8 @@ public class BackNavigationControllerTests extends WindowTestsBase {
assertTrue(outPrevActivities.isEmpty());
assertTrue(predictable);
// reset
- tf1.setAdjacentTaskFragment(null);
- tf2.setAdjacentTaskFragment(null);
+ tf1.clearAdjacentTaskFragments();
+ tf2.clearAdjacentTaskFragments();
tf1.setCompanionTaskFragment(null);
tf2.setCompanionTaskFragment(null);
@@ -398,8 +398,8 @@ public class BackNavigationControllerTests extends WindowTestsBase {
assertTrue(predictable);
// reset
outPrevActivities.clear();
- tf2.setAdjacentTaskFragment(null);
- tf3.setAdjacentTaskFragment(null);
+ tf2.clearAdjacentTaskFragments();
+ tf3.clearAdjacentTaskFragments();
final TaskFragment tf4 = createTaskFragmentWithActivity(task);
// Stacked + next companion to top => predict for previous activity below companion.
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaGroupTest.java b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaGroupTest.java
index 87dbca51e24e..060b379c1281 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaGroupTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaGroupTest.java
@@ -84,6 +84,7 @@ public class DisplayAreaGroupTest extends WindowTestsBase {
@Test
public void testGetRequestedOrientationForDisplay() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final Task task = new TaskBuilder(mSupervisor)
.setTaskDisplayArea(mTaskDisplayArea).setCreateActivity(true).build();
final ActivityRecord activity = task.getTopNonFinishingActivity();
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java
index 7b2cd63b4afb..0a7df5a305bc 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayAreaTest.java
@@ -491,6 +491,7 @@ public class DisplayAreaTest extends WindowTestsBase {
@Test
public void testSetIgnoreOrientationRequest_callSuperOnDescendantOrientationChangedNoSensor() {
final TaskDisplayArea tda = mDisplayContent.getDefaultTaskDisplayArea();
+ mDisplayContent.setIgnoreOrientationRequest(false);
final Task stack =
new TaskBuilder(mSupervisor).setOnTop(!ON_TOP).setCreateActivity(true).build();
final ActivityRecord activity = stack.getTopNonFinishingActivity();
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
index 9cbea2e2f0ad..db71f2bf039d 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayContentTests.java
@@ -898,6 +898,7 @@ public class DisplayContentTests extends WindowTestsBase {
public void testOrientationDefinedByKeyguard() {
final DisplayContent dc = mDisplayContent;
dc.getDisplayPolicy().setAwake(true);
+ dc.setIgnoreOrientationRequest(false);
// Create a window that requests landscape orientation. It will define device orientation
// by default.
@@ -925,6 +926,7 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testOrientationForAspectRatio() {
final DisplayContent dc = createNewDisplay();
+ dc.setIgnoreOrientationRequest(false);
// When display content is created its configuration is not yet initialized, which could
// cause unnecessary configuration propagation, so initialize it here.
@@ -1034,6 +1036,7 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testAllowsTopmostFullscreenOrientation() {
final DisplayContent dc = createNewDisplay();
+ dc.setIgnoreOrientationRequest(false);
assertEquals(SCREEN_ORIENTATION_UNSPECIFIED, dc.getOrientation());
dc.getDisplayRotation().setFixedToUserRotation(
IWindowManager.FIXED_TO_USER_ROTATION_DISABLED);
@@ -1112,6 +1115,7 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testOnDescendantOrientationRequestChanged() {
final DisplayContent dc = createNewDisplay();
+ dc.setIgnoreOrientationRequest(false);
dc.getDisplayRotation().setFixedToUserRotation(
IWindowManager.FIXED_TO_USER_ROTATION_DISABLED);
dc.getDefaultTaskDisplayArea().setWindowingMode(WINDOWING_MODE_FULLSCREEN);
@@ -1130,6 +1134,7 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testOnDescendantOrientationRequestChanged_FrozenToUserRotation() {
final DisplayContent dc = createNewDisplay();
+ dc.setIgnoreOrientationRequest(false);
dc.getDisplayRotation().setFixedToUserRotation(
IWindowManager.FIXED_TO_USER_ROTATION_ENABLED);
dc.getDisplayRotation().setUserRotation(
@@ -1152,6 +1157,7 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testOrientationBehind() {
assertNull(mDisplayContent.getLastOrientationSource());
+ mDisplayContent.setIgnoreOrientationRequest(false);
final ActivityRecord prev = new ActivityBuilder(mAtm).setCreateTask(true)
.setScreenOrientation(getRotatedOrientation(mDisplayContent)).build();
prev.setVisibleRequested(false);
@@ -1172,6 +1178,7 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testFixedToUserRotationChanged() {
final DisplayContent dc = createNewDisplay();
+ dc.setIgnoreOrientationRequest(false);
dc.getDisplayRotation().setFixedToUserRotation(
IWindowManager.FIXED_TO_USER_ROTATION_ENABLED);
dc.getDisplayRotation().setUserRotation(
@@ -1589,6 +1596,7 @@ public class DisplayContentTests extends WindowTestsBase {
W_INPUT_METHOD, W_NOTIFICATION_SHADE })
@Test
public void testApplyTopFixedRotationTransform() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final DisplayPolicy displayPolicy = mDisplayContent.getDisplayPolicy();
spyOn(displayPolicy);
// Only non-movable (gesture) navigation bar will be animated by fixed rotation animation.
@@ -1742,6 +1750,7 @@ public class DisplayContentTests extends WindowTestsBase {
@Test
public void testFixedRotationWithPip() {
final DisplayContent displayContent = mDefaultDisplay;
+ displayContent.setIgnoreOrientationRequest(false);
unblockDisplayRotation(displayContent);
// Unblock the condition in PinnedTaskController#continueOrientationChangeIfNeeded.
doNothing().when(displayContent).prepareAppTransition(anyInt());
diff --git a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java
index 63973345b5fb..6527af1ec704 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DisplayRotationImmersiveAppCompatPolicyTests.java
@@ -77,7 +77,7 @@ public class DisplayRotationImmersiveAppCompatPolicyTests extends WindowTestsBas
when(mMockActivityRecord.findMainWindow()).thenReturn(mMockWindowState);
doReturn(mMockActivityRecord).when(mDisplayContent).topRunningActivity();
- when(mDisplayContent.getIgnoreOrientationRequest()).thenReturn(true);
+ mDisplayContent.setIgnoreOrientationRequest(true);
mMockAppCompatConfiguration = mock(AppCompatConfiguration.class);
when(mMockAppCompatConfiguration.isDisplayRotationImmersiveAppCompatPolicyEnabled())
@@ -195,7 +195,7 @@ public class DisplayRotationImmersiveAppCompatPolicyTests extends WindowTestsBas
@Test
public void testIsRotationLockEnforced_ignoreOrientationRequestDisabled_lockNotEnforced() {
- when(mDisplayContent.getIgnoreOrientationRequest()).thenReturn(false);
+ mDisplayContent.setIgnoreOrientationRequest(false);
assertIsRotationLockEnforcedReturnsFalseForAllRotations();
}
diff --git a/services/tests/wmtests/src/com/android/server/wm/DualDisplayAreaGroupPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/DualDisplayAreaGroupPolicyTest.java
index 708d6860abc2..bd15bc42e811 100644
--- a/services/tests/wmtests/src/com/android/server/wm/DualDisplayAreaGroupPolicyTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/DualDisplayAreaGroupPolicyTest.java
@@ -106,6 +106,8 @@ public class DualDisplayAreaGroupPolicyTest extends WindowTestsBase {
// Display: 1920x1200 (landscape). First and second display are both 860x1200 (portrait).
mDisplay = new DualDisplayContent.Builder(mAtm, 1920, 1200).build();
+ // The test verifies that the display area can affect display's getLastOrientation().
+ mDisplay.setIgnoreOrientationRequest(false);
mFirstRoot = mDisplay.mFirstRoot;
mSecondRoot = mDisplay.mSecondRoot;
mFirstTda = mDisplay.getTaskDisplayArea(FEATURE_FIRST_TASK_CONTAINER);
diff --git a/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java b/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java
index 7cb62c5a6769..d96512588c7c 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RootTaskTests.java
@@ -132,6 +132,7 @@ public class RootTaskTests extends WindowTestsBase {
@Test
public void testClosingAppDifferentTaskOrientation() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final ActivityRecord activity1 = createActivityRecord(mDisplayContent);
activity1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
@@ -146,6 +147,7 @@ public class RootTaskTests extends WindowTestsBase {
@Test
public void testMoveTaskToBackDifferentTaskOrientation() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final ActivityRecord activity1 = createActivityRecord(mDisplayContent);
activity1.setOrientation(SCREEN_ORIENTATION_LANDSCAPE);
diff --git a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java
index 7e8bd38fb6a9..699ed0263756 100644
--- a/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/RootWindowContainerTests.java
@@ -41,6 +41,7 @@ import static com.android.server.wm.ActivityTaskSupervisor.ON_TOP;
import static com.android.server.wm.RootWindowContainer.MATCH_ATTACHED_TASK_OR_RECENT_TASKS_AND_RESTORE;
import static com.android.server.wm.WindowContainer.POSITION_BOTTOM;
+
import static com.google.common.truth.Truth.assertThat;
import static org.junit.Assert.assertEquals;
@@ -63,6 +64,7 @@ import static org.mockito.Mockito.reset;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.times;
import static org.mockito.Mockito.verify;
+import static org.testng.internal.junit.ArrayAsserts.assertArrayEquals;
import android.app.ActivityOptions;
import android.app.WindowConfiguration;
@@ -77,12 +79,14 @@ import android.graphics.Rect;
import android.os.PowerManager;
import android.os.RemoteException;
import android.os.UserHandle;
+import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;
import android.util.Pair;
import androidx.test.filters.MediumTest;
import com.android.internal.app.ResolverActivity;
+import com.android.window.flags.Flags;
import org.junit.Before;
import org.junit.Test;
@@ -693,6 +697,7 @@ public class RootWindowContainerTests extends WindowTestsBase {
@Test
public void testAwakeFromSleepingWithAppConfiguration() {
final DisplayContent display = mRootWindowContainer.getDefaultDisplay();
+ display.setIgnoreOrientationRequest(false);
final ActivityRecord activity = new ActivityBuilder(mAtm).setCreateTask(true).build();
activity.moveFocusableActivityToTop("test");
assertTrue(activity.getRootTask().isFocusedRootTaskOnDisplay());
@@ -1331,6 +1336,38 @@ public class RootWindowContainerTests extends WindowTestsBase {
assertEquals(taskDisplayArea.getTopRootTask(), taskDisplayArea.getRootHomeTask());
}
+ @EnableFlags(Flags.FLAG_ENABLE_TOP_VISIBLE_ROOT_TASK_PER_USER_TRACKING)
+ @Test
+ public void testSwitchUser_withVisibleRootTasks_storesAllVisibleRootTasksForCurrentUser() {
+ // Set up root tasks
+ final Task rootTask1 = mRootWindowContainer.getDefaultTaskDisplayArea().createRootTask(
+ WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, true /* onTop */);
+ final Task rootTask2 = mRootWindowContainer.getDefaultTaskDisplayArea().createRootTask(
+ WINDOWING_MODE_FREEFORM, ACTIVITY_TYPE_STANDARD, true /* onTop */);
+ final Task rootTask3 = mRootWindowContainer.getDefaultTaskDisplayArea().createRootTask(
+ WINDOWING_MODE_FREEFORM, ACTIVITY_TYPE_STANDARD, true /* onTop */);
+ doReturn(rootTask3).when(mRootWindowContainer).getTopDisplayFocusedRootTask();
+
+ // Set up user ids and visibility
+ rootTask1.mUserId = mRootWindowContainer.mCurrentUser;
+ rootTask2.mUserId = mRootWindowContainer.mCurrentUser;
+ rootTask3.mUserId = mRootWindowContainer.mCurrentUser;
+ rootTask1.mVisibleRequested = false;
+ rootTask2.mVisibleRequested = true;
+ rootTask3.mVisibleRequested = true;
+
+ // Switch to a different user
+ int currentUser = mRootWindowContainer.mCurrentUser;
+ int otherUser = currentUser + 1;
+ mRootWindowContainer.switchUser(otherUser, null);
+
+ // Verify that the previous user persists it's previous visible root tasks
+ assertArrayEquals(
+ new int[]{rootTask2.mTaskId, rootTask3.mTaskId},
+ mRootWindowContainer.mUserVisibleRootTasks.get(currentUser).toArray()
+ );
+ }
+
@Test
public void testLockAllProfileTasks() {
final int profileUid = UserHandle.PER_USER_RANGE + UserHandle.MIN_SECONDARY_USER_ID;
diff --git a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
index bf96f0eb03b8..201ff51f1495 100644
--- a/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/SizeCompatTests.java
@@ -107,6 +107,8 @@ import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;
import android.provider.DeviceConfig;
import android.provider.DeviceConfig.Properties;
+import android.view.DisplayCutout;
+import android.view.DisplayInfo;
import android.view.InsetsFrameProvider;
import android.view.InsetsSource;
import android.view.InsetsState;
@@ -210,6 +212,37 @@ public class SizeCompatTests extends WindowTestsBase {
return setUpApp(builder.build(), appBuilder);
}
+ private void setUpLargeScreenDisplayWithApp(int dw, int dh) {
+ final DisplayContent display = mDisplayContent;
+ final DisplayInfo displayInfo = display.getDisplayInfo();
+ displayInfo.logicalWidth = dw;
+ displayInfo.logicalHeight = dh;
+ // Prevent legacy sdk from being affected by INSETS_DECOUPLED_CONFIGURATION_ENFORCED.
+ display.mInitialDisplayCutout = displayInfo.displayCutout = DisplayCutout.NO_CUTOUT;
+ // Smallest screen width=747dp according to 1400/(300/160).
+ display.mBaseDisplayDensity = displayInfo.logicalDensityDpi =
+ TestDisplayContent.DEFAULT_LOGICAL_DISPLAY_DENSITY;
+ doNothing().when(display).updateDisplayInfo(any());
+ resizeDisplay(display, displayInfo.logicalWidth, displayInfo.logicalHeight);
+ assertTrue(display.isLargeScreen());
+ if (com.android.window.flags.Flags.universalResizableByDefault()) {
+ assertTrue("Large screen must ignore orientation request",
+ display.getIgnoreOrientationRequest());
+ } else {
+ display.setIgnoreOrientationRequest(true);
+ }
+ setUpApp(display, null /* appBuilder */);
+ spyOn(display.getDisplayRotation());
+ }
+
+ private void setUpLandscapeLargeScreenDisplayWithApp() {
+ setUpLargeScreenDisplayWithApp(/* dw */ 2800, /* dh */ 1400);
+ }
+
+ private void setUpPortraitLargeScreenDisplayWithApp() {
+ setUpLargeScreenDisplayWithApp(/* dw */ 1400, /* dh */ 2800);
+ }
+
@Test
public void testHorizontalReachabilityEnabledForTranslucentActivities() {
testReachabilityEnabledForTranslucentActivity(/* dw */ 2500, /* dh */1000,
@@ -658,9 +691,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testIsLetterboxed_activityFromBubble_returnsFalse() {
- setUpDisplaySizeWithApp(1000, 2500);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
- spyOn(mActivity);
+ setUpPortraitLargeScreenDisplayWithApp();
doReturn(true).when(mActivity).getLaunchedFromBubble();
prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);
@@ -1694,10 +1725,9 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testGetLetterboxInnerBounds_noScalingApplied() {
// Set up a display in portrait and ignoring orientation request.
- final int dw = 1400;
- final int dh = 2800;
- setUpDisplaySizeWithApp(dw, dh);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpPortraitLargeScreenDisplayWithApp();
+ final int dw = mDisplayContent.mBaseDisplayWidth;
+ final int dh = mDisplayContent.mBaseDisplayHeight;
// Rotate display to landscape.
rotateDisplay(mActivity.mDisplayContent, ROTATION_90);
@@ -1823,8 +1853,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayIgnoreOrientationRequest_fixedOrientationAppLaunchedLetterbox() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
// Portrait fixed app without max aspect.
prepareUnresizable(mActivity, /* maxAspect= */ 0, SCREEN_ORIENTATION_PORTRAIT);
@@ -1852,8 +1881,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayIgnoreOrientationRequest_fixedOrientationAppRespectMinAspectRatio() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
// Portrait fixed app with min aspect ratio higher that aspect ratio override for fixed
// orientation letterbox.
@@ -1884,8 +1912,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayIgnoreOrientationRequest_fixedOrientationAppRespectMaxAspectRatio() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
// Portrait fixed app with max aspect ratio lower that aspect ratio override for fixed
// orientation letterbox.
@@ -1915,8 +1942,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayIgnoreOrientationRequest_fixedOrientationAppWithAspectRatioOverride() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
final float fixedOrientationLetterboxAspectRatio = 1.1f;
mActivity.mWmService.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio(
@@ -2011,8 +2037,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayIgnoreOrientationRequest_unresizableWithCorrespondingMinAspectRatio() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
final float fixedOrientationLetterboxAspectRatio = 1.1f;
mActivity.mWmService.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio(
@@ -2045,13 +2070,10 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testComputeConfigResourceOverrides_unresizableApp() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
prepareUnresizable(mActivity, SCREEN_ORIENTATION_PORTRAIT);
- final Rect activityBounds = new Rect(mActivity.getBounds());
-
int originalScreenWidthDp = mActivity.getConfiguration().screenWidthDp;
int originalScreenHeighthDp = mActivity.getConfiguration().screenHeightDp;
@@ -2068,7 +2090,7 @@ public class SizeCompatTests extends WindowTestsBase {
// After we rotate, the activity should go in the size-compat mode and report the same
// configuration values.
- assertDownScaled();
+ assertThat(mActivity.inSizeCompatMode()).isTrue();
assertEquals(originalScreenWidthDp, mActivity.getConfiguration().smallestScreenWidthDp);
assertEquals(originalScreenWidthDp, mActivity.getConfiguration().screenWidthDp);
assertEquals(originalScreenHeighthDp, mActivity.getConfiguration().screenHeightDp);
@@ -2087,14 +2109,11 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testComputeConfigResourceOverrides_resizableFixedOrientationActivity() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
// Portrait fixed app without max aspect.
prepareLimitedBounds(mActivity, SCREEN_ORIENTATION_PORTRAIT, false /* isUnresizable */);
- final Rect activityBounds = new Rect(mActivity.getBounds());
-
int originalScreenWidthDp = mActivity.getConfiguration().screenWidthDp;
int originalScreenHeighthDp = mActivity.getConfiguration().screenHeightDp;
@@ -2206,10 +2225,10 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testSystemFullscreenOverrideForLandscapeDisplay() {
- final int displayWidth = 1600;
- final int displayHeight = 1400;
- setUpDisplaySizeWithApp(displayWidth, displayHeight);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
+ final int displayWidth = mDisplayContent.mBaseDisplayWidth;
+ final int displayHeight = mDisplayContent.mBaseDisplayHeight;
+
spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides());
doReturn(true).when(
mActivity.mAppCompatController.getAppCompatAspectRatioOverrides())
@@ -2226,10 +2245,10 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testSystemFullscreenOverrideForPortraitDisplay() {
- final int displayWidth = 1400;
- final int displayHeight = 1600;
- setUpDisplaySizeWithApp(displayWidth, displayHeight);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpPortraitLargeScreenDisplayWithApp();
+ final int displayWidth = mDisplayContent.mBaseDisplayWidth;
+ final int displayHeight = mDisplayContent.mBaseDisplayHeight;
+
spyOn(mActivity.mAppCompatController.getAppCompatAspectRatioOverrides());
doReturn(true).when(
mActivity.mAppCompatController.getAppCompatAspectRatioOverrides())
@@ -2619,7 +2638,7 @@ public class SizeCompatTests extends WindowTestsBase {
@EnableCompatChanges({ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION})
public void testOverrideRespectRequestedOrientationIsEnabled_orientationIsRespected() {
// Set up a display in landscape
- setUpDisplaySizeWithApp(2800, 1400);
+ setUpDisplaySizeWithApp(1000, 500);
final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false,
RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT);
@@ -2636,7 +2655,7 @@ public class SizeCompatTests extends WindowTestsBase {
@EnableCompatChanges({ActivityInfo.OVERRIDE_RESPECT_REQUESTED_ORIENTATION})
public void testOverrideRespectRequestedOrientationIsEnabled_multiWindow_orientationIgnored() {
// Set up a display in landscape
- setUpDisplaySizeWithApp(2800, 1400);
+ setUpDisplaySizeWithApp(1000, 500);
final ActivityRecord activity = buildActivityRecord(/* supportsSizeChanges= */ false,
RESIZE_MODE_UNRESIZEABLE, SCREEN_ORIENTATION_PORTRAIT);
@@ -2655,10 +2674,9 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testSplitAspectRatioForUnresizableLandscapeApps() {
// Set up a display in portrait and ignoring orientation request.
- int screenWidth = 1400;
- int screenHeight = 1600;
- setUpDisplaySizeWithApp(screenWidth, screenHeight);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLargeScreenDisplayWithApp(1400, 2400);
+ final int screenWidth = mDisplayContent.mBaseDisplayWidth;
+ final int screenHeight = mDisplayContent.mBaseDisplayHeight;
mActivity.mWmService.mAppCompatConfiguration
.setIsSplitScreenAspectRatioForUnresizableAppsEnabled(true);
@@ -2692,10 +2710,9 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayAspectRatioForResizablePortraitApps() {
// Set up a display in portrait and ignoring orientation request.
- int displayWidth = 1400;
- int displayHeight = 1600;
- setUpDisplaySizeWithApp(displayWidth, displayHeight);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLargeScreenDisplayWithApp(1400, 2400);
+ final int displayWidth = mDisplayContent.mBaseDisplayWidth;
+ final int displayHeight = mDisplayContent.mBaseDisplayHeight;
mWm.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio(2f);
// Enable display aspect ratio to take precedence before
@@ -2728,10 +2745,9 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayAspectRatioForResizableLandscapeApps() {
// Set up a display in landscape and ignoring orientation request.
- int displayWidth = 1600;
- int displayHeight = 1400;
- setUpDisplaySizeWithApp(displayWidth, displayHeight);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
+ final int displayWidth = mDisplayContent.mBaseDisplayWidth;
+ final int displayHeight = mDisplayContent.mBaseDisplayHeight;
mWm.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio(2f);
// Enable display aspect ratio to take precedence before
@@ -2764,10 +2780,9 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayAspectRatioForUnresizableLandscapeApps() {
// Set up a display in portrait and ignoring orientation request.
- int displayWidth = 1400;
- int displayHeight = 1600;
- setUpDisplaySizeWithApp(displayWidth, displayHeight);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpPortraitLargeScreenDisplayWithApp();
+ final int displayWidth = mDisplayContent.mBaseDisplayWidth;
+ final int displayHeight = mDisplayContent.mBaseDisplayHeight;
mActivity.mWmService.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio(1.1f);
// Enable display aspect ratio to take precedence before
@@ -2791,10 +2806,9 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayAspectRatioForUnresizablePortraitApps() {
// Set up a display in landscape and ignoring orientation request.
- int displayWidth = 1600;
- int displayHeight = 1400;
- setUpDisplaySizeWithApp(displayWidth, displayHeight);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
+ final int displayWidth = mDisplayContent.mBaseDisplayWidth;
+ final int displayHeight = mDisplayContent.mBaseDisplayHeight;
mActivity.mWmService.mAppCompatConfiguration.setFixedOrientationLetterboxAspectRatio(1.1f);
// Enable display aspect ratio to take precedence before
@@ -2819,8 +2833,7 @@ public class SizeCompatTests extends WindowTestsBase {
public void
testDisplayIgnoreOrientationRequest_orientationLetterboxBecameSizeCompatAfterRotate() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
// Portrait fixed app without max aspect.
prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT);
@@ -2837,7 +2850,7 @@ public class SizeCompatTests extends WindowTestsBase {
// App should be in size compat.
assertFalse(mActivity.mAppCompatController.getAppCompatAspectRatioPolicy()
.isLetterboxedForFixedOrientationAndAspectRatio());
- assertDownScaled();
+ assertThat(mActivity.inSizeCompatMode()).isTrue();
assertEquals(activityBounds.width(), newActivityBounds.width());
assertEquals(activityBounds.height(), newActivityBounds.height());
assertActivityMaxBoundsSandboxed();
@@ -2846,8 +2859,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayIgnoreOrientationRequest_sizeCompatAfterRotate() {
// Set up a display in portrait and ignoring orientation request.
- setUpDisplaySizeWithApp(1400, 2800);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpPortraitLargeScreenDisplayWithApp();
// Portrait fixed app without max aspect.
prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT);
@@ -2882,9 +2894,8 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayIgnoreOrientationRequest_newLaunchedOrientationAppInLetterbox() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
+ setUpLandscapeLargeScreenDisplayWithApp();
final DisplayContent display = mActivity.mDisplayContent;
- display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
// Portrait fixed app without max aspect.
prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT);
@@ -2928,9 +2939,7 @@ public class SizeCompatTests extends WindowTestsBase {
@EnableCompatChanges({ActivityInfo.OVERRIDE_ENABLE_INSETS_DECOUPLED_CONFIGURATION})
public void testDisplayIgnoreOrientationRequest_orientationChangedToUnspecified() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- final DisplayContent display = mActivity.mDisplayContent;
- display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
// Portrait fixed app without max aspect.
prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT);
@@ -2950,9 +2959,8 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayIgnoreOrientationRequest_newLaunchedMaxAspectApp() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
+ setUpLandscapeLargeScreenDisplayWithApp();
final DisplayContent display = mActivity.mDisplayContent;
- display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
// Portrait fixed app without max aspect.
prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT);
@@ -3001,9 +3009,7 @@ public class SizeCompatTests extends WindowTestsBase {
@SuppressWarnings("GuardedBy")
public void testDisplayIgnoreOrientationRequest_pausedAppNotLostSizeCompat() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- final DisplayContent display = mActivity.mDisplayContent;
- display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
// Portrait fixed app.
prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT);
@@ -3019,7 +3025,6 @@ public class SizeCompatTests extends WindowTestsBase {
// App should be in size compat.
assertFalse(mActivity.mAppCompatController.getAppCompatAspectRatioPolicy()
.isLetterboxedForFixedOrientationAndAspectRatio());
- assertDownScaled();
assertThat(mActivity.inSizeCompatMode()).isTrue();
// Activity max bounds are sandboxed due to size compat mode.
assertActivityMaxBoundsSandboxed();
@@ -3035,7 +3040,7 @@ public class SizeCompatTests extends WindowTestsBase {
verify(scmPolicy, never()).clearSizeCompatMode();
assertFalse(mActivity.mAppCompatController.getAppCompatAspectRatioPolicy()
.isLetterboxedForFixedOrientationAndAspectRatio());
- assertDownScaled();
+ assertThat(mActivity.inSizeCompatMode()).isTrue();
assertEquals(activityBounds, mActivity.getBounds());
// Activity max bounds are sandboxed due to size compat.
assertActivityMaxBoundsSandboxed();
@@ -3044,9 +3049,8 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testDisplayIgnoreOrientationRequest_rotated180_notInSizeCompat() {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
+ setUpLandscapeLargeScreenDisplayWithApp();
final DisplayContent display = mActivity.mDisplayContent;
- display.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
// Portrait fixed app.
prepareUnresizable(mActivity, 0, SCREEN_ORIENTATION_PORTRAIT);
@@ -3063,7 +3067,7 @@ public class SizeCompatTests extends WindowTestsBase {
// App should be in size compat.
assertFalse(mActivity.mAppCompatController.getAppCompatAspectRatioPolicy()
.isLetterboxedForFixedOrientationAndAspectRatio());
- assertDownScaled();
+ assertThat(mActivity.inSizeCompatMode()).isTrue();
assertActivityMaxBoundsSandboxed();
// Rotate display to landscape.
@@ -3246,8 +3250,9 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testTaskDisplayAreaNotFillDisplay() {
- setUpDisplaySizeWithApp(1400, 2800);
+ setUpPortraitLargeScreenDisplayWithApp();
final DisplayContent display = mActivity.mDisplayContent;
+ display.setIgnoreOrientationRequest(false);
final TaskDisplayArea taskDisplayArea = mActivity.getDisplayArea();
taskDisplayArea.setBounds(0, 0, 1000, 2400);
@@ -3430,8 +3435,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testIsHorizontalReachabilityEnabled_splitScreen_false() {
mAtm.mDevEnableNonResizableMultiWindow = true;
- setUpDisplaySizeWithApp(2800, 1000);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
mWm.mAppCompatConfiguration.setIsHorizontalReachabilityEnabled(true);
setUpAllowThinLetterboxed(/* thinLetterboxAllowed */ true);
final TestSplitOrganizer organizer =
@@ -3518,8 +3522,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testIsHorizontalReachabilityEnabled_emptyBounds_true() {
- setUpDisplaySizeWithApp(/* dw */ 2800, /* dh */ 1000);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
mWm.mAppCompatConfiguration.setIsHorizontalReachabilityEnabled(true);
setUpAllowThinLetterboxed(/* thinLetterboxAllowed */ true);
@@ -3566,8 +3569,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testIsHorizontalReachabilityEnabled_doesNotMatchParentHeight_false() {
- setUpDisplaySizeWithApp(2800, 1000);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
mWm.mAppCompatConfiguration.setIsHorizontalReachabilityEnabled(true);
setUpAllowThinLetterboxed(/* thinLetterboxAllowed */ true);
@@ -3787,12 +3789,10 @@ public class SizeCompatTests extends WindowTestsBase {
}
private void assertLandscapeActivityAlignedToBottomWithNavbar(boolean immersive) {
- final int screenHeight = 2800;
- final int screenWidth = 1400;
+ setUpPortraitLargeScreenDisplayWithApp();
+ final int screenHeight = mDisplayContent.mBaseDisplayHeight;
+ final int screenWidth = mDisplayContent.mBaseDisplayWidth;
final int taskbarHeight = 200;
- setUpDisplaySizeWithApp(screenWidth, screenHeight);
-
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true);
mActivity.mWmService.mAppCompatConfiguration.setLetterboxVerticalPositionMultiplier(1.0f);
final InsetsSource navSource = new InsetsSource(
@@ -3972,8 +3972,7 @@ public class SizeCompatTests extends WindowTestsBase {
float letterboxHorizontalPositionMultiplier, Rect fixedOrientationLetterbox,
Rect sizeCompatUnscaled, Rect sizeCompatScaled) {
// Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
mActivity.mWmService.mAppCompatConfiguration.setLetterboxHorizontalPositionMultiplier(
letterboxHorizontalPositionMultiplier);
@@ -4177,13 +4176,28 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testUpdateResolvedBoundsHorizontalPosition_activityFillParentWidth() {
+ // Set up a display in landscape and ignoring orientation request.
+ setUpLandscapeLargeScreenDisplayWithApp();
+ prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);
+
+ final Consumer<Float> assertHorizontalPosition = letterboxHorizontalPositionMultiplier -> {
+ mActivity.mWmService.mAppCompatConfiguration.setLetterboxHorizontalPositionMultiplier(
+ letterboxHorizontalPositionMultiplier);
+ mActivity.recomputeConfiguration();
+ assertFitted();
+ // Rotate to put activity in size compat mode.
+ rotateDisplay(mActivity.mDisplayContent, ROTATION_90);
+ assertTrue(mActivity.inSizeCompatMode());
+ // Activity is in size compat mode but not scaled.
+ assertEquals(new Rect(0, 0, 1400, 700), mActivity.getBounds());
+ if (letterboxHorizontalPositionMultiplier < 1f) {
+ rotateDisplay(mActivity.mDisplayContent, ROTATION_0);
+ }
+ };
// When activity width equals parent width, multiplier shouldn't have any effect.
- assertHorizontalPositionForDifferentDisplayConfigsForLandscapeActivity(
- /* letterboxHorizontalPositionMultiplier */ 0.0f);
- assertHorizontalPositionForDifferentDisplayConfigsForLandscapeActivity(
- /* letterboxHorizontalPositionMultiplier */ 0.5f);
- assertHorizontalPositionForDifferentDisplayConfigsForLandscapeActivity(
- /* letterboxHorizontalPositionMultiplier */ 1.0f);
+ assertHorizontalPosition.accept(0.0f);
+ assertHorizontalPosition.accept(0.5f);
+ assertHorizontalPosition.accept(1.0f);
}
@Test
@@ -4354,8 +4368,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testUpdateResolvedBoundsHorizontalPosition_bookModeEnabled() {
// Set up a display in landscape with a fixed-orientation PORTRAIT app
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
mWm.mAppCompatConfiguration.setIsAutomaticReachabilityInBookModeEnabled(true);
mWm.mAppCompatConfiguration.setLetterboxHorizontalPositionMultiplier(
1.0f /*letterboxHorizontalPositionMultiplier*/);
@@ -4380,8 +4393,7 @@ public class SizeCompatTests extends WindowTestsBase {
@Test
public void testUpdateResolvedBoundsHorizontalPosition_bookModeDisabled_centered() {
// Set up a display in landscape with a fixed-orientation PORTRAIT app
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpLandscapeLargeScreenDisplayWithApp();
mWm.mAppCompatConfiguration.setIsAutomaticReachabilityInBookModeEnabled(false);
mWm.mAppCompatConfiguration.setLetterboxHorizontalPositionMultiplier(0.5f);
prepareUnresizable(mActivity, 1.75f, SCREEN_ORIENTATION_PORTRAIT);
@@ -4462,8 +4474,7 @@ public class SizeCompatTests extends WindowTestsBase {
float letterboxVerticalPositionMultiplier, Rect fixedOrientationLetterbox,
Rect sizeCompatUnscaled, Rect sizeCompatScaled) {
// Set up a display in portrait and ignoring orientation request.
- setUpDisplaySizeWithApp(1400, 2800);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
+ setUpPortraitLargeScreenDisplayWithApp();
mActivity.mWmService.mAppCompatConfiguration.setLetterboxVerticalPositionMultiplier(
letterboxVerticalPositionMultiplier);
@@ -5036,23 +5047,6 @@ public class SizeCompatTests extends WindowTestsBase {
return (dimensionToSplit - (dividerWindowWidth - dividerInsets * 2)) / 2;
}
- private void assertHorizontalPositionForDifferentDisplayConfigsForLandscapeActivity(
- float letterboxHorizontalPositionMultiplier) {
- // Set up a display in landscape and ignoring orientation request.
- setUpDisplaySizeWithApp(2800, 1400);
- mActivity.mDisplayContent.setIgnoreOrientationRequest(true /* ignoreOrientationRequest */);
-
- mActivity.mWmService.mAppCompatConfiguration.setLetterboxHorizontalPositionMultiplier(
- letterboxHorizontalPositionMultiplier);
- prepareUnresizable(mActivity, SCREEN_ORIENTATION_LANDSCAPE);
- assertFitted();
- // Rotate to put activity in size compat mode.
- rotateDisplay(mActivity.mDisplayContent, ROTATION_90);
- assertTrue(mActivity.inSizeCompatMode());
- // Activity is in size compat mode but not scaled.
- assertEquals(new Rect(0, 0, 1400, 700), mActivity.getBounds());
- }
-
private void assertVerticalPositionForDifferentDisplayConfigsForPortraitActivity(
float letterboxVerticalPositionMultiplier) {
// Set up a display in portrait and ignoring orientation request.
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
index 65a6a69fc45e..dafa96f91812 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskFragmentTest.java
@@ -51,6 +51,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertSame;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.Mockito.clearInvocations;
@@ -62,6 +63,7 @@ import android.content.res.Configuration;
import android.graphics.Color;
import android.graphics.Rect;
import android.os.Binder;
+import android.platform.test.annotations.EnableFlags;
import android.platform.test.annotations.Presubmit;
import android.view.SurfaceControl;
import android.view.View;
@@ -1066,6 +1068,98 @@ public class TaskFragmentTest extends WindowTestsBase {
Math.min(outConfig.screenWidthDp, outConfig.screenHeightDp));
}
+ @EnableFlags(Flags.FLAG_ALLOW_MULTIPLE_ADJACENT_TASK_FRAGMENTS)
+ @Test
+ public void testSetAdjacentTaskFragments() {
+ final Task task = createTask(mDisplayContent);
+ final TaskFragment tf0 = createTaskFragmentWithActivity(task);
+ final TaskFragment tf1 = createTaskFragmentWithActivity(task);
+ final TaskFragment tf2 = createTaskFragmentWithActivity(task);
+ final TaskFragment.AdjacentSet adjacentTfs = new TaskFragment.AdjacentSet(tf0, tf1, tf2);
+ assertFalse(tf0.hasAdjacentTaskFragment());
+
+ tf0.setAdjacentTaskFragments(adjacentTfs);
+
+ assertSame(adjacentTfs, tf0.getAdjacentTaskFragments());
+ assertSame(adjacentTfs, tf1.getAdjacentTaskFragments());
+ assertSame(adjacentTfs, tf2.getAdjacentTaskFragments());
+ assertTrue(tf0.hasAdjacentTaskFragment());
+ assertTrue(tf1.hasAdjacentTaskFragment());
+ assertTrue(tf2.hasAdjacentTaskFragment());
+
+ final TaskFragment.AdjacentSet adjacentTfs2 = new TaskFragment.AdjacentSet(tf0, tf1);
+ tf0.setAdjacentTaskFragments(adjacentTfs2);
+
+ assertSame(adjacentTfs2, tf0.getAdjacentTaskFragments());
+ assertSame(adjacentTfs2, tf1.getAdjacentTaskFragments());
+ assertNull(tf2.getAdjacentTaskFragments());
+ assertTrue(tf0.hasAdjacentTaskFragment());
+ assertTrue(tf1.hasAdjacentTaskFragment());
+ assertFalse(tf2.hasAdjacentTaskFragment());
+ }
+
+ @EnableFlags(Flags.FLAG_ALLOW_MULTIPLE_ADJACENT_TASK_FRAGMENTS)
+ @Test
+ public void testClearAdjacentTaskFragments() {
+ final Task task = createTask(mDisplayContent);
+ final TaskFragment tf0 = createTaskFragmentWithActivity(task);
+ final TaskFragment tf1 = createTaskFragmentWithActivity(task);
+ final TaskFragment tf2 = createTaskFragmentWithActivity(task);
+ final TaskFragment.AdjacentSet adjacentTfs = new TaskFragment.AdjacentSet(tf0, tf1, tf2);
+ tf0.setAdjacentTaskFragments(adjacentTfs);
+
+ tf0.clearAdjacentTaskFragments();
+
+ assertNull(tf0.getAdjacentTaskFragments());
+ assertNull(tf1.getAdjacentTaskFragments());
+ assertNull(tf2.getAdjacentTaskFragments());
+ assertFalse(tf0.hasAdjacentTaskFragment());
+ assertFalse(tf1.hasAdjacentTaskFragment());
+ assertFalse(tf2.hasAdjacentTaskFragment());
+ }
+
+ @EnableFlags(Flags.FLAG_ALLOW_MULTIPLE_ADJACENT_TASK_FRAGMENTS)
+ @Test
+ public void testRemoveFromAdjacentTaskFragments() {
+ final Task task = createTask(mDisplayContent);
+ final TaskFragment tf0 = createTaskFragmentWithActivity(task);
+ final TaskFragment tf1 = createTaskFragmentWithActivity(task);
+ final TaskFragment tf2 = createTaskFragmentWithActivity(task);
+ final TaskFragment.AdjacentSet adjacentTfs = new TaskFragment.AdjacentSet(tf0, tf1, tf2);
+ tf0.setAdjacentTaskFragments(adjacentTfs);
+
+ tf0.removeFromAdjacentTaskFragments();
+
+ assertNull(tf0.getAdjacentTaskFragments());
+ assertSame(adjacentTfs, tf1.getAdjacentTaskFragments());
+ assertSame(adjacentTfs, tf2.getAdjacentTaskFragments());
+ assertFalse(adjacentTfs.contains(tf0));
+ assertTrue(tf1.isAdjacentTo(tf2));
+ assertTrue(tf2.isAdjacentTo(tf1));
+ assertFalse(tf1.isAdjacentTo(tf0));
+ assertFalse(tf0.isAdjacentTo(tf1));
+ assertFalse(tf0.isAdjacentTo(tf0));
+ assertFalse(tf1.isAdjacentTo(tf1));
+ }
+
+ @EnableFlags(Flags.FLAG_ALLOW_MULTIPLE_ADJACENT_TASK_FRAGMENTS)
+ @Test
+ public void testRemoveFromAdjacentTaskFragmentsWhenRemove() {
+ final Task task = createTask(mDisplayContent);
+ final TaskFragment tf0 = createTaskFragmentWithActivity(task);
+ final TaskFragment tf1 = createTaskFragmentWithActivity(task);
+ final TaskFragment tf2 = createTaskFragmentWithActivity(task);
+ final TaskFragment.AdjacentSet adjacentTfs = new TaskFragment.AdjacentSet(tf0, tf1, tf2);
+ tf0.setAdjacentTaskFragments(adjacentTfs);
+
+ tf0.removeImmediately();
+
+ assertNull(tf0.getAdjacentTaskFragments());
+ assertSame(adjacentTfs, tf1.getAdjacentTaskFragments());
+ assertSame(adjacentTfs, tf2.getAdjacentTaskFragments());
+ assertFalse(adjacentTfs.contains(tf0));
+ }
+
private WindowState createAppWindow(ActivityRecord app, String name) {
final WindowState win = createWindow(null, TYPE_BASE_APPLICATION, app, name,
0 /* ownerId */, false /* ownerCanAddInternalSystemWindow */, new TestIWindow());
diff --git a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
index e4512c31069a..1febc9fb4742 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TaskTests.java
@@ -527,6 +527,7 @@ public class TaskTests extends WindowTestsBase {
@Test
public void testHandlesOrientationChangeFromDescendant() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final Task rootTask = createTask(mDisplayContent,
WINDOWING_MODE_MULTI_WINDOW, ACTIVITY_TYPE_STANDARD);
final Task leafTask1 = createTaskInRootTask(rootTask, 0 /* userId */);
@@ -1570,6 +1571,7 @@ public class TaskTests extends WindowTestsBase {
@Test
public void testNotSpecifyOrientationByFloatingTask() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final Task task = new TaskBuilder(mSupervisor)
.setCreateActivity(true).setCreateParentTask(true).build();
final ActivityRecord activity = task.getTopMostActivity();
@@ -1589,6 +1591,7 @@ public class TaskTests extends WindowTestsBase {
@Test
public void testNotSpecifyOrientation_taskDisplayAreaNotFocused() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final TaskDisplayArea firstTaskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea();
final TaskDisplayArea secondTaskDisplayArea = createTaskDisplayArea(
mDisplayContent, mRootWindowContainer.mWmService, "TestTaskDisplayArea",
@@ -1625,6 +1628,7 @@ public class TaskTests extends WindowTestsBase {
@Test
public void testTaskOrientationOnDisplayWindowingModeChange() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
// Skip unnecessary operations to speed up the test.
mAtm.deferWindowLayout();
final Task task = getTestTask();
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 039a3ddd3e4f..78f32c1a4f88 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TransitionTests.java
@@ -1333,6 +1333,7 @@ public class TransitionTests extends WindowTestsBase {
@Test
public void testDeferRotationForTransientLaunch() {
+ mDisplayContent.setIgnoreOrientationRequest(false);
final TestTransitionPlayer player = registerTestTransitionPlayer();
assumeFalse(mDisplayContent.mTransitionController.useShellTransitionsRotation());
final ActivityRecord app = new ActivityBuilder(mAtm).setCreateTask(true).build();
diff --git a/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java b/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java
index 42752c326615..f1180ff93edb 100644
--- a/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java
+++ b/services/tests/wmtests/src/com/android/server/wm/TransparentPolicyTest.java
@@ -314,6 +314,7 @@ public class TransparentPolicyTest extends WindowTestsBase {
runTestScenario((robot) -> {
robot.transparentActivity((ta) -> {
ta.applyOnActivity((a) -> {
+ a.setIgnoreOrientationRequest(false);
a.applyToTopActivity((topActivity) -> {
topActivity.mWmService.mAppCompatConfiguration
.setLetterboxHorizontalPositionMultiplier(1.0f);
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
index 410fa2879600..da4c522834a6 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowOrganizerTests.java
@@ -777,6 +777,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
@Test
public void testSetIgnoreOrientationRequest_taskDisplayArea() {
removeGlobalMinSizeRestriction();
+ mDisplayContent.setIgnoreOrientationRequest(false);
final TaskDisplayArea taskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea();
final Task rootTask = taskDisplayArea.createRootTask(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, false /* onTop */);
@@ -815,6 +816,7 @@ public class WindowOrganizerTests extends WindowTestsBase {
@Test
public void testSetIgnoreOrientationRequest_displayContent() {
removeGlobalMinSizeRestriction();
+ mDisplayContent.setIgnoreOrientationRequest(false);
final TaskDisplayArea taskDisplayArea = mDisplayContent.getDefaultTaskDisplayArea();
final Task rootTask = taskDisplayArea.createRootTask(
WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD, false /* onTop */);
@@ -924,6 +926,49 @@ public class WindowOrganizerTests extends WindowTestsBase {
assertEquals(dc.getDefaultTaskDisplayArea().mLaunchAdjacentFlagRootTask, null);
}
+ @EnableFlags(Flags.FLAG_ALLOW_MULTIPLE_ADJACENT_TASK_FRAGMENTS)
+ @Test
+ public void testSetAdjacentLaunchRootSet() {
+ final DisplayContent dc = mWm.mRoot.getDisplayContent(Display.DEFAULT_DISPLAY);
+
+ final Task task1 = mWm.mAtmService.mTaskOrganizerController.createRootTask(
+ dc, WINDOWING_MODE_MULTI_WINDOW, null);
+ final RunningTaskInfo info1 = task1.getTaskInfo();
+ final Task task2 = mWm.mAtmService.mTaskOrganizerController.createRootTask(
+ dc, WINDOWING_MODE_MULTI_WINDOW, null);
+ final RunningTaskInfo info2 = task2.getTaskInfo();
+ final Task task3 = mWm.mAtmService.mTaskOrganizerController.createRootTask(
+ dc, WINDOWING_MODE_MULTI_WINDOW, null);
+ final RunningTaskInfo info3 = task3.getTaskInfo();
+
+ WindowContainerTransaction wct = new WindowContainerTransaction();
+ wct.setAdjacentRootSet(info1.token, info2.token, info3.token);
+ mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct);
+ assertTrue(task1.hasAdjacentTaskFragment());
+ assertTrue(task2.hasAdjacentTaskFragment());
+ assertTrue(task3.hasAdjacentTaskFragment());
+ assertTrue(task1.isAdjacentTo(task2));
+ assertTrue(task1.isAdjacentTo(task3));
+ assertTrue(task2.isAdjacentTo(task3));
+
+ wct = new WindowContainerTransaction();
+ wct.clearAdjacentRoots(info1.token);
+ mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct);
+ assertFalse(task1.hasAdjacentTaskFragment());
+ assertTrue(task2.hasAdjacentTaskFragment());
+ assertTrue(task3.hasAdjacentTaskFragment());
+ assertFalse(task1.isAdjacentTo(task2));
+ assertFalse(task1.isAdjacentTo(task3));
+ assertTrue(task2.isAdjacentTo(task3));
+
+ wct = new WindowContainerTransaction();
+ wct.clearAdjacentRoots(info2.token);
+ mWm.mAtmService.mWindowOrganizerController.applyTransaction(wct);
+ assertFalse(task2.hasAdjacentTaskFragment());
+ assertFalse(task3.hasAdjacentTaskFragment());
+ assertFalse(task2.isAdjacentTo(task3));
+ }
+
@Test
public void testTileAddRemoveChild() {
final StubOrganizer listener = new StubOrganizer();
diff --git a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
index 3a97cc621e0d..b27025c34d6b 100644
--- a/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
+++ b/services/tests/wmtests/src/com/android/server/wm/WindowTestsBase.java
@@ -201,14 +201,10 @@ public class WindowTestsBase extends SystemServiceTestsBase {
* {@link WindowTestsBase#setUpBase()}.
*/
private static boolean sGlobalOverridesChecked;
+
/**
* Whether device-specific overrides have already been checked in
- * {@link WindowTestsBase#setUpBase()} when the default display is used.
- */
- private static boolean sOverridesCheckedDefaultDisplay;
- /**
- * Whether device-specific overrides have already been checked in
- * {@link WindowTestsBase#setUpBase()} when a {@link TestDisplayContent} is used.
+ * {@link WindowTestsBase#setUpBase()}.
*/
private static boolean sOverridesCheckedTestDisplay;
@@ -332,17 +328,14 @@ public class WindowTestsBase extends SystemServiceTestsBase {
private void checkDeviceSpecificOverridesNotApplied() {
// Check global overrides
if (!sGlobalOverridesChecked) {
+ sGlobalOverridesChecked = true;
assertEquals(0, mWm.mAppCompatConfiguration.getFixedOrientationLetterboxAspectRatio(),
0 /* delta */);
- sGlobalOverridesChecked = true;
}
// Check display-specific overrides
- if (!sOverridesCheckedDefaultDisplay && mDisplayContent == mDefaultDisplay) {
- assertFalse(mDisplayContent.getIgnoreOrientationRequest());
- sOverridesCheckedDefaultDisplay = true;
- } else if (!sOverridesCheckedTestDisplay && mDisplayContent instanceof TestDisplayContent) {
- assertFalse(mDisplayContent.getIgnoreOrientationRequest());
+ if (!sOverridesCheckedTestDisplay) {
sOverridesCheckedTestDisplay = true;
+ assertFalse(mDisplayContent.mHasSetIgnoreOrientationRequest);
}
}
@@ -1121,7 +1114,7 @@ public class WindowTestsBase extends SystemServiceTestsBase {
displayContent.getDisplayRotation().configure(width, height);
final Configuration c = new Configuration();
displayContent.computeScreenConfiguration(c);
- displayContent.onRequestedOverrideConfigurationChanged(c);
+ displayContent.performDisplayOverrideConfigUpdate(c);
}
static void makeDisplayLargeScreen(DisplayContent displayContent) {
diff --git a/telephony/java/android/telephony/Annotation.java b/telephony/java/android/telephony/Annotation.java
index 09b18b65be4a..8fe107cc1ad3 100644
--- a/telephony/java/android/telephony/Annotation.java
+++ b/telephony/java/android/telephony/Annotation.java
@@ -109,7 +109,6 @@ public class Annotation {
//TelephonyManager.NETWORK_TYPE_LTE_CA,
TelephonyManager.NETWORK_TYPE_NR,
- TelephonyManager.NETWORK_TYPE_NB_IOT_NTN,
})
@Retention(RetentionPolicy.SOURCE)
public @interface NetworkType {
diff --git a/telephony/java/android/telephony/CellIdentityCdma.java b/telephony/java/android/telephony/CellIdentityCdma.java
index 4e5a246ef773..4cb622b3eb9e 100644
--- a/telephony/java/android/telephony/CellIdentityCdma.java
+++ b/telephony/java/android/telephony/CellIdentityCdma.java
@@ -105,20 +105,30 @@ public final class CellIdentityCdma extends CellIdentity {
*/
public CellIdentityCdma(int nid, int sid, int bid, int lon, int lat,
@Nullable String alphal, @Nullable String alphas) {
- super(TAG, CellInfo.TYPE_CDMA, null, null, alphal, alphas);
- mNetworkId = inRangeOrUnavailable(nid, 0, NETWORK_ID_MAX);
- mSystemId = inRangeOrUnavailable(sid, 0, SYSTEM_ID_MAX);
- mBasestationId = inRangeOrUnavailable(bid, 0, BASESTATION_ID_MAX);
- lat = inRangeOrUnavailable(lat, LATITUDE_MIN, LATITUDE_MAX);
- lon = inRangeOrUnavailable(lon, LONGITUDE_MIN, LONGITUDE_MAX);
-
- if (!isNullIsland(lat, lon)) {
- mLongitude = lon;
- mLatitude = lat;
+ super(TAG, CellInfo.TYPE_CDMA, null, null, Flags.cleanupCdma() ? null : alphal,
+ Flags.cleanupCdma() ? null : alphas);
+ if (Flags.cleanupCdma()) {
+ mNetworkId = CellInfo.UNAVAILABLE;
+ mSystemId = CellInfo.UNAVAILABLE;
+ mBasestationId = CellInfo.UNAVAILABLE;
+ mLongitude = CellInfo.UNAVAILABLE;
+ mLatitude = CellInfo.UNAVAILABLE;
+ mGlobalCellId = null;
} else {
- mLongitude = mLatitude = CellInfo.UNAVAILABLE;
+ mNetworkId = inRangeOrUnavailable(nid, 0, NETWORK_ID_MAX);
+ mSystemId = inRangeOrUnavailable(sid, 0, SYSTEM_ID_MAX);
+ mBasestationId = inRangeOrUnavailable(bid, 0, BASESTATION_ID_MAX);
+ lat = inRangeOrUnavailable(lat, LATITUDE_MIN, LATITUDE_MAX);
+ lon = inRangeOrUnavailable(lon, LONGITUDE_MIN, LONGITUDE_MAX);
+
+ if (!isNullIsland(lat, lon)) {
+ mLongitude = lon;
+ mLatitude = lat;
+ } else {
+ mLongitude = mLatitude = CellInfo.UNAVAILABLE;
+ }
+ updateGlobalCellId();
}
- updateGlobalCellId();
}
private CellIdentityCdma(@NonNull CellIdentityCdma cid) {
@@ -300,14 +310,34 @@ public final class CellIdentityCdma extends CellIdentity {
/** Construct from Parcel, type has already been processed */
private CellIdentityCdma(Parcel in) {
super(TAG, CellInfo.TYPE_CDMA, in);
- mNetworkId = in.readInt();
- mSystemId = in.readInt();
- mBasestationId = in.readInt();
- mLongitude = in.readInt();
- mLatitude = in.readInt();
-
- updateGlobalCellId();
- if (DBG) log(toString());
+
+ if (Flags.cleanupCdma()) {
+ in.readInt();
+ mNetworkId = CellInfo.UNAVAILABLE;
+
+ in.readInt();
+ mSystemId = CellInfo.UNAVAILABLE;
+
+ in.readInt();
+ mBasestationId = CellInfo.UNAVAILABLE;
+
+ in.readInt();
+ mLongitude = CellInfo.UNAVAILABLE;
+
+ in.readInt();
+ mLatitude = CellInfo.UNAVAILABLE;
+
+ mGlobalCellId = null;
+ } else {
+ mNetworkId = in.readInt();
+ mSystemId = in.readInt();
+ mBasestationId = in.readInt();
+ mLongitude = in.readInt();
+ mLatitude = in.readInt();
+
+ updateGlobalCellId();
+ if (DBG) log(toString());
+ }
}
/**
diff --git a/telephony/java/android/telephony/CellSignalStrengthCdma.java b/telephony/java/android/telephony/CellSignalStrengthCdma.java
index 5298e67bdf80..12a7294c42de 100644
--- a/telephony/java/android/telephony/CellSignalStrengthCdma.java
+++ b/telephony/java/android/telephony/CellSignalStrengthCdma.java
@@ -21,6 +21,7 @@ import android.os.Parcel;
import android.os.Parcelable;
import android.os.PersistableBundle;
+import com.android.internal.telephony.flags.Flags;
import com.android.telephony.Rlog;
import java.util.Objects;
@@ -68,13 +69,17 @@ public final class CellSignalStrengthCdma extends CellSignalStrength implements
*/
public CellSignalStrengthCdma(int cdmaDbm, int cdmaEcio, int evdoDbm, int evdoEcio,
int evdoSnr) {
- mCdmaDbm = inRangeOrUnavailable(cdmaDbm, -120, 0);
- mCdmaEcio = inRangeOrUnavailable(cdmaEcio, -160, 0);
- mEvdoDbm = inRangeOrUnavailable(evdoDbm, -120, 0);
- mEvdoEcio = inRangeOrUnavailable(evdoEcio, -160, 0);
- mEvdoSnr = inRangeOrUnavailable(evdoSnr, 0, 8);
+ if (Flags.cleanupCdma()) {
+ setDefaultValues();
+ } else {
+ mCdmaDbm = inRangeOrUnavailable(cdmaDbm, -120, 0);
+ mCdmaEcio = inRangeOrUnavailable(cdmaEcio, -160, 0);
+ mEvdoDbm = inRangeOrUnavailable(evdoDbm, -120, 0);
+ mEvdoEcio = inRangeOrUnavailable(evdoEcio, -160, 0);
+ mEvdoSnr = inRangeOrUnavailable(evdoSnr, 0, 8);
- updateLevel(null, null);
+ updateLevel(null, null);
+ }
}
/** @hide */
@@ -84,6 +89,10 @@ public final class CellSignalStrengthCdma extends CellSignalStrength implements
/** @hide */
protected void copyFrom(CellSignalStrengthCdma s) {
+ if (Flags.cleanupCdma()) {
+ setDefaultValues();
+ return;
+ }
mCdmaDbm = s.mCdmaDbm;
mCdmaEcio = s.mCdmaEcio;
mEvdoDbm = s.mEvdoDbm;
@@ -389,6 +398,7 @@ public final class CellSignalStrengthCdma extends CellSignalStrength implements
/** @hide */
@Override
public boolean isValid() {
+ if (Flags.cleanupCdma()) return false;
return !this.equals(sInvalid);
}
@@ -446,7 +456,12 @@ public final class CellSignalStrengthCdma extends CellSignalStrength implements
mEvdoEcio = in.readInt();
mEvdoSnr = in.readInt();
mLevel = in.readInt();
- if (DBG) log("CellSignalStrengthCdma(Parcel): " + toString());
+
+ if (Flags.cleanupCdma()) {
+ setDefaultValues();
+ } else {
+ if (DBG) log("CellSignalStrengthCdma(Parcel): " + toString());
+ }
}
/** Implement the Parcelable interface */
diff --git a/telephony/java/android/telephony/RadioAccessFamily.java b/telephony/java/android/telephony/RadioAccessFamily.java
index 8b52f07102b8..90d6f89553b7 100644
--- a/telephony/java/android/telephony/RadioAccessFamily.java
+++ b/telephony/java/android/telephony/RadioAccessFamily.java
@@ -66,9 +66,6 @@ public class RadioAccessFamily implements Parcelable {
// 5G
public static final int RAF_NR = (int) TelephonyManager.NETWORK_TYPE_BITMASK_NR;
- /** NB-IOT (Narrowband Internet of Things) over Non-Terrestrial-Networks technology. */
- public static final int RAF_NB_IOT_NTN = (int) TelephonyManager.NETWORK_TYPE_BITMASK_NB_IOT_NTN;
-
// Grouping of RAFs
// 2G
private static final int GSM = RAF_GSM | RAF_GPRS | RAF_EDGE;
@@ -83,9 +80,6 @@ public class RadioAccessFamily implements Parcelable {
// 5G
private static final int NR = RAF_NR;
- /** Non-Terrestrial Network. */
- private static final int NB_IOT_NTN = RAF_NB_IOT_NTN;
-
/* Phone ID of phone */
private int mPhoneId;
@@ -264,7 +258,7 @@ public class RadioAccessFamily implements Parcelable {
raf = ((EVDO & raf) > 0) ? (EVDO | raf) : raf;
raf = ((LTE & raf) > 0) ? (LTE | raf) : raf;
raf = ((NR & raf) > 0) ? (NR | raf) : raf;
- raf = ((NB_IOT_NTN & raf) > 0) ? (NB_IOT_NTN | raf) : raf;
+
return raf;
}
@@ -370,7 +364,6 @@ public class RadioAccessFamily implements Parcelable {
case "WCDMA": return WCDMA;
case "LTE_CA": return RAF_LTE_CA;
case "NR": return RAF_NR;
- case "NB_IOT_NTN": return RAF_NB_IOT_NTN;
default: return RAF_UNKNOWN;
}
}
diff --git a/telephony/java/android/telephony/ServiceState.java b/telephony/java/android/telephony/ServiceState.java
index f8c3287fec36..127bbff01575 100644
--- a/telephony/java/android/telephony/ServiceState.java
+++ b/telephony/java/android/telephony/ServiceState.java
@@ -233,12 +233,6 @@ public class ServiceState implements Parcelable {
public static final int RIL_RADIO_TECHNOLOGY_NR = 20;
/**
- * 3GPP NB-IOT (Narrowband Internet of Things) over Non-Terrestrial-Networks technology.
- * @hide
- */
- public static final int RIL_RADIO_TECHNOLOGY_NB_IOT_NTN = 21;
-
- /**
* RIL Radio Annotation
* @hide
*/
@@ -264,16 +258,14 @@ public class ServiceState implements Parcelable {
ServiceState.RIL_RADIO_TECHNOLOGY_TD_SCDMA,
ServiceState.RIL_RADIO_TECHNOLOGY_IWLAN,
ServiceState.RIL_RADIO_TECHNOLOGY_LTE_CA,
- ServiceState.RIL_RADIO_TECHNOLOGY_NR,
- ServiceState.RIL_RADIO_TECHNOLOGY_NB_IOT_NTN
- })
+ ServiceState.RIL_RADIO_TECHNOLOGY_NR})
public @interface RilRadioTechnology {}
/**
* The number of the radio technologies.
*/
- private static final int NEXT_RIL_RADIO_TECHNOLOGY = 22;
+ private static final int NEXT_RIL_RADIO_TECHNOLOGY = 21;
/** @hide */
public static final int RIL_RADIO_CDMA_TECHNOLOGY_BITMASK =
@@ -1133,9 +1125,6 @@ public class ServiceState implements Parcelable {
case RIL_RADIO_TECHNOLOGY_NR:
rtString = "NR_SA";
break;
- case RIL_RADIO_TECHNOLOGY_NB_IOT_NTN:
- rtString = "NB_IOT_NTN";
- break;
default:
rtString = "Unexpected";
Rlog.w(LOG_TAG, "Unexpected radioTechnology=" + rt);
@@ -1679,8 +1668,6 @@ public class ServiceState implements Parcelable {
return TelephonyManager.NETWORK_TYPE_LTE_CA;
case RIL_RADIO_TECHNOLOGY_NR:
return TelephonyManager.NETWORK_TYPE_NR;
- case RIL_RADIO_TECHNOLOGY_NB_IOT_NTN:
- return TelephonyManager.NETWORK_TYPE_NB_IOT_NTN;
default:
return TelephonyManager.NETWORK_TYPE_UNKNOWN;
}
@@ -1710,7 +1697,6 @@ public class ServiceState implements Parcelable {
return AccessNetworkType.CDMA2000;
case RIL_RADIO_TECHNOLOGY_LTE:
case RIL_RADIO_TECHNOLOGY_LTE_CA:
- case RIL_RADIO_TECHNOLOGY_NB_IOT_NTN:
return AccessNetworkType.EUTRAN;
case RIL_RADIO_TECHNOLOGY_NR:
return AccessNetworkType.NGRAN;
@@ -1771,8 +1757,6 @@ public class ServiceState implements Parcelable {
return RIL_RADIO_TECHNOLOGY_LTE_CA;
case TelephonyManager.NETWORK_TYPE_NR:
return RIL_RADIO_TECHNOLOGY_NR;
- case TelephonyManager.NETWORK_TYPE_NB_IOT_NTN:
- return RIL_RADIO_TECHNOLOGY_NB_IOT_NTN;
default:
return RIL_RADIO_TECHNOLOGY_UNKNOWN;
}
@@ -1882,8 +1866,7 @@ public class ServiceState implements Parcelable {
|| radioTechnology == RIL_RADIO_TECHNOLOGY_TD_SCDMA
|| radioTechnology == RIL_RADIO_TECHNOLOGY_IWLAN
|| radioTechnology == RIL_RADIO_TECHNOLOGY_LTE_CA
- || radioTechnology == RIL_RADIO_TECHNOLOGY_NR
- || radioTechnology == RIL_RADIO_TECHNOLOGY_NB_IOT_NTN;
+ || radioTechnology == RIL_RADIO_TECHNOLOGY_NR;
}
@@ -1903,8 +1886,7 @@ public class ServiceState implements Parcelable {
public static boolean isPsOnlyTech(int radioTechnology) {
return radioTechnology == RIL_RADIO_TECHNOLOGY_LTE
|| radioTechnology == RIL_RADIO_TECHNOLOGY_LTE_CA
- || radioTechnology == RIL_RADIO_TECHNOLOGY_NR
- || radioTechnology == RIL_RADIO_TECHNOLOGY_NB_IOT_NTN;
+ || radioTechnology == RIL_RADIO_TECHNOLOGY_NR;
}
/** @hide */
diff --git a/telephony/java/android/telephony/TelephonyManager.java b/telephony/java/android/telephony/TelephonyManager.java
index 7e87ecd9c12d..24fb8c5da2d7 100644
--- a/telephony/java/android/telephony/TelephonyManager.java
+++ b/telephony/java/android/telephony/TelephonyManager.java
@@ -3197,12 +3197,6 @@ public class TelephonyManager {
* For 5G NSA, the network type will be {@link #NETWORK_TYPE_LTE}.
*/
public static final int NETWORK_TYPE_NR = TelephonyProtoEnums.NETWORK_TYPE_NR; // 20.
- /**
- * 3GPP NB-IOT (Narrowband Internet of Things) over Non-Terrestrial-Networks technology.
- */
- @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS)
- public static final int NETWORK_TYPE_NB_IOT_NTN =
- TelephonyProtoEnums.NETWORK_TYPE_NB_IOT_NTN; // 21
private static final @NetworkType int[] NETWORK_TYPES = {
NETWORK_TYPE_GPRS,
@@ -3279,7 +3273,6 @@ public class TelephonyManager {
* @see #NETWORK_TYPE_EHRPD
* @see #NETWORK_TYPE_HSPAP
* @see #NETWORK_TYPE_NR
- * @see #NETWORK_TYPE_NB_IOT_NTN
*
* @hide
*/
@@ -3340,7 +3333,6 @@ public class TelephonyManager {
* @see #NETWORK_TYPE_EHRPD
* @see #NETWORK_TYPE_HSPAP
* @see #NETWORK_TYPE_NR
- * @see #NETWORK_TYPE_NB_IOT_NTN
*
* @throws UnsupportedOperationException If the device does not have
* {@link PackageManager#FEATURE_TELEPHONY_RADIO_ACCESS}.
@@ -3491,8 +3483,6 @@ public class TelephonyManager {
return "LTE_CA";
case NETWORK_TYPE_NR:
return "NR";
- case NETWORK_TYPE_NB_IOT_NTN:
- return "NB_IOT_NTN";
case NETWORK_TYPE_UNKNOWN:
return "UNKNOWN";
default:
@@ -3543,8 +3533,6 @@ public class TelephonyManager {
return NETWORK_TYPE_BITMASK_LTE;
case NETWORK_TYPE_NR:
return NETWORK_TYPE_BITMASK_NR;
- case NETWORK_TYPE_NB_IOT_NTN:
- return NETWORK_TYPE_BITMASK_NB_IOT_NTN;
case NETWORK_TYPE_IWLAN:
return NETWORK_TYPE_BITMASK_IWLAN;
case NETWORK_TYPE_IDEN:
@@ -6387,6 +6375,7 @@ public class TelephonyManager {
* @deprecated use {@link #getImsPrivateUserIdentity()}
*/
@UnsupportedAppUsage
+ @Deprecated
public String getIsimImpi() {
try {
IPhoneSubInfo info = getSubscriberInfoService();
@@ -6476,6 +6465,7 @@ public class TelephonyManager {
* @deprecated use {@link #getImsPublicUserIdentities()}
*/
@UnsupportedAppUsage
+ @Deprecated
@Nullable
@RequiresPermission(android.Manifest.permission.READ_PRIVILEGED_PHONE_STATE)
public String[] getIsimImpu() {
@@ -10337,9 +10327,6 @@ public class TelephonyManager {
* This API will result in allowing an intersection of allowed network types for all reasons,
* including the configuration done through other reasons.
*
- * If device supports satellite service, then
- * {@link #NETWORK_TYPE_NB_IOT_NTN} is added to allowed network types for reason by default.
- *
* @param reason the reason the allowed network type change is taking place
* @param allowedNetworkTypes The bitmask of allowed network type
* @throws IllegalStateException if the Telephony process is not currently available.
@@ -10389,10 +10376,6 @@ public class TelephonyManager {
* <p>Requires permission: android.Manifest.READ_PRIVILEGED_PHONE_STATE or
* that the calling app has carrier privileges (see {@link #hasCarrierPrivileges}).
*
- * If device supports satellite service, then
- * {@link #NETWORK_TYPE_NB_IOT_NTN} is added to allowed network types for reason by
- * default.
- *
* @param reason the reason the allowed network type change is taking place
* @return the allowed network type bitmask
* @throws IllegalStateException if the Telephony process is not currently available.
@@ -10459,7 +10442,7 @@ public class TelephonyManager {
*/
public static String convertNetworkTypeBitmaskToString(
@NetworkTypeBitMask long networkTypeBitmask) {
- String networkTypeName = IntStream.rangeClosed(NETWORK_TYPE_GPRS, NETWORK_TYPE_NB_IOT_NTN)
+ String networkTypeName = IntStream.rangeClosed(NETWORK_TYPE_GPRS, NETWORK_TYPE_NR)
.filter(x -> {
return (networkTypeBitmask & getBitMaskForNetworkType(x))
== getBitMaskForNetworkType(x);
@@ -14053,6 +14036,7 @@ public class TelephonyManager {
* @hide
*/
@SystemApi
+ @Deprecated
@RequiresPermission(android.Manifest.permission.MODIFY_PHONE_STATE)
@RequiresFeature(PackageManager.FEATURE_TELEPHONY_CARRIERLOCK)
public int setAllowedCarriers(int slotIndex, List<CarrierIdentifier> carriers) {
@@ -15140,8 +15124,7 @@ public class TelephonyManager {
NETWORK_TYPE_BITMASK_LTE_CA,
NETWORK_TYPE_BITMASK_NR,
NETWORK_TYPE_BITMASK_IWLAN,
- NETWORK_TYPE_BITMASK_IDEN,
- NETWORK_TYPE_BITMASK_NB_IOT_NTN
+ NETWORK_TYPE_BITMASK_IDEN
})
public @interface NetworkTypeBitMask {}
@@ -15248,12 +15231,6 @@ public class TelephonyManager {
*/
public static final long NETWORK_TYPE_BITMASK_IWLAN = (1 << (NETWORK_TYPE_IWLAN -1));
- /**
- * network type bitmask indicating the support of readio tech NB IOT NTN.
- */
- @FlaggedApi(Flags.FLAG_SATELLITE_SYSTEM_APIS)
- public static final long NETWORK_TYPE_BITMASK_NB_IOT_NTN = (1 << (NETWORK_TYPE_NB_IOT_NTN - 1));
-
/** @hide */
public static final long NETWORK_CLASS_BITMASK_2G = NETWORK_TYPE_BITMASK_GSM
| NETWORK_TYPE_BITMASK_GPRS
@@ -15282,9 +15259,6 @@ public class TelephonyManager {
public static final long NETWORK_CLASS_BITMASK_5G = NETWORK_TYPE_BITMASK_NR;
/** @hide */
- public static final long NETWORK_CLASS_BITMASK_NTN = NETWORK_TYPE_BITMASK_NB_IOT_NTN;
-
- /** @hide */
public static final long NETWORK_STANDARDS_FAMILY_BITMASK_3GPP = NETWORK_TYPE_BITMASK_GSM
| NETWORK_TYPE_BITMASK_GPRS
| NETWORK_TYPE_BITMASK_EDGE
@@ -15296,8 +15270,7 @@ public class TelephonyManager {
| NETWORK_TYPE_BITMASK_TD_SCDMA
| NETWORK_TYPE_BITMASK_LTE
| NETWORK_TYPE_BITMASK_LTE_CA
- | NETWORK_TYPE_BITMASK_NR
- | NETWORK_TYPE_BITMASK_NB_IOT_NTN;
+ | NETWORK_TYPE_BITMASK_NR;
/** @hide
* @deprecated Legacy CDMA is unsupported.
@@ -18338,7 +18311,7 @@ public class TelephonyManager {
*/
public static boolean isNetworkTypeValid(@NetworkType int networkType) {
return networkType >= TelephonyManager.NETWORK_TYPE_UNKNOWN &&
- networkType <= TelephonyManager.NETWORK_TYPE_NB_IOT_NTN;
+ networkType <= TelephonyManager.NETWORK_TYPE_NR;
}
/**
diff --git a/tests/FlickerTests/Android.bp b/tests/FlickerTests/Android.bp
index f44eacbaafbf..1e997b386faa 100644
--- a/tests/FlickerTests/Android.bp
+++ b/tests/FlickerTests/Android.bp
@@ -41,7 +41,6 @@ java_defaults {
"platform-test-annotations",
"wm-flicker-common-app-helpers",
"wm-shell-flicker-utils",
- "systemui-tapl",
],
data: [":FlickerTestApp"],
}
diff --git a/tests/FlickerTests/Notification/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTest.kt b/tests/FlickerTests/Notification/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTest.kt
index da90c4f624d2..ad70757a9a4d 100644
--- a/tests/FlickerTests/Notification/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTest.kt
+++ b/tests/FlickerTests/Notification/src/com/android/server/wm/flicker/notification/OpenAppFromNotificationWarmTest.kt
@@ -16,8 +16,6 @@
package com.android.server.wm.flicker.notification
-import android.platform.systemui_tapl.controller.NotificationIdentity
-import android.platform.systemui_tapl.ui.Root
import android.platform.test.annotations.Postsubmit
import android.platform.test.annotations.Presubmit
import android.platform.test.rule.DisableNotificationCooldownSettingRule
@@ -30,6 +28,8 @@ import android.tools.helpers.wakeUpAndGoToHomeScreen
import android.tools.traces.component.ComponentNameMatcher
import android.view.WindowInsets
import android.view.WindowManager
+import androidx.test.uiautomator.By
+import androidx.test.uiautomator.Until
import com.android.server.wm.flicker.helpers.NotificationAppHelper
import com.android.server.wm.flicker.helpers.setRotation
import com.android.server.wm.flicker.navBarLayerIsVisibleAtEnd
@@ -87,9 +87,8 @@ open class OpenAppFromNotificationWarmTest(flicker: LegacyFlickerTest) :
.withWindowSurfaceDisappeared(ComponentNameMatcher.NOTIFICATION_SHADE)
.waitForAndVerify()
}
-
protected fun FlickerTestData.openAppFromNotification() {
- doOpenAppAndWait()
+ doOpenAppAndWait(startY = 10, endY = 3 * device.displayHeight / 4, steps = 25)
}
protected fun FlickerTestData.openAppFromLockNotification() {
@@ -102,27 +101,25 @@ open class OpenAppFromNotificationWarmTest(flicker: LegacyFlickerTest) :
WindowInsets.Type.statusBars() or WindowInsets.Type.displayCutout()
)
- doOpenAppAndWait()
+ doOpenAppAndWait(startY = insets.top + 100, endY = device.displayHeight / 2, steps = 4)
}
- protected fun FlickerTestData.doOpenAppAndWait() {
- val shade = Root.get().openNotificationShade()
+ protected fun FlickerTestData.doOpenAppAndWait(startY: Int, endY: Int, steps: Int) {
+ // Swipe down to show the notification shade
+ val x = device.displayWidth / 2
+ device.swipe(x, startY, x, endY, steps)
+ device.waitForIdle(2000)
+ instrumentation.uiAutomation.syncInputTransactions()
// Launch the activity by clicking the notification
- // Post notification and ensure that it's collapsed
val notification =
- shade.notificationStack.findNotification(
- NotificationIdentity(
- type = NotificationIdentity.Type.BY_TEXT,
- text = "Flicker Test Notification",
- )
- )
+ device.wait(Until.findObject(By.text("Flicker Test Notification")), 2000L)
+ notification?.click() ?: error("Notification not found")
+ instrumentation.uiAutomation.syncInputTransactions()
- notification.clickToApp()
// Wait for the app to launch
wmHelper.StateSyncBuilder().withFullScreenApp(testApp).waitForAndVerify()
}
-
@Presubmit @Test override fun appWindowBecomesVisible() = appWindowBecomesVisible_warmStart()
@Presubmit @Test override fun appLayerBecomesVisible() = appLayerBecomesVisible_warmStart()