summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Android.bp6
-rw-r--r--api/current.txt18
-rw-r--r--api/test-current.txt26
-rw-r--r--cmds/statsd/statsd.rc3
-rwxr-xr-xconfig/generate-preloaded-classes.sh2
-rw-r--r--config/hiddenapi-light-greylist.txt20
-rw-r--r--config/preloaded-classes4
-rw-r--r--core/java/android/accounts/ChooseAccountActivity.java5
-rw-r--r--core/java/android/accounts/ChooseTypeAndAccountActivity.java5
-rw-r--r--core/java/android/app/Activity.java94
-rw-r--r--core/java/android/app/ActivityManager.java256
-rw-r--r--core/java/android/app/ActivityOptions.java2
-rw-r--r--core/java/android/app/ActivityTaskManager.java253
-rw-r--r--core/java/android/app/ActivityThread.java28
-rw-r--r--core/java/android/app/ActivityView.java8
-rw-r--r--core/java/android/app/AlarmManager.java3
-rw-r--r--core/java/android/app/ContextImpl.java4
-rw-r--r--core/java/android/app/Dialog.java5
-rw-r--r--core/java/android/app/IActivityManager.aidl219
-rw-r--r--core/java/android/app/IActivityTaskManager.aidl418
-rw-r--r--core/java/android/app/IApplicationThread.aidl3
-rw-r--r--core/java/android/app/Instrumentation.java10
-rw-r--r--core/java/android/app/KeyguardManager.java3
-rw-r--r--core/java/android/app/Notification.java67
-rw-r--r--core/java/android/app/SearchManager.java2
-rw-r--r--core/java/android/app/StatusBarManager.java6
-rw-r--r--core/java/android/app/SystemServiceRegistry.java8
-rw-r--r--core/java/android/app/WallpaperColors.java28
-rw-r--r--core/java/android/app/admin/DevicePolicyManager.java4
-rw-r--r--core/java/android/app/backup/BackupManager.java23
-rw-r--r--core/java/android/app/servertransaction/PauseActivityItem.java3
-rw-r--r--core/java/android/app/servertransaction/PendingTransactionActions.java3
-rw-r--r--core/java/android/app/servertransaction/ResumeActivityItem.java3
-rw-r--r--core/java/android/app/timedetector/ITimeDetectorService.aidl4
-rw-r--r--core/java/android/app/timedetector/TimeDetector.java12
-rw-r--r--core/java/android/app/timedetector/TimeSignal.aidl19
-rw-r--r--core/java/android/app/timedetector/TimeSignal.java110
-rw-r--r--core/java/android/bluetooth/le/ScanRecord.java2
-rw-r--r--core/java/android/content/Context.java10
-rw-r--r--core/java/android/content/Intent.java37
-rw-r--r--core/java/android/content/pm/IPackageManager.aidl2
-rw-r--r--core/java/android/content/pm/PackageManager.java13
-rw-r--r--core/java/android/content/pm/PackageParser.java23
-rw-r--r--core/java/android/content/pm/PackageUserState.java4
-rw-r--r--core/java/android/net/ConnectivityManager.java54
-rw-r--r--core/java/android/net/LinkProperties.java187
-rw-r--r--core/java/android/net/Network.java16
-rw-r--r--core/java/android/os/Build.java6
-rw-r--r--core/java/android/os/ParcelFileDescriptor.aidl2
-rw-r--r--core/java/android/os/UserManager.java6
-rw-r--r--core/java/android/provider/Settings.java17
-rw-r--r--core/java/android/service/autofill/TextValueSanitizer.java2
-rw-r--r--core/java/android/text/StaticLayout.java38
-rw-r--r--core/java/android/util/FeatureFlagUtils.java1
-rw-r--r--core/java/android/util/TimestampedValue.java121
-rw-r--r--core/java/android/view/View.java34
-rw-r--r--core/java/android/view/ViewRootImpl.java5
-rw-r--r--core/java/android/view/accessibility/AccessibilityEvent.java13
-rw-r--r--core/java/android/view/autofill/AutofillManager.java27
-rw-r--r--core/java/android/view/autofill/IAutoFillManager.aidl4
-rw-r--r--core/java/android/widget/Editor.java1
-rw-r--r--core/java/android/widget/RemoteViews.java4
-rw-r--r--core/java/android/widget/SpellChecker.java5
-rw-r--r--core/java/com/android/internal/app/HeavyWeightSwitcherActivity.java3
-rw-r--r--core/java/com/android/internal/app/IntentForwarderActivity.java5
-rw-r--r--core/java/com/android/internal/app/ResolverActivity.java5
-rw-r--r--core/java/com/android/internal/policy/PhoneWindow.java7
-rw-r--r--core/java/com/android/internal/util/ContrastColorUtil.java (renamed from core/java/com/android/internal/util/NotificationColorUtil.java)24
-rw-r--r--core/java/com/android/internal/widget/MessagingLayout.java6
-rw-r--r--core/java/com/android/internal/widget/PointerLocationView.java49
-rw-r--r--core/jni/AndroidRuntime.cpp5
-rw-r--r--core/jni/android_text_StaticLayout.cpp9
-rw-r--r--core/proto/android/providers/settings/global.proto13
-rw-r--r--core/res/AndroidManifest.xml22
-rw-r--r--core/res/res/drawable-watch/toast_frame.xml24
-rw-r--r--core/res/res/layout-watch/transient_notification.xml37
-rw-r--r--core/res/res/values-w210dp-round-watch/styles.xml22
-rw-r--r--core/res/res/values-watch/config.xml3
-rw-r--r--core/res/res/values-watch/dimens.xml2
-rw-r--r--core/res/res/values-watch/styles.xml22
-rw-r--r--core/res/res/values/strings.xml36
-rw-r--r--core/tests/coretests/src/android/app/NotificationTest.java2
-rw-r--r--core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java3
-rw-r--r--core/tests/coretests/src/android/provider/DocumentsProviderTest.java6
-rw-r--r--core/tests/coretests/src/android/provider/SettingsBackupTest.java4
-rw-r--r--core/tests/coretests/src/android/util/TimestampedValueTest.java119
-rw-r--r--data/etc/platform.xml1
-rw-r--r--data/sounds/AllAudio.mk3
-rw-r--r--data/sounds/AudioPackage10.mk2
-rw-r--r--data/sounds/AudioPackage11.mk2
-rw-r--r--data/sounds/AudioPackage12.mk2
-rw-r--r--data/sounds/AudioPackage12_48.mk2
-rw-r--r--data/sounds/AudioPackage13.mk2
-rw-r--r--data/sounds/AudioPackage13_48.mk2
-rw-r--r--data/sounds/effects/ChargingStarted.oggbin0 -> 33370 bytes
-rw-r--r--data/sounds/effects/ogg/ChargingStarted.oggbin0 -> 33370 bytes
-rw-r--r--data/sounds/effects/ogg/ChargingStarted_48k.oggbin0 -> 33370 bytes
-rw-r--r--data/sounds/effects/ogg/InCallNotification_48k.oggbin0 -> 6275 bytes
-rw-r--r--graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java2
-rw-r--r--keystore/java/android/security/KeyStore.java19
-rw-r--r--libs/androidfw/ResourceTypes.cpp10
-rw-r--r--media/java/android/media/MediaTimestamp.java10
-rw-r--r--packages/CaptivePortalLogin/AndroidManifest.xml2
-rw-r--r--packages/SettingsLib/res/layout/preference_dropdown_material_settings.xml35
-rw-r--r--packages/SettingsLib/res/values/styles_support_preference.xml72
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java76
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java8
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothManager.java12
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java12
-rw-r--r--packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java4
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/SettingsLibRobolectricTestRunner.java2
-rw-r--r--packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java18
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java9
-rw-r--r--packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java12
-rw-r--r--packages/SystemUI/res/drawable-nodpi/icon.xml31
-rw-r--r--packages/SystemUI/res/drawable-nodpi/icon_bg.xml18
-rw-r--r--packages/SystemUI/res/drawable-nodpi/p.xml33
-rw-r--r--packages/SystemUI/res/drawable/ic_qs_auto_rotate.xml2
-rw-r--r--packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml12
-rw-r--r--packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml2
-rw-r--r--packages/SystemUI/res/layout/car_qs_panel.xml2
-rw-r--r--packages/SystemUI/res/values-land/dimens.xml2
-rw-r--r--packages/SystemUI/res/values/dimens.xml7
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/RecentsTaskLoadPlan.java3
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/RecentsTaskLoader.java7
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java21
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java4
-rw-r--r--packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java3
-rw-r--r--packages/SystemUI/src/com/android/keyguard/CarrierText.java6
-rw-r--r--packages/SystemUI/src/com/android/keyguard/EmergencyButton.java3
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java2
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java19
-rw-r--r--packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/BatteryMeterView.java13
-rw-r--r--packages/SystemUI/src/com/android/systemui/ScreenDecorations.java15
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java19
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java24
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/phone/PipUtils.java5
-rw-r--r--packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java24
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/qs/tiles/NightDisplayTile.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java26
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/DockState.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/recents/views/TaskViewAccessibilityDelegate.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java9
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationBlockingHelperManager.java17
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java22
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java20
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java4
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationUtils.java7
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java13
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java45
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java3
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java14
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java6
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java8
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java11
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java1
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java36
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java2
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java26
-rw-r--r--packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java10
-rw-r--r--packages/SystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java9
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java15
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/recents/RecentsTest.java12
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationBlockingHelperManagerTest.java19
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java21
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsManagerTest.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java8
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java4
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java12
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java8
-rw-r--r--packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java11
-rw-r--r--services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java15
-rw-r--r--services/accessibility/java/com/android/server/accessibility/AccessibilityServiceConnection.java5
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerService.java24
-rw-r--r--services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java6
-rw-r--r--services/autofill/java/com/android/server/autofill/FieldClassificationStrategy.java10
-rw-r--r--services/autofill/java/com/android/server/autofill/Helper.java5
-rw-r--r--services/autofill/java/com/android/server/autofill/RemoteFillService.java11
-rw-r--r--services/autofill/java/com/android/server/autofill/Session.java35
-rw-r--r--services/autofill/java/com/android/server/autofill/ui/FillUi.java5
-rw-r--r--services/backup/java/com/android/server/backup/internal/PerformInitializeTask.java9
-rw-r--r--services/core/java/com/android/server/AlarmManagerService.java9
-rw-r--r--services/core/java/com/android/server/ConnectivityService.java325
-rw-r--r--services/core/java/com/android/server/IpSecService.java26
-rw-r--r--services/core/java/com/android/server/StorageManagerService.java8
-rw-r--r--services/core/java/com/android/server/UiModeManagerService.java5
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerService.java3080
-rw-r--r--services/core/java/com/android/server/am/ActivityManagerShellCommand.java87
-rw-r--r--services/core/java/com/android/server/am/ActivityRecord.java6
-rw-r--r--services/core/java/com/android/server/am/ActivityStack.java14
-rw-r--r--services/core/java/com/android/server/am/ActivityStackSupervisor.java50
-rw-r--r--services/core/java/com/android/server/am/ActivityStarter.java3
-rw-r--r--services/core/java/com/android/server/am/ActivityTaskManagerService.java3330
-rw-r--r--services/core/java/com/android/server/am/AppErrors.java2
-rw-r--r--services/core/java/com/android/server/am/AssistDataRequester.java10
-rw-r--r--services/core/java/com/android/server/am/LaunchParamsController.java2
-rw-r--r--services/core/java/com/android/server/am/LockTaskController.java4
-rw-r--r--services/core/java/com/android/server/am/PinnedActivityStack.java2
-rw-r--r--services/core/java/com/android/server/am/RecentTasks.java5
-rw-r--r--services/core/java/com/android/server/am/TaskRecord.java15
-rw-r--r--services/core/java/com/android/server/audio/AudioService.java4
-rw-r--r--services/core/java/com/android/server/connectivity/PacManager.java22
-rw-r--r--services/core/java/com/android/server/connectivity/ProxyTracker.java184
-rw-r--r--services/core/java/com/android/server/display/BrightnessTracker.java3
-rw-r--r--services/core/java/com/android/server/display/DisplayTransformManager.java3
-rw-r--r--services/core/java/com/android/server/fingerprint/FingerprintService.java12
-rw-r--r--services/core/java/com/android/server/location/GnssLocationProvider.java4
-rw-r--r--services/core/java/com/android/server/media/MediaSessionService.java3
-rw-r--r--services/core/java/com/android/server/notification/NotificationManagerService.java60
-rw-r--r--services/core/java/com/android/server/pm/InstantAppResolver.java7
-rw-r--r--services/core/java/com/android/server/pm/PackageManagerService.java191
-rw-r--r--services/core/java/com/android/server/pm/ShortcutService.java24
-rw-r--r--services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java10
-rw-r--r--services/core/java/com/android/server/policy/PhoneWindowManager.java11
-rw-r--r--services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java3
-rw-r--r--services/core/java/com/android/server/power/PowerManagerService.java6
-rw-r--r--services/core/java/com/android/server/search/SearchManagerService.java4
-rw-r--r--services/core/java/com/android/server/timedetector/SimpleTimeDetectorStrategy.java57
-rw-r--r--services/core/java/com/android/server/timedetector/TimeDetectorService.java40
-rw-r--r--services/core/java/com/android/server/timedetector/TimeDetectorStrategy.java53
-rw-r--r--services/core/java/com/android/server/timedetector/TimeDetectorStrategyCallbackImpl.java58
-rw-r--r--services/core/java/com/android/server/wm/AppWindowToken.java14
-rw-r--r--services/core/java/com/android/server/wm/DisplayContent.java2
-rw-r--r--services/core/java/com/android/server/wm/DragAndDropPermissionsHandler.java5
-rw-r--r--services/core/java/com/android/server/wm/PinnedStackController.java2
-rw-r--r--services/core/java/com/android/server/wm/Task.java8
-rw-r--r--services/core/java/com/android/server/wm/TaskPositioner.java11
-rw-r--r--services/core/java/com/android/server/wm/TaskPositioningController.java5
-rw-r--r--services/core/java/com/android/server/wm/TaskSnapshotController.java9
-rw-r--r--services/core/java/com/android/server/wm/TaskStack.java12
-rw-r--r--services/core/java/com/android/server/wm/WindowManagerService.java21
-rw-r--r--services/core/java/com/android/server/wm/WindowState.java6
-rw-r--r--services/core/jni/com_android_server_AlarmManagerService.cpp29
-rw-r--r--services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java116
-rw-r--r--services/java/com/android/server/SystemServer.java17
-rw-r--r--services/robotests/src/com/android/server/backup/internal/PerformInitializeTaskTest.java32
-rw-r--r--services/robotests/src/com/android/server/backup/testing/TestUtils.java5
-rw-r--r--services/robotests/src/com/android/server/testing/shadows/ShadowSlog.java80
-rw-r--r--services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java2
-rw-r--r--services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java16
-rw-r--r--services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java11
-rw-r--r--services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java4
-rw-r--r--services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java69
-rw-r--r--services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java5
-rw-r--r--services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceTestable.java6
-rw-r--r--services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java4
-rw-r--r--services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java3
-rw-r--r--services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeZoneDetectorStrategyTest.java68
-rw-r--r--services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java58
-rw-r--r--services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorStrategyTest.java46
-rw-r--r--services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java3
-rw-r--r--services/usage/java/com/android/server/usage/UsageStatsService.java2
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java9
-rw-r--r--services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java5
-rw-r--r--telecomm/java/android/telecom/ConnectionService.java12
-rw-r--r--telephony/java/android/telephony/data/ApnSetting.java669
-rw-r--r--telephony/java/com/android/internal/telephony/CarrierAppUtils.java37
-rw-r--r--telephony/java/com/android/internal/telephony/uicc/IccUtils.java8
-rw-r--r--tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java6
-rw-r--r--tests/net/java/com/android/server/IpSecServiceParameterizedTest.java2
-rw-r--r--tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java13
-rw-r--r--tools/aapt2/ResourceParser.cpp3
-rw-r--r--tools/aapt2/ResourceParser_test.cpp18
-rw-r--r--tools/aapt2/java/ProguardRules.cpp15
-rw-r--r--tools/aapt2/java/ProguardRules.h25
-rw-r--r--tools/aapt2/java/ProguardRules_test.cpp85
-rw-r--r--tools/apilint/apilint.py64
-rwxr-xr-xtools/apilint/apilint_stats.sh7
-rw-r--r--tools/stats_log_api_gen/Android.bp1
-rw-r--r--tools/stats_log_api_gen/main.cpp12
293 files changed, 8096 insertions, 5339 deletions
diff --git a/Android.bp b/Android.bp
index b50593dfcd22..e9fb93e2decb 100644
--- a/Android.bp
+++ b/Android.bp
@@ -58,6 +58,7 @@ java_library {
"core/java/android/app/IActivityController.aidl",
"core/java/android/app/IActivityManager.aidl",
"core/java/android/app/IActivityPendingResult.aidl",
+ "core/java/android/app/IActivityTaskManager.aidl",
"core/java/android/app/IAlarmCompleteListener.aidl",
"core/java/android/app/IAlarmListener.aidl",
"core/java/android/app/IAlarmManager.aidl",
@@ -1223,11 +1224,6 @@ metalava_framework_docs_args = "--manifest $(location core/res/AndroidManifest.x
doc_defaults {
name: "metalava-framework-docs-default",
srcs: [
- // test mock src files.
- "test-mock/src/android/test/mock/**/*.java",
- // test runner excluding mock src files.
- "test-runner/src/**/*.java",
- "test-base/src/**/*.java",
":opt-telephony-srcs",
":opt-net-voip-srcs",
":openjdk_javadoc_files",
diff --git a/api/current.txt b/api/current.txt
index 04a49415f923..13d8e7ae0fbc 100644
--- a/api/current.txt
+++ b/api/current.txt
@@ -20869,6 +20869,7 @@ package android.icu.util {
field public static final android.icu.util.MeasureUnit PICOMETER;
field public static final android.icu.util.MeasureUnit PINT;
field public static final android.icu.util.MeasureUnit PINT_METRIC;
+ field public static final android.icu.util.MeasureUnit POINT;
field public static final android.icu.util.MeasureUnit POUND;
field public static final android.icu.util.MeasureUnit POUND_PER_SQUARE_INCH;
field public static final android.icu.util.MeasureUnit QUART;
@@ -24499,7 +24500,8 @@ package android.media {
public final class MediaTimestamp {
method public long getAnchorMediaTimeUs();
- method public long getAnchorSytemNanoTime();
+ method public long getAnchorSystemNanoTime();
+ method public deprecated long getAnchorSytemNanoTime();
method public float getMediaClockRate();
field public static final android.media.MediaTimestamp TIMESTAMP_UNKNOWN;
}
@@ -42721,7 +42723,8 @@ package android.telephony.data {
method public int getAuthType();
method public java.lang.String getEntryName();
method public int getId();
- method public java.net.InetAddress getMmsProxyAddress();
+ method public deprecated java.net.InetAddress getMmsProxyAddress();
+ method public java.lang.String getMmsProxyAddressAsString();
method public int getMmsProxyPort();
method public android.net.Uri getMmsc();
method public int getMvnoType();
@@ -42729,7 +42732,8 @@ package android.telephony.data {
method public java.lang.String getOperatorNumeric();
method public java.lang.String getPassword();
method public int getProtocol();
- method public java.net.InetAddress getProxyAddress();
+ method public deprecated java.net.InetAddress getProxyAddress();
+ method public java.lang.String getProxyAddressAsString();
method public int getProxyPort();
method public int getRoamingProtocol();
method public java.lang.String getUser();
@@ -42749,7 +42753,7 @@ package android.telephony.data {
field public static final int PROTOCOL_IPV6 = 1; // 0x1
field public static final int PROTOCOL_PPP = 3; // 0x3
field public static final int TYPE_CBS = 128; // 0x80
- field public static final int TYPE_DEFAULT = 17; // 0x11
+ field public static final int TYPE_DEFAULT = 1; // 0x1
field public static final int TYPE_DUN = 8; // 0x8
field public static final int TYPE_EMERGENCY = 512; // 0x200
field public static final int TYPE_FOTA = 32; // 0x20
@@ -42768,7 +42772,8 @@ package android.telephony.data {
method public android.telephony.data.ApnSetting.Builder setAuthType(int);
method public android.telephony.data.ApnSetting.Builder setCarrierEnabled(boolean);
method public android.telephony.data.ApnSetting.Builder setEntryName(java.lang.String);
- method public android.telephony.data.ApnSetting.Builder setMmsProxyAddress(java.net.InetAddress);
+ method public deprecated android.telephony.data.ApnSetting.Builder setMmsProxyAddress(java.net.InetAddress);
+ method public android.telephony.data.ApnSetting.Builder setMmsProxyAddress(java.lang.String);
method public android.telephony.data.ApnSetting.Builder setMmsProxyPort(int);
method public android.telephony.data.ApnSetting.Builder setMmsc(android.net.Uri);
method public android.telephony.data.ApnSetting.Builder setMvnoType(int);
@@ -42776,7 +42781,8 @@ package android.telephony.data {
method public android.telephony.data.ApnSetting.Builder setOperatorNumeric(java.lang.String);
method public android.telephony.data.ApnSetting.Builder setPassword(java.lang.String);
method public android.telephony.data.ApnSetting.Builder setProtocol(int);
- method public android.telephony.data.ApnSetting.Builder setProxyAddress(java.net.InetAddress);
+ method public deprecated android.telephony.data.ApnSetting.Builder setProxyAddress(java.net.InetAddress);
+ method public android.telephony.data.ApnSetting.Builder setProxyAddress(java.lang.String);
method public android.telephony.data.ApnSetting.Builder setProxyPort(int);
method public android.telephony.data.ApnSetting.Builder setRoamingProtocol(int);
method public android.telephony.data.ApnSetting.Builder setUser(java.lang.String);
diff --git a/api/test-current.txt b/api/test-current.txt
index 9be252f92831..e589f1eab051 100644
--- a/api/test-current.txt
+++ b/api/test-current.txt
@@ -30,25 +30,12 @@ package android.app {
method public long getTotalRam();
method public int getUidImportance(int);
method public void removeOnUidImportanceListener(android.app.ActivityManager.OnUidImportanceListener);
- method public void removeStacksInWindowingModes(int[]) throws java.lang.SecurityException;
- method public void removeStacksWithActivityTypes(int[]) throws java.lang.SecurityException;
- method public void resizeStack(int, android.graphics.Rect) throws java.lang.SecurityException;
- method public void setTaskWindowingMode(int, int, boolean) throws java.lang.SecurityException;
- method public void setTaskWindowingModeSplitScreenPrimary(int, int, boolean, boolean, android.graphics.Rect, boolean) throws java.lang.SecurityException;
- method public static boolean supportsMultiWindow(android.content.Context);
- method public static boolean supportsSplitScreenMultiWindow(android.content.Context);
- field public static final int SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT = 1; // 0x1
- field public static final int SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT = 0; // 0x0
}
public static abstract interface ActivityManager.OnUidImportanceListener {
method public abstract void onUidImportance(int, int);
}
- public static class ActivityManager.StackId {
- field public static final int INVALID_STACK_ID = -1; // 0xffffffff
- }
-
public static class ActivityManager.TaskDescription implements android.os.Parcelable {
method public java.lang.String getIconFilename();
method public int getIconResource();
@@ -61,6 +48,19 @@ package android.app {
method public void setTaskOverlay(boolean, boolean);
}
+ public class ActivityTaskManager {
+ method public void removeStacksInWindowingModes(int[]) throws java.lang.SecurityException;
+ method public void removeStacksWithActivityTypes(int[]) throws java.lang.SecurityException;
+ method public void resizeStack(int, android.graphics.Rect) throws java.lang.SecurityException;
+ method public void setTaskWindowingMode(int, int, boolean) throws java.lang.SecurityException;
+ method public void setTaskWindowingModeSplitScreenPrimary(int, int, boolean, boolean, android.graphics.Rect, boolean) throws java.lang.SecurityException;
+ method public static boolean supportsMultiWindow(android.content.Context);
+ method public static boolean supportsSplitScreenMultiWindow(android.content.Context);
+ field public static final int INVALID_STACK_ID = -1; // 0xffffffff
+ field public static final int SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT = 1; // 0x1
+ field public static final int SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT = 0; // 0x0
+ }
+
public class AppOpsManager {
method public static int getNumOps();
method public static java.lang.String[] getOpStrs();
diff --git a/cmds/statsd/statsd.rc b/cmds/statsd/statsd.rc
index f3492920940d..cbf2a8d5383d 100644
--- a/cmds/statsd/statsd.rc
+++ b/cmds/statsd/statsd.rc
@@ -19,6 +19,9 @@ service statsd /system/bin/statsd
group statsd log
writepid /dev/cpuset/system-background/tasks
+on property:ro.statsd.enable=false
+ stop statsd
+
on post-fs-data
# Create directory for statsd
mkdir /data/misc/stats-data/ 0770 statsd system
diff --git a/config/generate-preloaded-classes.sh b/config/generate-preloaded-classes.sh
index e36e148c7476..0ad3a0263d95 100755
--- a/config/generate-preloaded-classes.sh
+++ b/config/generate-preloaded-classes.sh
@@ -36,4 +36,4 @@ shift 2
extra_classes_files=("$@")
# Disable locale to enable lexicographical sorting
-LC_ALL=C sort "$input" "${extra_classes_files[@]}" | uniq | grep -f "$blacklist" -v -F -x
+LC_ALL=C sort "$input" "${extra_classes_files[@]}" | uniq | grep -f "$blacklist" -v -F -x | grep -v "\$NoPreloadHolder"
diff --git a/config/hiddenapi-light-greylist.txt b/config/hiddenapi-light-greylist.txt
index 7e57f3cd4c26..ab6150f4e8c7 100644
--- a/config/hiddenapi-light-greylist.txt
+++ b/config/hiddenapi-light-greylist.txt
@@ -170,6 +170,7 @@ Landroid/app/ActivityManagerNative;->getDefault()Landroid/app/IActivityManager;
Landroid/app/ActivityManagerNative;->isSystemReady()Z
Landroid/app/ActivityOptions;->makeCustomAnimation(Landroid/content/Context;IILandroid/os/Handler;Landroid/app/ActivityOptions$OnAnimationStartedListener;)Landroid/app/ActivityOptions;
Landroid/app/ActivityOptions;->makeMultiThumbFutureAspectScaleAnimation(Landroid/content/Context;Landroid/os/Handler;Landroid/view/IAppTransitionAnimationSpecsFuture;Landroid/app/ActivityOptions$OnAnimationStartedListener;Z)Landroid/app/ActivityOptions;
+Landroid/app/ActivityThread$ActivityClientRecord;-><init>()V
Landroid/app/ActivityThread$ActivityClientRecord;->activity:Landroid/app/Activity;
Landroid/app/ActivityThread$ActivityClientRecord;->activityInfo:Landroid/content/pm/ActivityInfo;
Landroid/app/ActivityThread$ActivityClientRecord;->compatInfo:Landroid/content/res/CompatibilityInfo;
@@ -179,6 +180,7 @@ Landroid/app/ActivityThread$ActivityClientRecord;->packageInfo:Landroid/app/Load
Landroid/app/ActivityThread$ActivityClientRecord;->paused:Z
Landroid/app/ActivityThread$ActivityClientRecord;->stopped:Z
Landroid/app/ActivityThread$ActivityClientRecord;->token:Landroid/os/IBinder;
+Landroid/app/ActivityThread$AppBindData;-><init>()V
Landroid/app/ActivityThread$AppBindData;->appInfo:Landroid/content/pm/ApplicationInfo;
Landroid/app/ActivityThread$AppBindData;->compatInfo:Landroid/content/res/CompatibilityInfo;
Landroid/app/ActivityThread$AppBindData;->info:Landroid/app/LoadedApk;
@@ -500,6 +502,7 @@ Landroid/app/ContentProviderHolder;-><init>(Landroid/os/Parcel;)V
Landroid/app/ContentProviderHolder;->info:Landroid/content/pm/ProviderInfo;
Landroid/app/ContentProviderHolder;->noReleaseNeeded:Z
Landroid/app/ContentProviderHolder;->provider:Landroid/content/IContentProvider;
+Landroid/app/ContextImpl$ApplicationContentResolver;->acquireProvider(Landroid/content/Context;Ljava/lang/String;)Landroid/content/IContentProvider;
Landroid/app/ContextImpl$ApplicationContentResolver;->mMainThread:Landroid/app/ActivityThread;
Landroid/app/ContextImpl;->createActivityContext(Landroid/app/ActivityThread;Landroid/app/LoadedApk;Landroid/content/pm/ActivityInfo;Landroid/os/IBinder;ILandroid/content/res/Configuration;)Landroid/app/ContextImpl;
Landroid/app/ContextImpl;->createAppContext(Landroid/app/ActivityThread;Landroid/app/LoadedApk;)Landroid/app/ContextImpl;
@@ -583,6 +586,7 @@ Landroid/app/IActivityManager$Stub$Proxy;->getProcessPss([I)[J
Landroid/app/IActivityManager$Stub$Proxy;->isAppForeground(I)Z
Landroid/app/IActivityManager$Stub$Proxy;->mRemote:Landroid/os/IBinder;
Landroid/app/IActivityManager$Stub$Proxy;->setActivityController(Landroid/app/IActivityController;Z)V
+Landroid/app/IActivityManager$Stub$Proxy;->updatePersistentConfiguration(Landroid/content/res/Configuration;)V
Landroid/app/IActivityManager$Stub;->asInterface(Landroid/os/IBinder;)Landroid/app/IActivityManager;
Landroid/app/IActivityManager;->bindService(Landroid/app/IApplicationThread;Landroid/os/IBinder;Landroid/content/Intent;Ljava/lang/String;Landroid/app/IServiceConnection;ILjava/lang/String;I)I
Landroid/app/IActivityManager;->broadcastIntent(Landroid/app/IApplicationThread;Landroid/content/Intent;Ljava/lang/String;Landroid/content/IIntentReceiver;ILjava/lang/String;Landroid/os/Bundle;[Ljava/lang/String;ILandroid/os/Bundle;ZZI)I
@@ -876,8 +880,10 @@ Landroid/app/ProgressDialog;->mProgress:Landroid/widget/ProgressBar;
Landroid/app/ProgressDialog;->mProgressNumber:Landroid/widget/TextView;
Landroid/app/QueuedWork;->addFinisher(Ljava/lang/Runnable;)V
Landroid/app/QueuedWork;->getHandler()Landroid/os/Handler;
+Landroid/app/QueuedWork;->queue(Ljava/lang/Runnable;Z)V
Landroid/app/QueuedWork;->removeFinisher(Ljava/lang/Runnable;)V
Landroid/app/QueuedWork;->sFinishers:Ljava/util/LinkedList;
+Landroid/app/ResourcesManager$ActivityResources;-><init>()V
Landroid/app/ResourcesManager;-><init>()V
Landroid/app/ResourcesManager;->appendLibAssetForMainAssetPath(Ljava/lang/String;Ljava/lang/String;)V
Landroid/app/ResourcesManager;->createAssetManager(Landroid/content/res/ResourcesKey;)Landroid/content/res/AssetManager;
@@ -894,6 +900,7 @@ Landroid/app/ResultInfo;->mResultWho:Ljava/lang/String;
Landroid/app/SearchableInfo$ActionKeyInfo;->getQueryActionMsg()Ljava/lang/String;
Landroid/app/SearchableInfo$ActionKeyInfo;->getSuggestActionMsg()Ljava/lang/String;
Landroid/app/SearchableInfo$ActionKeyInfo;->getSuggestActionMsgColumn()Ljava/lang/String;
+Landroid/app/SearchableInfo;-><init>(Landroid/content/Context;Landroid/util/AttributeSet;Landroid/content/ComponentName;)V
Landroid/app/SearchableInfo;->findActionKey(I)Landroid/app/SearchableInfo$ActionKeyInfo;
Landroid/app/SearchableInfo;->getActivityContext(Landroid/content/Context;)Landroid/content/Context;
Landroid/app/SearchableInfo;->getIconId()I
@@ -1344,6 +1351,7 @@ Landroid/content/Context;->sendOrderedBroadcastAsUser(Landroid/content/Intent;La
Landroid/content/Context;->startActivityAsUser(Landroid/content/Intent;Landroid/os/Bundle;Landroid/os/UserHandle;)V
Landroid/content/Context;->startActivityForResult(Ljava/lang/String;Landroid/content/Intent;ILandroid/os/Bundle;)V
Landroid/content/Context;->STATUS_BAR_SERVICE:Ljava/lang/String;
+Landroid/content/ContextWrapper;->createApplicationContext(Landroid/content/pm/ApplicationInfo;I)Landroid/content/Context;
Landroid/content/ContextWrapper;->getBasePackageName()Ljava/lang/String;
Landroid/content/ContextWrapper;->getDisplay()Landroid/view/Display;
Landroid/content/ContextWrapper;->mBase:Landroid/content/Context;
@@ -1494,6 +1502,8 @@ Landroid/content/pm/IPackageInstallObserver2$Stub;->asInterface(Landroid/os/IBin
Landroid/content/pm/IPackageInstallObserver2;->onPackageInstalled(Ljava/lang/String;ILjava/lang/String;Landroid/os/Bundle;)V
Landroid/content/pm/IPackageInstallObserver2;->onUserActionRequired(Landroid/content/Intent;)V
Landroid/content/pm/IPackageManager$Stub$Proxy;-><init>(Landroid/os/IBinder;)V
+Landroid/content/pm/IPackageManager$Stub$Proxy;->checkUidPermission(Ljava/lang/String;I)I
+Landroid/content/pm/IPackageManager$Stub$Proxy;->getAppOpPermissionPackages(Ljava/lang/String;)[Ljava/lang/String;
Landroid/content/pm/IPackageManager$Stub$Proxy;->getInstalledPackages(II)Landroid/content/pm/ParceledListSlice;
Landroid/content/pm/IPackageManager$Stub$Proxy;->getInstallLocation()I
Landroid/content/pm/IPackageManager$Stub$Proxy;->getPackageInfo(Ljava/lang/String;II)Landroid/content/pm/PackageInfo;
@@ -1514,6 +1524,7 @@ Landroid/content/pm/IPackageManager;->currentToCanonicalPackageNames([Ljava/lang
Landroid/content/pm/IPackageManager;->deleteApplicationCacheFiles(Ljava/lang/String;Landroid/content/pm/IPackageDataObserver;)V
Landroid/content/pm/IPackageManager;->enterSafeMode()V
Landroid/content/pm/IPackageManager;->getApplicationEnabledSetting(Ljava/lang/String;I)I
+Landroid/content/pm/IPackageManager;->getAppOpPermissionPackages(Ljava/lang/String;)[Ljava/lang/String;
Landroid/content/pm/IPackageManager;->getBlockUninstallForUser(Ljava/lang/String;I)Z
Landroid/content/pm/IPackageManager;->getComponentEnabledSetting(Landroid/content/ComponentName;I)I
Landroid/content/pm/IPackageManager;->getFlagsForUid(I)I
@@ -1783,6 +1794,7 @@ Landroid/content/pm/UserInfo;->serialNumber:I
Landroid/content/pm/VerifierInfo;-><init>(Ljava/lang/String;Ljava/security/PublicKey;)V
Landroid/content/pm/XmlSerializerAndParser;->createFromXml(Lorg/xmlpull/v1/XmlPullParser;)Ljava/lang/Object;
Landroid/content/pm/XmlSerializerAndParser;->writeAsXml(Ljava/lang/Object;Lorg/xmlpull/v1/XmlSerializer;)V
+Landroid/content/res/ApkAssets;->getAssetPath()Ljava/lang/String;
Landroid/content/res/AssetFileDescriptor;->mFd:Landroid/os/ParcelFileDescriptor;
Landroid/content/res/AssetFileDescriptor;->mLength:J
Landroid/content/res/AssetFileDescriptor;->mStartOffset:J
@@ -1794,6 +1806,7 @@ Landroid/content/res/AssetManager;->addAssetPathAsSharedLibrary(Ljava/lang/Strin
Landroid/content/res/AssetManager;->addOverlayPath(Ljava/lang/String;)I
Landroid/content/res/AssetManager;->applyStyle(JIILandroid/content/res/XmlBlock$Parser;[IJJ)V
Landroid/content/res/AssetManager;->createTheme()J
+Landroid/content/res/AssetManager;->getApkAssets()[Landroid/content/res/ApkAssets;
Landroid/content/res/AssetManager;->getAssignedPackageIdentifiers()Landroid/util/SparseArray;
Landroid/content/res/AssetManager;->getGlobalAssetCount()I
Landroid/content/res/AssetManager;->getGlobalAssetManagerCount()I
@@ -1836,6 +1849,7 @@ Landroid/content/res/CompatibilityInfo$Translator;->translateRectInScreenToAppWi
Landroid/content/res/CompatibilityInfo$Translator;->translateRectInScreenToAppWinFrame(Landroid/graphics/Rect;)V
Landroid/content/res/CompatibilityInfo$Translator;->translateRegionInWindowToScreen(Landroid/graphics/Region;)V
Landroid/content/res/CompatibilityInfo$Translator;->translateWindowLayout(Landroid/view/WindowManager$LayoutParams;)V
+Landroid/content/res/CompatibilityInfo;-><init>()V
Landroid/content/res/CompatibilityInfo;-><init>(Landroid/content/pm/ApplicationInfo;IIZ)V
Landroid/content/res/CompatibilityInfo;->applicationScale:F
Landroid/content/res/CompatibilityInfo;->computeCompatibleScaling(Landroid/util/DisplayMetrics;Landroid/util/DisplayMetrics;)F
@@ -1849,6 +1863,7 @@ Landroid/content/res/Configuration;->makeDefault()V
Landroid/content/res/Configuration;->resourceQualifierString(Landroid/content/res/Configuration;)Ljava/lang/String;
Landroid/content/res/Configuration;->seq:I
Landroid/content/res/Configuration;->userSetLocale:Z
+Landroid/content/res/ConfigurationBoundResourceCache;-><init>()V
Landroid/content/res/DrawableCache;-><init>()V
Landroid/content/res/DrawableCache;->getInstance(JLandroid/content/res/Resources;Landroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
Landroid/content/res/ObbInfo;->salt:[B
@@ -2727,6 +2742,7 @@ Landroid/media/AudioGainConfig;->mRampDurationMs:I
Landroid/media/AudioGainConfig;->mValues:[I
Landroid/media/AudioHandle;-><init>(I)V
Landroid/media/AudioHandle;->mId:I
+Landroid/media/AudioManager;-><init>()V
Landroid/media/AudioManager;-><init>(Landroid/content/Context;)V
Landroid/media/AudioManager;->abandonAudioFocusForCall()V
Landroid/media/AudioManager;->createAudioPatch([Landroid/media/AudioPatch;[Landroid/media/AudioPortConfig;[Landroid/media/AudioPortConfig;)I
@@ -2986,6 +3002,8 @@ Landroid/media/MediaPlayer;->BYPASS_METADATA_FILTER:Z
Landroid/media/MediaPlayer;->getMediaTimeProvider()Landroid/media/MediaTimeProvider;
Landroid/media/MediaPlayer;->getMetadata(ZZ)Landroid/media/Metadata;
Landroid/media/MediaPlayer;->invoke(Landroid/os/Parcel;Landroid/os/Parcel;)V
+Landroid/media/MediaPlayer;->MEDIA_INFO_EXTERNAL_METADATA_UPDATE:I
+Landroid/media/MediaPlayer;->MEDIA_INFO_TIMED_TEXT_ERROR:I
Landroid/media/MediaPlayer;->METADATA_ALL:Z
Landroid/media/MediaPlayer;->mEventHandler:Landroid/media/MediaPlayer$EventHandler;
Landroid/media/MediaPlayer;->mOnCompletionListener:Landroid/media/MediaPlayer$OnCompletionListener;
@@ -3354,6 +3372,7 @@ Landroid/net/LinkProperties;->addLinkAddress(Landroid/net/LinkAddress;)Z
Landroid/net/LinkProperties;->getAddresses()Ljava/util/List;
Landroid/net/LinkProperties;->getAllAddresses()Ljava/util/List;
Landroid/net/LinkProperties;->getAllLinkAddresses()Ljava/util/List;
+Landroid/net/LinkProperties;->getTcpBufferSizes()Ljava/lang/String;
Landroid/net/LinkProperties;->isIdenticalHttpProxy(Landroid/net/LinkProperties;)Z
Landroid/net/LinkProperties;->isIdenticalInterfaceName(Landroid/net/LinkProperties;)Z
Landroid/net/LinkProperties;->mIfaceName:Ljava/lang/String;
@@ -6889,6 +6908,7 @@ Landroid/widget/Gallery;->mSelectedChild:Landroid/view/View;
Landroid/widget/Gallery;->mSpacing:I
Landroid/widget/Gallery;->trackMotionScroll(I)V
Landroid/widget/GridLayout;->UNDEFINED_ALIGNMENT:Landroid/widget/GridLayout$Alignment;
+Landroid/widget/GridView;->determineColumns(I)Z
Landroid/widget/GridView;->fillDown(II)Landroid/view/View;
Landroid/widget/GridView;->fillUp(II)Landroid/view/View;
Landroid/widget/GridView;->mColumnWidth:I
diff --git a/config/preloaded-classes b/config/preloaded-classes
index 2971ef83feb6..001479370fb9 100644
--- a/config/preloaded-classes
+++ b/config/preloaded-classes
@@ -2771,10 +2771,8 @@ android.security.net.config.PinSet
android.security.net.config.RootTrustManager
android.security.net.config.RootTrustManagerFactorySpi
android.security.net.config.SystemCertificateSource
-android.security.net.config.SystemCertificateSource$NoPreloadHolder
android.security.net.config.TrustedCertificateStoreAdapter
android.security.net.config.UserCertificateSource
-android.security.net.config.UserCertificateSource$NoPreloadHolder
android.security.net.config.XmlConfigSource
android.security.net.config.XmlConfigSource$ParserException
android.service.media.IMediaBrowserService
@@ -4556,7 +4554,6 @@ com.android.org.conscrypt.OpenSSLX509CertificateFactory$ParsingException
com.android.org.conscrypt.PeerInfoProvider
com.android.org.conscrypt.PeerInfoProvider$1
com.android.org.conscrypt.Platform
-com.android.org.conscrypt.Platform$NoPreloadHolder
com.android.org.conscrypt.Preconditions
com.android.org.conscrypt.SSLClientSessionCache
com.android.org.conscrypt.SSLParametersImpl
@@ -6072,7 +6069,6 @@ javax.net.ssl.ExtendedSSLSession
javax.net.ssl.HandshakeCompletedListener
javax.net.ssl.HostnameVerifier
javax.net.ssl.HttpsURLConnection
-javax.net.ssl.HttpsURLConnection$NoPreloadHolder
javax.net.ssl.KeyManager
javax.net.ssl.KeyManagerFactory
javax.net.ssl.KeyManagerFactory$1
diff --git a/core/java/android/accounts/ChooseAccountActivity.java b/core/java/android/accounts/ChooseAccountActivity.java
index 6a436869a0ec..4af22bfac92d 100644
--- a/core/java/android/accounts/ChooseAccountActivity.java
+++ b/core/java/android/accounts/ChooseAccountActivity.java
@@ -17,6 +17,7 @@ package android.accounts;
import android.app.Activity;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.content.Context;
import android.content.pm.PackageManager;
import android.content.res.Resources;
@@ -72,8 +73,8 @@ public class ChooseAccountActivity extends Activity {
try {
IBinder activityToken = getActivityToken();
- mCallingUid = ActivityManager.getService().getLaunchedFromUid(activityToken);
- mCallingPackage = ActivityManager.getService().getLaunchedFromPackage(
+ mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken);
+ mCallingPackage = ActivityTaskManager.getService().getLaunchedFromPackage(
activityToken);
} catch (RemoteException re) {
// Couldn't figure out caller details
diff --git a/core/java/android/accounts/ChooseTypeAndAccountActivity.java b/core/java/android/accounts/ChooseTypeAndAccountActivity.java
index 6680ce6acb04..57c108326706 100644
--- a/core/java/android/accounts/ChooseTypeAndAccountActivity.java
+++ b/core/java/android/accounts/ChooseTypeAndAccountActivity.java
@@ -15,6 +15,7 @@
*/
package android.accounts;
+import android.app.ActivityTaskManager;
import com.google.android.collect.Sets;
import android.app.Activity;
@@ -147,8 +148,8 @@ public class ChooseTypeAndAccountActivity extends Activity
try {
IBinder activityToken = getActivityToken();
- mCallingUid = ActivityManager.getService().getLaunchedFromUid(activityToken);
- mCallingPackage = ActivityManager.getService().getLaunchedFromPackage(
+ mCallingUid = ActivityTaskManager.getService().getLaunchedFromUid(activityToken);
+ mCallingPackage = ActivityTaskManager.getService().getLaunchedFromPackage(
activityToken);
if (mCallingUid != 0 && mCallingPackage != null) {
Bundle restrictions = UserManager.get(this)
diff --git a/core/java/android/app/Activity.java b/core/java/android/app/Activity.java
index a6d2be0842a7..8e0fa1395ed1 100644
--- a/core/java/android/app/Activity.java
+++ b/core/java/android/app/Activity.java
@@ -1442,7 +1442,7 @@ public class Activity extends ContextThemeWrapper
public boolean isVoiceInteractionRoot() {
try {
return mVoiceInteractor != null
- && ActivityManager.getService().isRootVoiceInteraction(mToken);
+ && ActivityTaskManager.getService().isRootVoiceInteraction(mToken);
} catch (RemoteException e) {
}
return false;
@@ -1465,7 +1465,7 @@ public class Activity extends ContextThemeWrapper
*/
public boolean isLocalVoiceInteractionSupported() {
try {
- return ActivityManager.getService().supportsLocalVoiceInteraction();
+ return ActivityTaskManager.getService().supportsLocalVoiceInteraction();
} catch (RemoteException re) {
}
return false;
@@ -1479,7 +1479,7 @@ public class Activity extends ContextThemeWrapper
*/
public void startLocalVoiceInteraction(Bundle privateOptions) {
try {
- ActivityManager.getService().startLocalVoiceInteraction(mToken, privateOptions);
+ ActivityTaskManager.getService().startLocalVoiceInteraction(mToken, privateOptions);
} catch (RemoteException re) {
}
}
@@ -1508,7 +1508,7 @@ public class Activity extends ContextThemeWrapper
*/
public void stopLocalVoiceInteraction() {
try {
- ActivityManager.getService().stopLocalVoiceInteraction(mToken);
+ ActivityTaskManager.getService().stopLocalVoiceInteraction(mToken);
} catch (RemoteException re) {
}
}
@@ -1886,7 +1886,7 @@ public class Activity extends ContextThemeWrapper
*/
public boolean showAssist(Bundle args) {
try {
- return ActivityManager.getService().showAssistFromActivity(mToken, args);
+ return ActivityTaskManager.getService().showAssistFromActivity(mToken, args);
} catch (RemoteException e) {
}
return false;
@@ -2019,7 +2019,8 @@ public class Activity extends ContextThemeWrapper
if (mDoReportFullyDrawn) {
mDoReportFullyDrawn = false;
try {
- ActivityManager.getService().reportActivityFullyDrawn(mToken, mRestoredFromBundle);
+ ActivityTaskManager.getService().reportActivityFullyDrawn(
+ mToken, mRestoredFromBundle);
} catch (RemoteException e) {
}
}
@@ -2066,7 +2067,7 @@ public class Activity extends ContextThemeWrapper
*/
public boolean isInMultiWindowMode() {
try {
- return ActivityManager.getService().isInMultiWindowMode(mToken);
+ return ActivityTaskManager.getService().isInMultiWindowMode(mToken);
} catch (RemoteException e) {
}
return false;
@@ -2113,7 +2114,7 @@ public class Activity extends ContextThemeWrapper
*/
public boolean isInPictureInPictureMode() {
try {
- return ActivityManager.getService().isInPictureInPictureMode(mToken);
+ return ActivityTaskManager.getService().isInPictureInPictureMode(mToken);
} catch (RemoteException e) {
}
return false;
@@ -2168,7 +2169,7 @@ public class Activity extends ContextThemeWrapper
throw new IllegalStateException("Activity must be resumed to enter"
+ " picture-in-picture");
}
- return ActivityManagerNative.getDefault().enterPictureInPictureMode(mToken, params);
+ return ActivityTaskManager.getService().enterPictureInPictureMode(mToken, params);
} catch (RemoteException e) {
return false;
}
@@ -2194,7 +2195,7 @@ public class Activity extends ContextThemeWrapper
if (params == null) {
throw new IllegalArgumentException("Expected non-null picture-in-picture params");
}
- ActivityManagerNative.getDefault().setPictureInPictureParams(mToken, params);
+ ActivityTaskManager.getService().setPictureInPictureParams(mToken, params);
} catch (RemoteException e) {
}
}
@@ -2207,7 +2208,7 @@ public class Activity extends ContextThemeWrapper
*/
public int getMaxNumPictureInPictureActions() {
try {
- return ActivityManagerNative.getDefault().getMaxNumPictureInPictureActions(mToken);
+ return ActivityTaskManager.getService().getMaxNumPictureInPictureActions(mToken);
} catch (RemoteException e) {
return 0;
}
@@ -3321,7 +3322,7 @@ public class Activity extends ContextThemeWrapper
*/
@Override
public void exitFreeformMode() throws RemoteException {
- ActivityManager.getService().exitFreeformMode(mToken);
+ ActivityTaskManager.getService().exitFreeformMode(mToken);
}
/**
@@ -4833,7 +4834,7 @@ public class Activity extends ContextThemeWrapper
fillInIntent.prepareToLeaveProcess(this);
resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
}
- int result = ActivityManager.getService()
+ int result = ActivityTaskManager.getService()
.startActivityIntentSender(mMainThread.getApplicationThread(),
intent != null ? intent.getTarget() : null,
intent != null ? intent.getWhitelistToken() : null,
@@ -5065,7 +5066,7 @@ public class Activity extends ContextThemeWrapper
}
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(this);
- result = ActivityManager.getService()
+ result = ActivityTaskManager.getService()
.startActivity(mMainThread.getApplicationThread(), getBasePackageName(),
intent, intent.resolveTypeIfNeeded(getContentResolver()), mToken,
mEmbeddedID, requestCode, ActivityManager.START_FLAG_ONLY_IF_NEEDED,
@@ -5136,7 +5137,7 @@ public class Activity extends ContextThemeWrapper
try {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(this);
- return ActivityManager.getService()
+ return ActivityTaskManager.getService()
.startNextMatchingActivity(mToken, intent, options);
} catch (RemoteException e) {
// Empty
@@ -5351,7 +5352,7 @@ public class Activity extends ContextThemeWrapper
*/
public void overridePendingTransition(int enterAnim, int exitAnim) {
try {
- ActivityManager.getService().overridePendingTransition(
+ ActivityTaskManager.getService().overridePendingTransition(
mToken, getPackageName(), enterAnim, exitAnim);
} catch (RemoteException e) {
}
@@ -5476,7 +5477,7 @@ public class Activity extends ContextThemeWrapper
@Nullable
public String getCallingPackage() {
try {
- return ActivityManager.getService().getCallingPackage(mToken);
+ return ActivityTaskManager.getService().getCallingPackage(mToken);
} catch (RemoteException e) {
return null;
}
@@ -5499,7 +5500,7 @@ public class Activity extends ContextThemeWrapper
@Nullable
public ComponentName getCallingActivity() {
try {
- return ActivityManager.getService().getCallingActivity(mToken);
+ return ActivityTaskManager.getService().getCallingActivity(mToken);
} catch (RemoteException e) {
return null;
}
@@ -5603,7 +5604,7 @@ public class Activity extends ContextThemeWrapper
if (resultData != null) {
resultData.prepareToLeaveProcess(this);
}
- if (ActivityManager.getService()
+ if (ActivityTaskManager.getService()
.finishActivity(mToken, resultCode, resultData, finishTask)) {
mFinished = true;
}
@@ -5653,7 +5654,7 @@ public class Activity extends ContextThemeWrapper
throw new IllegalStateException("Can not be called to deliver a result");
}
try {
- if (ActivityManager.getService().finishActivityAffinity(mToken)) {
+ if (ActivityTaskManager.getService().finishActivityAffinity(mToken)) {
mFinished = true;
}
} catch (RemoteException e) {
@@ -5699,7 +5700,7 @@ public class Activity extends ContextThemeWrapper
public void finishActivity(int requestCode) {
if (mParent == null) {
try {
- ActivityManager.getService()
+ ActivityTaskManager.getService()
.finishSubActivity(mToken, mEmbeddedID, requestCode);
} catch (RemoteException e) {
// Empty
@@ -5719,7 +5720,7 @@ public class Activity extends ContextThemeWrapper
*/
public void finishActivityFromChild(@NonNull Activity child, int requestCode) {
try {
- ActivityManager.getService()
+ ActivityTaskManager.getService()
.finishSubActivity(mToken, child.mEmbeddedID, requestCode);
} catch (RemoteException e) {
// Empty
@@ -5747,7 +5748,7 @@ public class Activity extends ContextThemeWrapper
*/
public boolean releaseInstance() {
try {
- return ActivityManager.getService().releaseActivityInstance(mToken);
+ return ActivityTaskManager.getService().releaseActivityInstance(mToken);
} catch (RemoteException e) {
// Empty
}
@@ -5862,7 +5863,7 @@ public class Activity extends ContextThemeWrapper
public void setRequestedOrientation(@ActivityInfo.ScreenOrientation int requestedOrientation) {
if (mParent == null) {
try {
- ActivityManager.getService().setRequestedOrientation(
+ ActivityTaskManager.getService().setRequestedOrientation(
mToken, requestedOrientation);
} catch (RemoteException e) {
// Empty
@@ -5885,7 +5886,7 @@ public class Activity extends ContextThemeWrapper
public int getRequestedOrientation() {
if (mParent == null) {
try {
- return ActivityManager.getService()
+ return ActivityTaskManager.getService()
.getRequestedOrientation(mToken);
} catch (RemoteException e) {
// Empty
@@ -5904,8 +5905,7 @@ public class Activity extends ContextThemeWrapper
*/
public int getTaskId() {
try {
- return ActivityManager.getService()
- .getTaskForActivity(mToken, false);
+ return ActivityTaskManager.getService().getTaskForActivity(mToken, false);
} catch (RemoteException e) {
return -1;
}
@@ -5920,7 +5920,7 @@ public class Activity extends ContextThemeWrapper
@Override
public boolean isTaskRoot() {
try {
- return ActivityManager.getService().getTaskForActivity(mToken, true) >= 0;
+ return ActivityTaskManager.getService().getTaskForActivity(mToken, true) >= 0;
} catch (RemoteException e) {
return false;
}
@@ -5939,8 +5939,7 @@ public class Activity extends ContextThemeWrapper
*/
public boolean moveTaskToBack(boolean nonRoot) {
try {
- return ActivityManager.getService().moveActivityTaskToBack(
- mToken, nonRoot);
+ return ActivityTaskManager.getService().moveActivityTaskToBack(mToken, nonRoot);
} catch (RemoteException e) {
// Empty
}
@@ -6115,7 +6114,7 @@ public class Activity extends ContextThemeWrapper
}
}
try {
- ActivityManager.getService().setTaskDescription(mToken, mTaskDescription);
+ ActivityTaskManager.getService().setTaskDescription(mToken, mTaskDescription);
} catch (RemoteException e) {
}
}
@@ -6390,7 +6389,7 @@ public class Activity extends ContextThemeWrapper
*/
public boolean isImmersive() {
try {
- return ActivityManager.getService().isImmersive(mToken);
+ return ActivityTaskManager.getService().isImmersive(mToken);
} catch (RemoteException e) {
return false;
}
@@ -6408,7 +6407,7 @@ public class Activity extends ContextThemeWrapper
return false;
}
try {
- return ActivityManager.getService().isTopOfTask(getActivityToken());
+ return ActivityTaskManager.getService().isTopOfTask(getActivityToken());
} catch (RemoteException e) {
return false;
}
@@ -6434,7 +6433,7 @@ public class Activity extends ContextThemeWrapper
public void convertFromTranslucent() {
try {
mTranslucentCallback = null;
- if (ActivityManager.getService().convertFromTranslucent(mToken)) {
+ if (ActivityTaskManager.getService().convertFromTranslucent(mToken)) {
WindowManagerGlobal.getInstance().changeCanvasOpacity(mToken, true);
}
} catch (RemoteException e) {
@@ -6473,7 +6472,7 @@ public class Activity extends ContextThemeWrapper
boolean drawComplete;
try {
mTranslucentCallback = callback;
- mChangeCanvasToTranslucent = ActivityManager.getService().convertToTranslucent(
+ mChangeCanvasToTranslucent = ActivityTaskManager.getService().convertToTranslucent(
mToken, options == null ? null : options.toBundle());
WindowManagerGlobal.getInstance().changeCanvasOpacity(mToken, false);
drawComplete = true;
@@ -6519,7 +6518,7 @@ public class Activity extends ContextThemeWrapper
ActivityOptions getActivityOptions() {
try {
return ActivityOptions.fromBundle(
- ActivityManager.getService().getActivityOptions(mToken));
+ ActivityTaskManager.getService().getActivityOptions(mToken));
} catch (RemoteException e) {
}
return null;
@@ -6664,7 +6663,7 @@ public class Activity extends ContextThemeWrapper
*/
public void setImmersive(boolean i) {
try {
- ActivityManager.getService().setImmersive(mToken, i);
+ ActivityTaskManager.getService().setImmersive(mToken, i);
} catch (RemoteException e) {
// pass
}
@@ -6727,7 +6726,7 @@ public class Activity extends ContextThemeWrapper
public void setVrModeEnabled(boolean enabled, @NonNull ComponentName requestedComponent)
throws PackageManager.NameNotFoundException {
try {
- if (ActivityManager.getService().setVrMode(mToken, enabled, requestedComponent)
+ if (ActivityTaskManager.getService().setVrMode(mToken, enabled, requestedComponent)
!= 0) {
throw new PackageManager.NameNotFoundException(
requestedComponent.flattenToString());
@@ -6848,8 +6847,7 @@ public class Activity extends ContextThemeWrapper
if (info.taskAffinity == null) {
return false;
}
- return ActivityManager.getService()
- .shouldUpRecreateTask(mToken, info.taskAffinity);
+ return ActivityTaskManager.getService().shouldUpRecreateTask(mToken, info.taskAffinity);
} catch (RemoteException e) {
return false;
} catch (NameNotFoundException e) {
@@ -6901,7 +6899,7 @@ public class Activity extends ContextThemeWrapper
}
try {
upIntent.prepareToLeaveProcess(this);
- return ActivityManager.getService().navigateUpTo(mToken, upIntent,
+ return ActivityTaskManager.getService().navigateUpTo(mToken, upIntent,
resultCode, resultData);
} catch (RemoteException e) {
return false;
@@ -7508,7 +7506,7 @@ public class Activity extends ContextThemeWrapper
*/
public void startLockTask() {
try {
- ActivityManager.getService().startLockTaskModeByToken(mToken);
+ ActivityTaskManager.getService().startLockTaskModeByToken(mToken);
} catch (RemoteException e) {
}
}
@@ -7531,7 +7529,7 @@ public class Activity extends ContextThemeWrapper
*/
public void stopLockTask() {
try {
- ActivityManager.getService().stopLockTaskModeByToken(mToken);
+ ActivityTaskManager.getService().stopLockTaskModeByToken(mToken);
} catch (RemoteException e) {
}
}
@@ -7543,7 +7541,7 @@ public class Activity extends ContextThemeWrapper
*/
public void showLockTaskEscapeMessage() {
try {
- ActivityManager.getService().showLockTaskEscapeMessage(mToken);
+ ActivityTaskManager.getService().showLockTaskEscapeMessage(mToken);
} catch (RemoteException e) {
}
}
@@ -7813,7 +7811,7 @@ public class Activity extends ContextThemeWrapper
*/
public void setDisablePreviewScreenshots(boolean disable) {
try {
- ActivityManager.getService().setDisablePreviewScreenshots(mToken, disable);
+ ActivityTaskManager.getService().setDisablePreviewScreenshots(mToken, disable);
} catch (RemoteException e) {
Log.e(TAG, "Failed to call setDisablePreviewScreenshots", e);
}
@@ -7834,7 +7832,7 @@ public class Activity extends ContextThemeWrapper
*/
public void setShowWhenLocked(boolean showWhenLocked) {
try {
- ActivityManager.getService().setShowWhenLocked(mToken, showWhenLocked);
+ ActivityTaskManager.getService().setShowWhenLocked(mToken, showWhenLocked);
} catch (RemoteException e) {
Log.e(TAG, "Failed to call setShowWhenLocked", e);
}
@@ -7860,7 +7858,7 @@ public class Activity extends ContextThemeWrapper
*/
public void setTurnScreenOn(boolean turnScreenOn) {
try {
- ActivityManager.getService().setTurnScreenOn(mToken, turnScreenOn);
+ ActivityTaskManager.getService().setTurnScreenOn(mToken, turnScreenOn);
} catch (RemoteException e) {
Log.e(TAG, "Failed to call setTurnScreenOn", e);
}
@@ -7876,7 +7874,7 @@ public class Activity extends ContextThemeWrapper
@RequiresPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS)
public void registerRemoteAnimations(RemoteAnimationDefinition definition) {
try {
- ActivityManager.getService().registerRemoteAnimations(mToken, definition);
+ ActivityTaskManager.getService().registerRemoteAnimations(mToken, definition);
} catch (RemoteException e) {
Log.e(TAG, "Failed to call registerRemoteAnimations", e);
}
diff --git a/core/java/android/app/ActivityManager.java b/core/java/android/app/ActivityManager.java
index 929e119dc2d2..e08b54f3eb5c 100644
--- a/core/java/android/app/ActivityManager.java
+++ b/core/java/android/app/ActivityManager.java
@@ -123,8 +123,6 @@ import java.util.List;
public class ActivityManager {
private static String TAG = "ActivityManager";
- private static int gMaxRecentTasks = -1;
-
private final Context mContext;
private static volatile boolean sSystemReady = false;
@@ -746,86 +744,9 @@ public class ActivityManager {
SystemProperties.getBoolean("debug.force_low_ram", false);
/** @hide */
- @TestApi
- public static class StackId {
-
- private StackId() {
- }
-
- /** Invalid stack ID. */
- public static final int INVALID_STACK_ID = -1;
-
- }
-
- /**
- * Parameter to {@link android.app.IActivityManager#setTaskWindowingModeSplitScreenPrimary}
- * which specifies the position of the created docked stack at the top half of the screen if
- * in portrait mode or at the left half of the screen if in landscape mode.
- * @hide
- */
- @TestApi
- public static final int SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT = 0;
-
- /**
- * Parameter to {@link android.app.IActivityManager#setTaskWindowingModeSplitScreenPrimary}
- * which
- * specifies the position of the created docked stack at the bottom half of the screen if
- * in portrait mode or at the right half of the screen if in landscape mode.
- * @hide
- */
- @TestApi
- public static final int SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT = 1;
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
- * that the resize doesn't need to preserve the window, and can be skipped if bounds
- * is unchanged. This mode is used by window manager in most cases.
- * @hide
- */
- public static final int RESIZE_MODE_SYSTEM = 0;
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
- * that the resize should preserve the window if possible.
- * @hide
- */
- public static final int RESIZE_MODE_PRESERVE_WINDOW = (0x1 << 0);
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
- * that the resize should be performed even if the bounds appears unchanged.
- * @hide
- */
- public static final int RESIZE_MODE_FORCED = (0x1 << 1);
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} used by window
- * manager during a screen rotation.
- * @hide
- */
- public static final int RESIZE_MODE_SYSTEM_SCREEN_ROTATION = RESIZE_MODE_PRESERVE_WINDOW;
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} used when the
- * resize is due to a drag action.
- * @hide
- */
- public static final int RESIZE_MODE_USER = RESIZE_MODE_PRESERVE_WINDOW;
-
- /**
- * Input parameter to {@link android.app.IActivityManager#resizeTask} which indicates
- * that the resize should preserve the window if possible, and should not be skipped
- * even if the bounds is unchanged. Usually used to force a resizing when a drag action
- * is ending.
- * @hide
- */
- public static final int RESIZE_MODE_USER_FORCED =
- RESIZE_MODE_PRESERVE_WINDOW | RESIZE_MODE_FORCED;
-
- /** @hide */
public int getFrontActivityScreenCompatMode() {
try {
- return getService().getFrontActivityScreenCompatMode();
+ return getTaskService().getFrontActivityScreenCompatMode();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -834,7 +755,7 @@ public class ActivityManager {
/** @hide */
public void setFrontActivityScreenCompatMode(int mode) {
try {
- getService().setFrontActivityScreenCompatMode(mode);
+ getTaskService().setFrontActivityScreenCompatMode(mode);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -977,57 +898,13 @@ public class ActivityManager {
}
/**
- * Return the maximum number of recents entries that we will maintain and show.
+ * TODO(b/80414790): Remove once no longer on hiddenapi-light-greylist.txt
* @hide
+ * @deprecated Use {@link ActivityTaskManager#getMaxRecentTasksStatic()}
*/
+ @Deprecated
static public int getMaxRecentTasksStatic() {
- if (gMaxRecentTasks < 0) {
- return gMaxRecentTasks = isLowRamDeviceStatic() ? 36 : 48;
- }
- return gMaxRecentTasks;
- }
-
- /**
- * Return the default limit on the number of recents that an app can make.
- * @hide
- */
- static public int getDefaultAppRecentsLimitStatic() {
- return getMaxRecentTasksStatic() / 6;
- }
-
- /**
- * Return the maximum limit on the number of recents that an app can make.
- * @hide
- */
- static public int getMaxAppRecentsLimitStatic() {
- return getMaxRecentTasksStatic() / 2;
- }
-
- /**
- * Returns true if the system supports at least one form of multi-window.
- * E.g. freeform, split-screen, picture-in-picture.
- * @hide
- */
- @TestApi
- static public boolean supportsMultiWindow(Context context) {
- // On watches, multi-window is used to present essential system UI, and thus it must be
- // supported regardless of device memory characteristics.
- boolean isWatch = context.getPackageManager().hasSystemFeature(
- PackageManager.FEATURE_WATCH);
- return (!isLowRamDeviceStatic() || isWatch)
- && Resources.getSystem().getBoolean(
- com.android.internal.R.bool.config_supportsMultiWindow);
- }
-
- /**
- * Returns true if the system supports split screen multi-window.
- * @hide
- */
- @TestApi
- static public boolean supportsSplitScreenMultiWindow(Context context) {
- return supportsMultiWindow(context)
- && Resources.getSystem().getBoolean(
- com.android.internal.R.bool.config_supportsSplitScreenMultiWindow);
+ return ActivityTaskManager.getMaxRecentTasksStatic();
}
/** @removed */
@@ -1305,7 +1182,7 @@ public class ActivityManager {
public static Bitmap loadTaskDescriptionIcon(String iconFilename, int userId) {
if (iconFilename != null) {
try {
- return getService().getTaskDescriptionIcon(iconFilename,
+ return getTaskService().getTaskDescriptionIcon(iconFilename,
userId);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -1705,7 +1582,7 @@ public class ActivityManager {
if (maxNum < 0) {
throw new IllegalArgumentException("The requested number of tasks should be >= 0");
}
- return getService().getRecentTasks(maxNum, flags, mContext.getUserId()).getList();
+ return getTaskService().getRecentTasks(maxNum, flags, mContext.getUserId()).getList();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -1858,7 +1735,7 @@ public class ActivityManager {
ArrayList<AppTask> tasks = new ArrayList<AppTask>();
List<IBinder> appTasks;
try {
- appTasks = getService().getAppTasks(mContext.getPackageName());
+ appTasks = getTaskService().getAppTasks(mContext.getPackageName());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -1883,7 +1760,7 @@ public class ActivityManager {
private void ensureAppTaskThumbnailSizeLocked() {
if (mAppTaskThumbnailSize == null) {
try {
- mAppTaskThumbnailSize = getService().getAppTaskThumbnailSize();
+ mAppTaskThumbnailSize = getTaskService().getAppTaskThumbnailSize();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -1948,7 +1825,7 @@ public class ActivityManager {
description = new TaskDescription();
}
try {
- return getService().addAppTask(activity.getActivityToken(),
+ return getTaskService().addAppTask(activity.getActivityToken(),
intent, description, thumbnail);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -1991,103 +1868,7 @@ public class ActivityManager {
public List<RunningTaskInfo> getRunningTasks(int maxNum)
throws SecurityException {
try {
- return getService().getTasks(maxNum);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Sets the windowing mode for a specific task. Only works on tasks of type
- * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}
- * @param taskId The id of the task to set the windowing mode for.
- * @param windowingMode The windowing mode to set for the task.
- * @param toTop If the task should be moved to the top once the windowing mode changes.
- * @hide
- */
- @TestApi
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
- public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop)
- throws SecurityException {
- try {
- getService().setTaskWindowingMode(taskId, windowingMode, toTop);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Moves the input task to the primary-split-screen stack.
- * @param taskId Id of task to move.
- * @param createMode The mode the primary split screen stack should be created in if it doesn't
- * exist already. See
- * {@link android.app.ActivityManager#SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT}
- * and
- * {@link android.app.ActivityManager
- * #SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT}
- * @param toTop If the task and stack should be moved to the top.
- * @param animate Whether we should play an animation for the moving the task
- * @param initialBounds If the primary stack gets created, it will use these bounds for the
- * docked stack. Pass {@code null} to use default bounds.
- * @param showRecents If the recents activity should be shown on the other side of the task
- * going into split-screen mode.
- * @hide
- */
- @TestApi
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
- public void setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
- boolean animate, Rect initialBounds, boolean showRecents) throws SecurityException {
- try {
- getService().setTaskWindowingModeSplitScreenPrimary(taskId, createMode, toTop, animate,
- initialBounds, showRecents);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Resizes the input stack id to the given bounds.
- * @param stackId Id of the stack to resize.
- * @param bounds Bounds to resize the stack to or {@code null} for fullscreen.
- * @hide
- */
- @TestApi
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
- public void resizeStack(int stackId, Rect bounds) throws SecurityException {
- try {
- getService().resizeStack(stackId, bounds, false /* allowResizeInDockedMode */,
- false /* preserveWindows */, false /* animate */, -1 /* animationDuration */);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Removes stacks in the windowing modes from the system if they are of activity type
- * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
- *
- * @hide
- */
- @TestApi
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
- public void removeStacksInWindowingModes(int[] windowingModes) throws SecurityException {
- try {
- getService().removeStacksInWindowingModes(windowingModes);
- } catch (RemoteException e) {
- throw e.rethrowFromSystemServer();
- }
- }
-
- /**
- * Removes stack of the activity types from the system.
- *
- * @hide
- */
- @TestApi
- @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
- public void removeStacksWithActivityTypes(int[] activityTypes) throws SecurityException {
- try {
- getService().removeStacksWithActivityTypes(activityTypes);
+ return getTaskService().getTasks(maxNum);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -2177,7 +1958,8 @@ public class ActivityManager {
}
/**
- * @return Whether or not the snapshot is of a translucent app window.
+ * @return Whether or not the snapshot is of a translucent app window (non-fullscreen or has
+ * a non-opaque pixel format).
*/
public boolean isTranslucent() {
return mIsTranslucent;
@@ -2295,7 +2077,7 @@ public class ActivityManager {
@RequiresPermission(android.Manifest.permission.REORDER_TASKS)
public void moveTaskToFront(int taskId, @MoveTaskFlags int flags, Bundle options) {
try {
- getService().moveTaskToFront(taskId, flags, options);
+ getTaskService().moveTaskToFront(taskId, flags, options);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -3802,7 +3584,7 @@ public class ActivityManager {
@TestApi
public void alwaysShowUnsupportedCompileSdkWarning(ComponentName activity) {
try {
- getService().alwaysShowUnsupportedCompileSdkWarning(activity);
+ getTaskService().alwaysShowUnsupportedCompileSdkWarning(activity);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -4125,6 +3907,10 @@ public class ActivityManager {
return IActivityManagerSingleton.get();
}
+ private static IActivityTaskManager getTaskService() {
+ return ActivityTaskManager.getService();
+ }
+
private static final Singleton<IActivityManager> IActivityManagerSingleton =
new Singleton<IActivityManager>() {
@Override
@@ -4240,7 +4026,7 @@ public class ActivityManager {
*/
public int getLockTaskModeState() {
try {
- return getService().getLockTaskModeState();
+ return getTaskService().getLockTaskModeState();
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/core/java/android/app/ActivityOptions.java b/core/java/android/app/ActivityOptions.java
index ecd99a7b5402..89408cc340d9 100644
--- a/core/java/android/app/ActivityOptions.java
+++ b/core/java/android/app/ActivityOptions.java
@@ -17,7 +17,7 @@
package android.app;
import static android.Manifest.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.Display.INVALID_DISPLAY;
diff --git a/core/java/android/app/ActivityTaskManager.java b/core/java/android/app/ActivityTaskManager.java
new file mode 100644
index 000000000000..398644afd17a
--- /dev/null
+++ b/core/java/android/app/ActivityTaskManager.java
@@ -0,0 +1,253 @@
+/*
+ * 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 android.app;
+
+import android.annotation.RequiresPermission;
+import android.annotation.SystemService;
+import android.annotation.TestApi;
+import android.content.Context;
+import android.content.pm.PackageManager;
+import android.content.res.Resources;
+import android.graphics.Rect;
+import android.os.Handler;
+import android.os.IBinder;
+import android.os.RemoteException;
+import android.os.ServiceManager;
+import android.util.Singleton;
+
+/**
+ * This class gives information about, and interacts with activities and their containers like task,
+ * stacks, and displays.
+ *
+ * @hide
+ */
+@TestApi
+@SystemService(Context.ACTIVITY_TASK_SERVICE)
+public class ActivityTaskManager {
+
+ /** Invalid stack ID. */
+ public static final int INVALID_STACK_ID = -1;
+
+ /**
+ * Parameter to {@link IActivityTaskManager#setTaskWindowingModeSplitScreenPrimary} which
+ * specifies the position of the created docked stack at the top half of the screen if
+ * in portrait mode or at the left half of the screen if in landscape mode.
+ */
+ public static final int SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT = 0;
+
+ /**
+ * Parameter to {@link IActivityTaskManager#setTaskWindowingModeSplitScreenPrimary} which
+ * specifies the position of the created docked stack at the bottom half of the screen if
+ * in portrait mode or at the right half of the screen if in landscape mode.
+ */
+ public static final int SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT = 1;
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} which indicates
+ * that the resize doesn't need to preserve the window, and can be skipped if bounds
+ * is unchanged. This mode is used by window manager in most cases.
+ * @hide
+ */
+ public static final int RESIZE_MODE_SYSTEM = 0;
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} which indicates
+ * that the resize should preserve the window if possible.
+ * @hide
+ */
+ public static final int RESIZE_MODE_PRESERVE_WINDOW = (0x1 << 0);
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} used when the
+ * resize is due to a drag action.
+ * @hide
+ */
+ public static final int RESIZE_MODE_USER = RESIZE_MODE_PRESERVE_WINDOW;
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} used by window
+ * manager during a screen rotation.
+ * @hide
+ */
+ public static final int RESIZE_MODE_SYSTEM_SCREEN_ROTATION = RESIZE_MODE_PRESERVE_WINDOW;
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} which indicates
+ * that the resize should be performed even if the bounds appears unchanged.
+ * @hide
+ */
+ public static final int RESIZE_MODE_FORCED = (0x1 << 1);
+
+ /**
+ * Input parameter to {@link IActivityTaskManager#resizeTask} which indicates
+ * that the resize should preserve the window if possible, and should not be skipped
+ * even if the bounds is unchanged. Usually used to force a resizing when a drag action
+ * is ending.
+ * @hide
+ */
+ public static final int RESIZE_MODE_USER_FORCED =
+ RESIZE_MODE_PRESERVE_WINDOW | RESIZE_MODE_FORCED;
+
+ private static int sMaxRecentTasks = -1;
+
+ ActivityTaskManager(Context context, Handler handler) {
+ }
+
+ /** @hide */
+ public static IActivityTaskManager getService() {
+ return IActivityTaskManagerSingleton.get();
+ }
+
+ private static final Singleton<IActivityTaskManager> IActivityTaskManagerSingleton =
+ new Singleton<IActivityTaskManager>() {
+ @Override
+ protected IActivityTaskManager create() {
+ final IBinder b = ServiceManager.getService(Context.ACTIVITY_TASK_SERVICE);
+ return IActivityTaskManager.Stub.asInterface(b);
+ }
+ };
+
+ /**
+ * Sets the windowing mode for a specific task. Only works on tasks of type
+ * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}
+ * @param taskId The id of the task to set the windowing mode for.
+ * @param windowingMode The windowing mode to set for the task.
+ * @param toTop If the task should be moved to the top once the windowing mode changes.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
+ public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop)
+ throws SecurityException {
+ try {
+ getService().setTaskWindowingMode(taskId, windowingMode, toTop);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Moves the input task to the primary-split-screen stack.
+ * @param taskId Id of task to move.
+ * @param createMode The mode the primary split screen stack should be created in if it doesn't
+ * exist already. See
+ * {@link ActivityTaskManager#SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT}
+ * and
+ * {@link android.app.ActivityManager
+ * #SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT}
+ * @param toTop If the task and stack should be moved to the top.
+ * @param animate Whether we should play an animation for the moving the task
+ * @param initialBounds If the primary stack gets created, it will use these bounds for the
+ * docked stack. Pass {@code null} to use default bounds.
+ * @param showRecents If the recents activity should be shown on the other side of the task
+ * going into split-screen mode.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
+ public void setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
+ boolean animate, Rect initialBounds, boolean showRecents) throws SecurityException {
+ try {
+ getService().setTaskWindowingModeSplitScreenPrimary(taskId, createMode, toTop, animate,
+ initialBounds, showRecents);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Resizes the input stack id to the given bounds.
+ * @param stackId Id of the stack to resize.
+ * @param bounds Bounds to resize the stack to or {@code null} for fullscreen.
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
+ public void resizeStack(int stackId, Rect bounds) throws SecurityException {
+ try {
+ getService().resizeStack(stackId, bounds, false /* allowResizeInDockedMode */,
+ false /* preserveWindows */, false /* animate */, -1 /* animationDuration */);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Removes stacks in the windowing modes from the system if they are of activity type
+ * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
+ */
+ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
+ public void removeStacksInWindowingModes(int[] windowingModes) throws SecurityException {
+ try {
+ getService().removeStacksInWindowingModes(windowingModes);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /** Removes stack of the activity types from the system. */
+ @RequiresPermission(android.Manifest.permission.MANAGE_ACTIVITY_STACKS)
+ public void removeStacksWithActivityTypes(int[] activityTypes) throws SecurityException {
+ try {
+ getService().removeStacksWithActivityTypes(activityTypes);
+ } catch (RemoteException e) {
+ throw e.rethrowFromSystemServer();
+ }
+ }
+
+ /**
+ * Return the maximum number of recents entries that we will maintain and show.
+ * @hide
+ */
+ public static int getMaxRecentTasksStatic() {
+ if (sMaxRecentTasks < 0) {
+ return sMaxRecentTasks = ActivityManager.isLowRamDeviceStatic() ? 36 : 48;
+ }
+ return sMaxRecentTasks;
+ }
+
+ /**
+ * Return the default limit on the number of recents that an app can make.
+ * @hide
+ */
+ public static int getDefaultAppRecentsLimitStatic() {
+ return getMaxRecentTasksStatic() / 6;
+ }
+
+ /**
+ * Return the maximum limit on the number of recents that an app can make.
+ * @hide
+ */
+ public static int getMaxAppRecentsLimitStatic() {
+ return getMaxRecentTasksStatic() / 2;
+ }
+
+ /**
+ * Returns true if the system supports at least one form of multi-window.
+ * E.g. freeform, split-screen, picture-in-picture.
+ */
+ public static boolean supportsMultiWindow(Context context) {
+ // On watches, multi-window is used to present essential system UI, and thus it must be
+ // supported regardless of device memory characteristics.
+ boolean isWatch = context.getPackageManager().hasSystemFeature(
+ PackageManager.FEATURE_WATCH);
+ return (!ActivityManager.isLowRamDeviceStatic() || isWatch)
+ && Resources.getSystem().getBoolean(
+ com.android.internal.R.bool.config_supportsMultiWindow);
+ }
+
+ /** Returns true if the system supports split screen multi-window. */
+ public static boolean supportsSplitScreenMultiWindow(Context context) {
+ return supportsMultiWindow(context)
+ && Resources.getSystem().getBoolean(
+ com.android.internal.R.bool.config_supportsSplitScreenMultiWindow);
+ }
+}
diff --git a/core/java/android/app/ActivityThread.java b/core/java/android/app/ActivityThread.java
index 6fc14e768b64..f3c67310c05d 100644
--- a/core/java/android/app/ActivityThread.java
+++ b/core/java/android/app/ActivityThread.java
@@ -94,6 +94,7 @@ import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
import android.os.Process;
+import android.os.RemoteCallback;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.StrictMode;
@@ -739,6 +740,7 @@ public final class ActivityThread extends ClientTransactionHandler {
public boolean runGc;
String path;
ParcelFileDescriptor fd;
+ RemoteCallback finishCallback;
}
static final class UpdateCompatibilityData {
@@ -998,13 +1000,14 @@ public final class ActivityThread extends ClientTransactionHandler {
@Override
public void dumpHeap(boolean managed, boolean mallocInfo, boolean runGc, String path,
- ParcelFileDescriptor fd) {
+ ParcelFileDescriptor fd, RemoteCallback finishCallback) {
DumpHeapData dhd = new DumpHeapData();
dhd.managed = managed;
dhd.mallocInfo = mallocInfo;
dhd.runGc = runGc;
dhd.path = path;
dhd.fd = fd;
+ dhd.finishCallback = finishCallback;
sendMessage(H.DUMP_HEAP, dhd, 0, 0, true /*async*/);
}
@@ -1837,7 +1840,7 @@ public final class ActivityThread extends ClientTransactionHandler {
}
if (a != null) {
mNewActivities = null;
- IActivityManager am = ActivityManager.getService();
+ IActivityTaskManager am = ActivityTaskManager.getService();
ActivityClientRecord prev;
do {
if (localLOGV) Slog.v(
@@ -2990,7 +2993,7 @@ public final class ActivityThread extends ClientTransactionHandler {
private ContextImpl createBaseContextForActivity(ActivityClientRecord r) {
final int displayId;
try {
- displayId = ActivityManager.getService().getActivityDisplayId(r.token);
+ displayId = ActivityTaskManager.getService().getActivityDisplayId(r.token);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -3058,7 +3061,7 @@ public final class ActivityThread extends ClientTransactionHandler {
} else {
// If there was an error, for any reason, tell the activity manager to stop us.
try {
- ActivityManager.getService()
+ ActivityTaskManager.getService()
.finishActivity(r.token, Activity.RESULT_CANCELED, null,
Activity.DONT_FINISH_TASK_WITH_ACTIVITY);
} catch (RemoteException ex) {
@@ -3090,7 +3093,7 @@ public final class ActivityThread extends ClientTransactionHandler {
}
}
try {
- ActivityManager.getService().reportSizeConfigurations(r.token,
+ ActivityTaskManager.getService().reportSizeConfigurations(r.token,
horizontal.copyKeys(), vertical.copyKeys(), smallest.copyKeys());
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
@@ -3207,7 +3210,7 @@ public final class ActivityThread extends ClientTransactionHandler {
structure.setAcquisitionEndTime(SystemClock.uptimeMillis());
mLastAssistStructures.add(new WeakReference<>(structure));
- IActivityManager mgr = ActivityManager.getService();
+ IActivityTaskManager mgr = ActivityTaskManager.getService();
try {
mgr.reportAssistContextExtras(cmd.requestToken, data, structure, content, referrer);
} catch (RemoteException e) {
@@ -3835,7 +3838,7 @@ public final class ActivityThread extends ClientTransactionHandler {
boolean willBeVisible = !a.mStartedActivity;
if (!willBeVisible) {
try {
- willBeVisible = ActivityManager.getService().willActivityBeVisible(
+ willBeVisible = ActivityTaskManager.getService().willActivityBeVisible(
a.getActivityToken());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
@@ -4287,7 +4290,7 @@ public final class ActivityThread extends ClientTransactionHandler {
// Tell activity manager we slept.
try {
- ActivityManager.getService().activitySlept(r.token);
+ ActivityTaskManager.getService().activitySlept(r.token);
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
}
@@ -4534,7 +4537,7 @@ public final class ActivityThread extends ClientTransactionHandler {
}
if (finishing) {
try {
- ActivityManager.getService().activityDestroyed(token);
+ ActivityTaskManager.getService().activityDestroyed(token);
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
}
@@ -4787,7 +4790,7 @@ public final class ActivityThread extends ClientTransactionHandler {
@Override
public void reportRelaunch(IBinder token, PendingTransactionActions pendingActions) {
try {
- ActivityManager.getService().activityRelaunched(token);
+ ActivityTaskManager.getService().activityRelaunched(token);
final ActivityClientRecord r = mActivities.get(token);
if (pendingActions.shouldReportRelaunchToWindowManager() && r != null
&& r.window != null) {
@@ -5310,6 +5313,9 @@ public final class ActivityThread extends ClientTransactionHandler {
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
+ if (dhd.finishCallback != null) {
+ dhd.finishCallback.sendResult(null);
+ }
}
final void handleDispatchPackageBroadcast(int cmd, String[] packages) {
@@ -6509,7 +6515,7 @@ public final class ActivityThread extends ClientTransactionHandler {
+ " used=" + (dalvikUsed/1024));
mSomeActivitiesChanged = false;
try {
- mgr.releaseSomeActivities(mAppThread);
+ ActivityTaskManager.getService().releaseSomeActivities(mAppThread);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/core/java/android/app/ActivityView.java b/core/java/android/app/ActivityView.java
index e469098e22d5..c7fa33d1745d 100644
--- a/core/java/android/app/ActivityView.java
+++ b/core/java/android/app/ActivityView.java
@@ -64,6 +64,7 @@ public class ActivityView extends ViewGroup {
private StateCallback mActivityViewCallback;
private IActivityManager mActivityManager;
+ private IActivityTaskManager mActivityTaskManager;
private IInputForwarder mInputForwarder;
// Temp container to store view coordinates on screen.
private final int[] mLocationOnScreen = new int[2];
@@ -85,6 +86,7 @@ public class ActivityView extends ViewGroup {
super(context, attrs, defStyle);
mActivityManager = ActivityManager.getService();
+ mActivityTaskManager = ActivityTaskManager.getService();
mSurfaceView = new SurfaceView(context);
mSurfaceCallback = new SurfaceCallback();
mSurfaceView.getHolder().addCallback(mSurfaceCallback);
@@ -349,7 +351,7 @@ public class ActivityView extends ViewGroup {
mInputForwarder = InputManager.getInstance().createInputForwarder(displayId);
mTaskStackListener = new TaskStackListenerImpl();
try {
- mActivityManager.registerTaskStackListener(mTaskStackListener);
+ mActivityTaskManager.registerTaskStackListener(mTaskStackListener);
} catch (RemoteException e) {
Log.e(TAG, "Failed to register task stack listener", e);
}
@@ -369,7 +371,7 @@ public class ActivityView extends ViewGroup {
if (mTaskStackListener != null) {
try {
- mActivityManager.unregisterTaskStackListener(mTaskStackListener);
+ mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
} catch (RemoteException e) {
Log.e(TAG, "Failed to unregister task stack listener", e);
}
@@ -474,7 +476,7 @@ public class ActivityView extends ViewGroup {
// Find the topmost task on our virtual display - it will define the background
// color of the surface view during resizing.
final int displayId = mVirtualDisplay.getDisplay().getDisplayId();
- final List<StackInfo> stackInfoList = mActivityManager.getAllStackInfos();
+ final List<StackInfo> stackInfoList = mActivityTaskManager.getAllStackInfos();
// Iterate through stacks from top to bottom.
final int stackCount = stackInfoList.size();
diff --git a/core/java/android/app/AlarmManager.java b/core/java/android/app/AlarmManager.java
index 124f9338f781..f76f911db99b 100644
--- a/core/java/android/app/AlarmManager.java
+++ b/core/java/android/app/AlarmManager.java
@@ -28,7 +28,6 @@ import android.os.Handler;
import android.os.Parcel;
import android.os.Parcelable;
import android.os.RemoteException;
-import android.os.UserHandle;
import android.os.WorkSource;
import android.text.TextUtils;
import android.util.ArrayMap;
@@ -958,6 +957,7 @@ public class AlarmManager {
*
* @param millis time in milliseconds since the Epoch
*/
+ @RequiresPermission(android.Manifest.permission.SET_TIME)
public void setTime(long millis) {
try {
mService.setTime(millis);
@@ -981,6 +981,7 @@ public class AlarmManager {
* @param timeZone one of the Olson ids from the list returned by
* {@link java.util.TimeZone#getAvailableIDs}
*/
+ @RequiresPermission(android.Manifest.permission.SET_TIME_ZONE)
public void setTimeZone(String timeZone) {
if (TextUtils.isEmpty(timeZone)) {
return;
diff --git a/core/java/android/app/ContextImpl.java b/core/java/android/app/ContextImpl.java
index 95117862a8da..82088dc569e7 100644
--- a/core/java/android/app/ContextImpl.java
+++ b/core/java/android/app/ContextImpl.java
@@ -923,7 +923,7 @@ class ContextImpl extends Context {
@Override
public void startActivityAsUser(Intent intent, Bundle options, UserHandle user) {
try {
- ActivityManager.getService().startActivityAsUser(
+ ActivityTaskManager.getService().startActivityAsUser(
mMainThread.getApplicationThread(), getBasePackageName(), intent,
intent.resolveTypeIfNeeded(getContentResolver()),
null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options,
@@ -985,7 +985,7 @@ class ContextImpl extends Context {
fillInIntent.prepareToLeaveProcess(this);
resolvedType = fillInIntent.resolveTypeIfNeeded(getContentResolver());
}
- int result = ActivityManager.getService()
+ int result = ActivityTaskManager.getService()
.startActivityIntentSender(mMainThread.getApplicationThread(),
intent != null ? intent.getTarget() : null,
intent != null ? intent.getWhitelistToken() : null,
diff --git a/core/java/android/app/Dialog.java b/core/java/android/app/Dialog.java
index 1d35ba29e443..6557ac4bea11 100644
--- a/core/java/android/app/Dialog.java
+++ b/core/java/android/app/Dialog.java
@@ -291,10 +291,7 @@ public class Dialog implements DialogInterface, Window.Callback,
if (mWindow.hasFeature(Window.FEATURE_ACTION_BAR)) {
mWindow.invalidatePanelMenu(Window.FEATURE_ACTION_BAR);
}
- if (mDecor.getVisibility() != View.VISIBLE) {
- mDecor.setVisibility(View.VISIBLE);
- sendShowMessage();
- }
+ mDecor.setVisibility(View.VISIBLE);
}
return;
}
diff --git a/core/java/android/app/IActivityManager.aidl b/core/java/android/app/IActivityManager.aidl
index 569c2bd37b6a..8aae4063ae19 100644
--- a/core/java/android/app/IActivityManager.aidl
+++ b/core/java/android/app/IActivityManager.aidl
@@ -63,6 +63,7 @@ import android.os.IBinder;
import android.os.IProgressListener;
import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
+import android.os.RemoteCallback;
import android.os.StrictMode;
import android.os.WorkSource;
import android.service.voice.IVoiceInteractionSession;
@@ -104,7 +105,6 @@ interface IActivityManager {
in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode,
int flags, in ProfilerInfo profilerInfo, in Bundle options);
void unhandledBack();
-
boolean finishActivity(in IBinder token, int code, in Intent data, int finishTask);
Intent registerReceiver(in IApplicationThread caller, in String callerPackage,
in IIntentReceiver receiver, in IntentFilter filter,
@@ -118,25 +118,16 @@ interface IActivityManager {
oneway void finishReceiver(in IBinder who, int resultCode, in String resultData, in Bundle map,
boolean abortBroadcast, int flags);
void attachApplication(in IApplicationThread app, long startSeq);
- oneway void activityIdle(in IBinder token, in Configuration config,
- in boolean stopProfiling);
- void activityPaused(in IBinder token);
- oneway void activityStopped(in IBinder token, in Bundle state,
- in PersistableBundle persistentState, in CharSequence description);
- String getCallingPackage(in IBinder token);
- ComponentName getCallingActivity(in IBinder token);
List<ActivityManager.RunningTaskInfo> getTasks(int maxNum);
List<ActivityManager.RunningTaskInfo> getFilteredTasks(int maxNum, int ignoreActivityType,
int ignoreWindowingMode);
void moveTaskToFront(int task, int flags, in Bundle options);
- void moveTaskBackwards(int task);
int getTaskForActivity(in IBinder token, in boolean onlyRoot);
ContentProviderHolder getContentProvider(in IApplicationThread caller,
in String name, int userId, boolean stable);
void publishContentProviders(in IApplicationThread caller,
in List<ContentProviderHolder> providers);
boolean refContentProvider(in IBinder connection, int stableDelta, int unstableDelta);
- void finishSubActivity(in IBinder token, in String resultWho, int requestCode);
PendingIntent getRunningServiceControlPanel(in ComponentName service);
ComponentName startService(in IApplicationThread caller, in Intent service,
in String resolvedType, boolean requireForeground, in String callingPackage, int userId);
@@ -147,7 +138,6 @@ interface IActivityManager {
in String callingPackage, int userId);
boolean unbindService(in IServiceConnection connection);
void publishService(in IBinder token, in Intent intent, in IBinder service);
- void activityResumed(in IBinder token);
void setDebugApp(in String packageName, boolean waitForDebugger, boolean persistent);
void setAgentApp(in String packageName, @nullable String agent);
void setAlwaysFinish(boolean enabled);
@@ -173,8 +163,6 @@ interface IActivityManager {
*/
boolean updateConfiguration(in Configuration values);
boolean stopServiceToken(in ComponentName className, in IBinder token, int startId);
- ComponentName getActivityClassForToken(in IBinder token);
- String getPackageForToken(in IBinder token);
void setProcessLimit(int max);
int getProcessLimit();
int checkPermission(in String permission, int pid, int uid);
@@ -194,7 +182,6 @@ interface IActivityManager {
ParceledListSlice getRecentTasks(int maxNum, int flags, int userId);
oneway void serviceDoneExecuting(in IBinder token, int type, int startId, int res);
- oneway void activityDestroyed(in IBinder token);
IIntentSender getIntentSender(int type, in String packageName, in IBinder token,
in String resultWho, int requestCode, in Intent[] intents, in String[] resolvedTypes,
int flags, in Bundle options, int userId);
@@ -203,13 +190,10 @@ interface IActivityManager {
void registerIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver);
void unregisterIntentSenderCancelListener(in IIntentSender sender, in IResultReceiver receiver);
void enterSafeMode();
- boolean startNextMatchingActivity(in IBinder callingActivity,
- in Intent intent, in Bundle options);
void noteWakeupAlarm(in IIntentSender sender, in WorkSource workSource, int sourceUid,
in String sourcePkg, in String tag);
void removeContentProvider(in IBinder connection, boolean stable);
void setRequestedOrientation(in IBinder token, int requestedOrientation);
- int getRequestedOrientation(in IBinder token);
void unbindFinished(in IBinder token, in Intent service, boolean doRebind);
void setProcessImportant(in IBinder token, int pid, boolean isForeground, String reason);
void setServiceForeground(in ComponentName className, in IBinder token,
@@ -222,7 +206,6 @@ interface IActivityManager {
void forceStopPackage(in String packageName, int userId);
boolean killPids(in int[] pids, in String reason, boolean secure);
List<ActivityManager.RunningServiceInfo> getServices(int maxNum, int flags);
- ActivityManager.TaskDescription getTaskDescription(int taskId);
// Retrieve running application processes in the system
List<ActivityManager.RunningAppProcessInfo> getRunningAppProcesses();
// Get device configuration
@@ -245,26 +228,11 @@ interface IActivityManager {
void closeSystemDialogs(in String reason);
Debug.MemoryInfo[] getProcessMemoryInfo(in int[] pids);
void killApplicationProcess(in String processName, int uid);
- int startActivityIntentSender(in IApplicationThread caller,
- in IIntentSender target, in IBinder whitelistToken, in Intent fillInIntent,
- in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode,
- int flagsMask, int flagsValues, in Bundle options);
- void overridePendingTransition(in IBinder token, in String packageName,
- int enterAnim, int exitAnim);
// Special low-level communication with activity manager.
boolean handleApplicationWtf(in IBinder app, in String tag, boolean system,
in ApplicationErrorReport.ParcelableCrashInfo crashInfo);
void killBackgroundProcesses(in String packageName, int userId);
boolean isUserAMonkey();
- WaitResult startActivityAndWait(in IApplicationThread caller, in String callingPackage,
- in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
- int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options,
- int userId);
- boolean willActivityBeVisible(in IBinder token);
- int startActivityWithConfig(in IApplicationThread caller, in String callingPackage,
- in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
- int requestCode, int startFlags, in Configuration newConfig,
- in Bundle options, int userId);
// Retrieve info of applications installed on external media that are currently
// running.
List<ApplicationInfo> getRunningExternalApplications();
@@ -275,8 +243,6 @@ interface IActivityManager {
// ActivityManagerService remaining set.
void handleApplicationStrictModeViolation(in IBinder app, int violationMask,
in StrictMode.ViolationInfo crashInfo);
- boolean isImmersive(in IBinder token);
- void setImmersive(in IBinder token, boolean immersive);
boolean isTopActivityImmersive();
void crashApplication(int uid, int initialPid, in String packageName, int userId, in String message);
String getProviderMimeType(in Uri uri, int userId);
@@ -288,20 +254,14 @@ interface IActivityManager {
int modeFlags, int userId);
// Cause the specified process to dump the specified heap.
boolean dumpHeap(in String process, int userId, boolean managed, boolean mallocInfo,
- boolean runGc, in String path, in ParcelFileDescriptor fd);
- int startActivities(in IApplicationThread caller, in String callingPackage,
- in Intent[] intents, in String[] resolvedTypes, in IBinder resultTo,
- in Bundle options, int userId);
+ boolean runGc, in String path, in ParcelFileDescriptor fd,
+ in RemoteCallback finishCallback);
boolean isUserRunning(int userid, int flags);
- oneway void activitySlept(in IBinder token);
- int getFrontActivityScreenCompatMode();
- void setFrontActivityScreenCompatMode(int mode);
int getPackageScreenCompatMode(in String packageName);
void setPackageScreenCompatMode(in String packageName, int mode);
boolean getPackageAskScreenCompat(in String packageName);
void setPackageAskScreenCompat(in String packageName, boolean ask);
boolean switchUser(int userid);
- void setFocusedTask(int taskId);
boolean removeTask(int taskId);
void registerProcessObserver(in IProcessObserver observer);
void unregisterProcessObserver(in IProcessObserver observer);
@@ -317,9 +277,6 @@ interface IActivityManager {
void getMyMemoryState(out ActivityManager.RunningAppProcessInfo outInfo);
boolean killProcessesBelowForeground(in String reason);
UserInfo getCurrentUser();
- boolean shouldUpRecreateTask(in IBinder token, in String destAffinity);
- boolean navigateUpTo(in IBinder token, in Intent target, int resultCode,
- in Intent resultData);
/**
* Informs ActivityManagerService that the keyguard is showing.
*
@@ -331,7 +288,6 @@ interface IActivityManager {
*/
void setLockScreenShown(boolean showingKeyguard, boolean showingAod,
int secondaryDisplayShowing);
- boolean finishActivityAffinity(in IBinder token);
// This is not public because you need to be very careful in how you
// manage your activity to make sure it is always the uid you expect.
int getLaunchedFromUid(in IBinder activityToken);
@@ -381,9 +337,6 @@ interface IActivityManager {
long inputDispatchingTimedOut(int pid, boolean aboveSystem, in String reason);
void clearPendingBackup();
Intent getIntentForIntentSender(in IIntentSender sender);
- Bundle getAssistContextExtras(int requestType);
- void reportAssistContextExtras(in IBinder token, in Bundle extras,
- in AssistStructure structure, in AssistContent content, in Uri referrer);
// This is not public because you need to be very careful in how you
// manage your activity to make sure it is always the uid you expect.
String getLaunchedFromPackage(in IBinder activityToken);
@@ -391,14 +344,7 @@ interface IActivityManager {
void setUserIsMonkey(boolean monkey);
void hang(in IBinder who, boolean allowRestart);
- /**
- * Sets the windowing mode for a specific task. Only works on tasks of type
- * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}
- * @param taskId The id of the task to set the windowing mode for.
- * @param windowingMode The windowing mode to set for the task.
- * @param toTop If the task should be moved to the top once the windowing mode changes.
- */
- void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop);
+ List<ActivityManager.StackInfo> getAllStackInfos();
void moveTaskToStack(int taskId, int stackId, boolean toTop);
/**
* Resizes the input stack id to the given bounds.
@@ -416,14 +362,8 @@ interface IActivityManager {
*/
void resizeStack(int stackId, in Rect bounds, boolean allowResizeInDockedMode,
boolean preserveWindows, boolean animate, int animationDuration);
- List<ActivityManager.StackInfo> getAllStackInfos();
void setFocusedStack(int stackId);
ActivityManager.StackInfo getFocusedStackInfo();
- ActivityManager.StackInfo getStackInfo(int windowingMode, int activityType);
- boolean convertFromTranslucent(in IBinder token);
- boolean convertToTranslucent(in IBinder token, in Bundle options);
- void notifyActivityDrawn(in IBinder token);
- void reportActivityFullyDrawn(in IBinder token, boolean restoredFromBundle);
void restart();
void performIdleMaintenance();
void takePersistableUriPermission(in Uri uri, int modeFlags, String toPackage, int userId);
@@ -431,60 +371,26 @@ interface IActivityManager {
ParceledListSlice getPersistedUriPermissions(in String packageName, boolean incoming);
void appNotRespondingViaProvider(in IBinder connection);
Rect getTaskBounds(int taskId);
- int getActivityDisplayId(in IBinder activityToken);
boolean setProcessMemoryTrimLevel(in String process, int uid, int level);
// Start of L transactions
String getTagForIntentSender(in IIntentSender sender, in String prefix);
boolean startUserInBackground(int userid);
- void startLockTaskModeByToken(in IBinder token);
- void stopLockTaskModeByToken(in IBinder token);
boolean isInLockTaskMode();
- void setTaskDescription(in IBinder token, in ActivityManager.TaskDescription values);
- int startVoiceActivity(in String callingPackage, int callingPid, int callingUid,
- in Intent intent, in String resolvedType, in IVoiceInteractionSession session,
- in IVoiceInteractor interactor, int flags, in ProfilerInfo profilerInfo,
- in Bundle options, int userId);
- int startAssistantActivity(in String callingPackage, int callingPid, int callingUid,
- in Intent intent, in String resolvedType, in Bundle options, int userId);
void startRecentsActivity(in Intent intent, in IAssistDataReceiver assistDataReceiver,
in IRecentsAnimationRunner recentsAnimationRunner);
void cancelRecentsAnimation(boolean restoreHomeStackPosition);
int startActivityFromRecents(int taskId, in Bundle options);
- Bundle getActivityOptions(in IBinder token);
- List<IBinder> getAppTasks(in String callingPackage);
void startSystemLockTaskMode(int taskId);
- void stopSystemLockTaskMode();
- void finishVoiceTask(in IVoiceInteractionSession session);
boolean isTopOfTask(in IBinder token);
- void notifyLaunchTaskBehindComplete(in IBinder token);
- void notifyEnterAnimationComplete(in IBinder token);
- int startActivityAsCaller(in IApplicationThread caller, in String callingPackage,
- in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
- int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options,
- boolean ignoreTargetSecurity, int userId);
- int addAppTask(in IBinder activityToken, in Intent intent,
- in ActivityManager.TaskDescription description, in Bitmap thumbnail);
- Point getAppTaskThumbnailSize();
- boolean releaseActivityInstance(in IBinder token);
- void releaseSomeActivities(in IApplicationThread app);
void bootAnimationComplete();
- Bitmap getTaskDescriptionIcon(in String filename, int userId);
- boolean launchAssistIntent(in Intent intent, int requestType, in String hint, int userHandle,
- in Bundle args);
- void startInPlaceAnimationOnFrontMostApplication(in Bundle opts);
int checkPermissionWithToken(in String permission, int pid, int uid,
in IBinder callerToken);
void registerTaskStackListener(in ITaskStackListener listener);
void unregisterTaskStackListener(in ITaskStackListener listener);
-
void notifyCleartextNetwork(int uid, in byte[] firstPacket);
- int createStackOnDisplay(int displayId);
void setTaskResizeable(int taskId, int resizeableMode);
- boolean requestAssistContextExtras(int requestType, in IAssistDataReceiver receiver,
- in Bundle receiverExtras, in IBinder activityToken,
- boolean focused, boolean newSessionId);
void resizeTask(int taskId, in Rect bounds, int resizeMode);
int getLockTaskModeState();
void setDumpHeapDebugLimit(in String processName, int uid, long maxMemSize,
@@ -495,19 +401,8 @@ interface IActivityManager {
void noteAlarmStart(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag);
void noteAlarmFinish(in IIntentSender sender, in WorkSource workSource, int sourceUid, in String tag);
int getPackageProcessState(in String packageName, in String callingPackage);
- oneway void showLockTaskEscapeMessage(in IBinder token);
void updateDeviceOwner(in String packageName);
- /**
- * Notify the system that the keyguard is going away.
- *
- * @param flags See {@link android.view.WindowManagerPolicyConstants#KEYGUARD_GOING_AWAY_FLAG_TO_SHADE}
- * etc.
- */
- void keyguardGoingAway(int flags);
int getUidProcessState(int uid, in String callingPackage);
- boolean isAssistDataAllowedOnCurrentActivity();
- boolean showAssistFromActivity(in IBinder token, in Bundle args);
- boolean isRootVoiceInteraction(in IBinder token);
// Start of N transactions
@@ -522,37 +417,12 @@ interface IActivityManager {
* different stack.
*/
void positionTaskInStack(int taskId, int stackId, int position);
- void exitFreeformMode(in IBinder token);
- void reportSizeConfigurations(in IBinder token, in int[] horizontalSizeConfiguration,
- in int[] verticalSizeConfigurations, in int[] smallestWidthConfigurations);
- boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
- boolean animate, in Rect initialBounds, boolean showRecents);
- /**
- * Dismisses split-screen multi-window mode.
- * {@param toTop} If true the current primary split-screen stack will be placed or left on top.
- */
- void dismissSplitScreenMode(boolean toTop);
- /**
- * Dismisses PiP
- * @param animate True if the dismissal should be animated.
- * @param animationDuration The duration of the resize animation in milliseconds or -1 if the
- * default animation duration should be used.
- */
- void dismissPip(boolean animate, int animationDuration);
void suppressResizeConfigChanges(boolean suppress);
- void moveTasksToFullscreenStack(int fromStackId, boolean onTop);
boolean moveTopActivityToPinnedStack(int stackId, in Rect bounds);
boolean isAppStartModeDisabled(int uid, in String packageName);
boolean unlockUser(int userid, in byte[] token, in byte[] secret,
in IProgressListener listener);
- boolean isInMultiWindowMode(in IBinder token);
- boolean isInPictureInPictureMode(in IBinder token);
void killPackageDependents(in String packageName, int userId);
- boolean enterPictureInPictureMode(in IBinder token, in PictureInPictureParams params);
- void setPictureInPictureParams(in IBinder token, in PictureInPictureParams params);
- int getMaxNumPictureInPictureActions(in IBinder token);
- void activityRelaunched(in IBinder token);
- IBinder getUriPermissionOwnerForActivity(in IBinder activityToken);
/**
* Resizes the docked stack, and all other stacks as the result of the dock stack bounds change.
*
@@ -575,12 +445,6 @@ interface IActivityManager {
void resizeDockedStack(in Rect dockedBounds, in Rect tempDockedTaskBounds,
in Rect tempDockedTaskInsetBounds,
in Rect tempOtherTaskBounds, in Rect tempOtherTaskInsetBounds);
- /**
- * Sets whether we are currently in an interactive split screen resize operation where we
- * are changing the docked stack size.
- */
- void setSplitScreenResizing(boolean resizing);
- int setVrMode(in IBinder token, boolean enabled, in ComponentName packageName);
// Gets the URI permissions granted to an arbitrary package (or all packages if null)
// NOTE: this is different from getPersistedUriPermissions(), which returns the URIs the package
// granted to another packages (instead of those granted to it).
@@ -588,31 +452,9 @@ interface IActivityManager {
// Clears the URI permissions granted to an arbitrary package.
void clearGrantedUriPermissions(in String packageName, int userId);
boolean isAppForeground(int uid);
- void startLocalVoiceInteraction(in IBinder token, in Bundle options);
- void stopLocalVoiceInteraction(in IBinder token);
- boolean supportsLocalVoiceInteraction();
- void notifyPinnedStackAnimationStarted();
- void notifyPinnedStackAnimationEnded();
void removeStack(int stackId);
- /**
- * Removes stacks in the input windowing modes from the system if they are of activity type
- * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
- */
- void removeStacksInWindowingModes(in int[] windowingModes);
- /** Removes stack of the activity types from the system. */
- void removeStacksWithActivityTypes(in int[] activityTypes);
void makePackageIdle(String packageName, int userId);
int getMemoryTrimLevel();
- /**
- * Resizes the pinned stack.
- *
- * @param pinnedBounds The bounds for the pinned stack.
- * @param tempPinnedTaskBounds The temporary bounds for the tasks in the pinned stack, which
- * might be different from the stack bounds to allow more
- * flexibility while resizing, or {@code null} if they should be the
- * same as the stack bounds.
- */
- void resizePinnedStack(in Rect pinnedBounds, in Rect tempPinnedTaskBounds);
boolean isVrModePackageEnabled(in ComponentName packageName);
void notifyLockedProfile(int userId);
void startConfirmDeviceCredentialIntent(in Intent intent, in Bundle options);
@@ -636,25 +478,9 @@ interface IActivityManager {
void setHasTopUi(boolean hasTopUi);
// Start of O transactions
- /**
- * Updates override configuration applied to specific display.
- * @param values Update values for display configuration. If null is passed it will request the
- * Window Manager to compute new config for the specified display.
- * @param displayId Id of the display to apply the config to.
- * @throws RemoteException
- * @return Returns true if the configuration was updated.
- */
- boolean updateDisplayOverrideConfiguration(in Configuration values, int displayId);
- void moveStackToDisplay(int stackId, int displayId);
- boolean requestAutofillData(in IAssistDataReceiver receiver, in Bundle receiverExtras,
- in IBinder activityToken, int flags);
- void dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback,
- in CharSequence message);
int restartUserInBackground(int userId);
-
/** Cancels the window transitions for the given task. */
void cancelTaskWindowTransition(int taskId);
-
/**
* @param taskId the id of the task to retrieve the sAutoapshots for
* @param reducedResolution if set, if the snapshot needs to be loaded from disk, this will load
@@ -662,56 +488,19 @@ interface IActivityManager {
* @return a graphic buffer representing a screenshot of a task
*/
ActivityManager.TaskSnapshot getTaskSnapshot(int taskId, boolean reducedResolution);
-
void scheduleApplicationInfoChanged(in List<String> packageNames, int userId);
void setPersistentVrThread(int tid);
void waitForNetworkStateUpdate(long procStateSeq);
-
- /**
- * See {@link android.app.Activity#setDisablePreviewScreenshots}
- */
- void setDisablePreviewScreenshots(IBinder token, boolean disable);
-
- /**
- * Return the user id of last resumed activity.
- */
- int getLastResumedActivityUserId();
-
/**
* Add a bare uid to the background restrictions whitelist. Only the system uid may call this.
*/
void backgroundWhitelistUid(int uid);
// Start of P transactions
- void updateLockTaskFeatures(int userId, int flags);
-
- // WARNING: when these transactions are updated, check if they are any callers on the native
- // side. If so, make sure they are using the correct transaction ids and arguments.
- // If a transaction which will also be used on the native side is being inserted, add it
- // alongside with other transactions of this kind at the top of this file.
-
- void setShowWhenLocked(in IBinder token, boolean showWhenLocked);
- void setTurnScreenOn(in IBinder token, boolean turnScreenOn);
-
/**
* Similar to {@link #startUserInBackground(int userId), but with a listener to report
* user unlock progress.
*/
boolean startUserInBackgroundWithListener(int userid, IProgressListener unlockProgressListener);
-
- /**
- * Registers remote animations for a specific activity.
- */
- void registerRemoteAnimations(in IBinder token, in RemoteAnimationDefinition definition);
-
- /**
- * Registers a remote animation to be run for all activity starts from a certain package during
- * a short predefined amount of time.
- */
- void registerRemoteAnimationForNextActivityStart(in String packageName,
- in RemoteAnimationAdapter adapter);
-
- /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */
- void alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity);
}
diff --git a/core/java/android/app/IActivityTaskManager.aidl b/core/java/android/app/IActivityTaskManager.aidl
new file mode 100644
index 000000000000..d2c6402d64b3
--- /dev/null
+++ b/core/java/android/app/IActivityTaskManager.aidl
@@ -0,0 +1,418 @@
+/*
+ * 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 android.app;
+
+import android.app.ActivityManager;
+import android.app.ApplicationErrorReport;
+import android.app.ContentProviderHolder;
+import android.app.GrantedUriPermission;
+import android.app.IApplicationThread;
+import android.app.IActivityController;
+import android.app.IAppTask;
+import android.app.IAssistDataReceiver;
+import android.app.IInstrumentationWatcher;
+import android.app.IProcessObserver;
+import android.app.IServiceConnection;
+import android.app.IStopUserCallback;
+import android.app.ITaskStackListener;
+import android.app.IUiAutomationConnection;
+import android.app.IUidObserver;
+import android.app.IUserSwitchObserver;
+import android.app.Notification;
+import android.app.PendingIntent;
+import android.app.PictureInPictureParams;
+import android.app.ProfilerInfo;
+import android.app.WaitResult;
+import android.app.assist.AssistContent;
+import android.app.assist.AssistStructure;
+import android.content.ComponentName;
+import android.content.IIntentReceiver;
+import android.content.IIntentSender;
+import android.content.Intent;
+import android.content.IntentFilter;
+import android.content.IntentSender;
+import android.content.pm.ApplicationInfo;
+import android.content.pm.ConfigurationInfo;
+import android.content.pm.IPackageDataObserver;
+import android.content.pm.ParceledListSlice;
+import android.content.pm.ProviderInfo;
+import android.content.pm.UserInfo;
+import android.content.res.Configuration;
+import android.graphics.Bitmap;
+import android.graphics.GraphicBuffer;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.net.Uri;
+import android.os.Bundle;
+import android.os.Debug;
+import android.os.IBinder;
+import android.os.IProgressListener;
+import android.os.ParcelFileDescriptor;
+import android.os.PersistableBundle;
+import android.os.StrictMode;
+import android.os.WorkSource;
+import android.service.voice.IVoiceInteractionSession;
+import android.view.IRecentsAnimationRunner;
+import android.view.RemoteAnimationDefinition;
+import android.view.RemoteAnimationAdapter;
+import com.android.internal.app.IVoiceInteractor;
+import com.android.internal.os.IResultReceiver;
+import com.android.internal.policy.IKeyguardDismissCallback;
+
+import java.util.List;
+
+/**
+ * System private API for talking with the activity task manager that handles how activities are
+ * managed on screen.
+ *
+ * {@hide}
+ */
+interface IActivityTaskManager {
+ int startActivity(in IApplicationThread caller, in String callingPackage, in Intent intent,
+ in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode,
+ int flags, in ProfilerInfo profilerInfo, in Bundle options);
+ int startActivities(in IApplicationThread caller, in String callingPackage,
+ in Intent[] intents, in String[] resolvedTypes, in IBinder resultTo,
+ in Bundle options, int userId);
+ int startActivityAsUser(in IApplicationThread caller, in String callingPackage,
+ in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
+ int requestCode, int flags, in ProfilerInfo profilerInfo,
+ in Bundle options, int userId);
+ boolean startNextMatchingActivity(in IBinder callingActivity,
+ in Intent intent, in Bundle options);
+ int startActivityIntentSender(in IApplicationThread caller,
+ in IIntentSender target, in IBinder whitelistToken, in Intent fillInIntent,
+ in String resolvedType, in IBinder resultTo, in String resultWho, int requestCode,
+ int flagsMask, int flagsValues, in Bundle options);
+ WaitResult startActivityAndWait(in IApplicationThread caller, in String callingPackage,
+ in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
+ int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options,
+ int userId);
+ int startActivityWithConfig(in IApplicationThread caller, in String callingPackage,
+ in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
+ int requestCode, int startFlags, in Configuration newConfig,
+ in Bundle options, int userId);
+ int startVoiceActivity(in String callingPackage, int callingPid, int callingUid,
+ in Intent intent, in String resolvedType, in IVoiceInteractionSession session,
+ in IVoiceInteractor interactor, int flags, in ProfilerInfo profilerInfo,
+ in Bundle options, int userId);
+ int startAssistantActivity(in String callingPackage, int callingPid, int callingUid,
+ in Intent intent, in String resolvedType, in Bundle options, int userId);
+ void startRecentsActivity(in Intent intent, in IAssistDataReceiver assistDataReceiver,
+ in IRecentsAnimationRunner recentsAnimationRunner);
+ int startActivityFromRecents(int taskId, in Bundle options);
+ int startActivityAsCaller(in IApplicationThread caller, in String callingPackage,
+ in Intent intent, in String resolvedType, in IBinder resultTo, in String resultWho,
+ int requestCode, int flags, in ProfilerInfo profilerInfo, in Bundle options,
+ boolean ignoreTargetSecurity, int userId);
+
+ void unhandledBack();
+ boolean finishActivity(in IBinder token, int code, in Intent data, int finishTask);
+ boolean finishActivityAffinity(in IBinder token);
+
+ oneway void activityIdle(in IBinder token, in Configuration config,
+ in boolean stopProfiling);
+ void activityResumed(in IBinder token);
+ void activityPaused(in IBinder token);
+ oneway void activityStopped(in IBinder token, in Bundle state,
+ in PersistableBundle persistentState, in CharSequence description);
+ oneway void activityDestroyed(in IBinder token);
+ void activityRelaunched(in IBinder token);
+ oneway void activitySlept(in IBinder token);
+ int getFrontActivityScreenCompatMode();
+ void setFrontActivityScreenCompatMode(int mode);
+ String getCallingPackage(in IBinder token);
+ ComponentName getCallingActivity(in IBinder token);
+ void setFocusedTask(int taskId);
+ boolean removeTask(int taskId);
+ List<ActivityManager.RunningTaskInfo> getTasks(int maxNum);
+ List<ActivityManager.RunningTaskInfo> getFilteredTasks(int maxNum, int ignoreActivityType,
+ int ignoreWindowingMode);
+ boolean shouldUpRecreateTask(in IBinder token, in String destAffinity);
+ boolean navigateUpTo(in IBinder token, in Intent target, int resultCode,
+ in Intent resultData);
+ void moveTaskToFront(int task, int flags, in Bundle options);
+ int getTaskForActivity(in IBinder token, in boolean onlyRoot);
+ void finishSubActivity(in IBinder token, in String resultWho, int requestCode);
+ ParceledListSlice getRecentTasks(int maxNum, int flags, int userId);
+ boolean willActivityBeVisible(in IBinder token);
+ void setRequestedOrientation(in IBinder token, int requestedOrientation);
+ int getRequestedOrientation(in IBinder token);
+ boolean convertFromTranslucent(in IBinder token);
+ boolean convertToTranslucent(in IBinder token, in Bundle options);
+ void notifyActivityDrawn(in IBinder token);
+ void reportActivityFullyDrawn(in IBinder token, boolean restoredFromBundle);
+ int getActivityDisplayId(in IBinder activityToken);
+ boolean isImmersive(in IBinder token);
+ void setImmersive(in IBinder token, boolean immersive);
+ boolean isTopActivityImmersive();
+ boolean moveActivityTaskToBack(in IBinder token, boolean nonRoot);
+ ActivityManager.TaskDescription getTaskDescription(int taskId);
+ void overridePendingTransition(in IBinder token, in String packageName,
+ int enterAnim, int exitAnim);
+ int getLaunchedFromUid(in IBinder activityToken);
+ String getLaunchedFromPackage(in IBinder activityToken);
+ void reportAssistContextExtras(in IBinder token, in Bundle extras,
+ in AssistStructure structure, in AssistContent content, in Uri referrer);
+
+ void setFocusedStack(int stackId);
+ ActivityManager.StackInfo getFocusedStackInfo();
+ Rect getTaskBounds(int taskId);
+
+ void cancelRecentsAnimation(boolean restoreHomeStackPosition);
+ void startLockTaskModeByToken(in IBinder token);
+ void stopLockTaskModeByToken(in IBinder token);
+ boolean isInLockTaskMode();
+ int getLockTaskModeState();
+ void setTaskDescription(in IBinder token, in ActivityManager.TaskDescription values);
+ Bundle getActivityOptions(in IBinder token);
+ List<IBinder> getAppTasks(in String callingPackage);
+ void startSystemLockTaskMode(int taskId);
+ void stopSystemLockTaskMode();
+ void finishVoiceTask(in IVoiceInteractionSession session);
+ boolean isTopOfTask(in IBinder token);
+ void notifyLaunchTaskBehindComplete(in IBinder token);
+ void notifyEnterAnimationComplete(in IBinder token);
+ int addAppTask(in IBinder activityToken, in Intent intent,
+ in ActivityManager.TaskDescription description, in Bitmap thumbnail);
+ Point getAppTaskThumbnailSize();
+ boolean releaseActivityInstance(in IBinder token);
+ void releaseSomeActivities(in IApplicationThread app);
+ Bitmap getTaskDescriptionIcon(in String filename, int userId);
+ void startInPlaceAnimationOnFrontMostApplication(in Bundle opts);
+ void registerTaskStackListener(in ITaskStackListener listener);
+ void unregisterTaskStackListener(in ITaskStackListener listener);
+ int createStackOnDisplay(int displayId);
+ void setTaskResizeable(int taskId, int resizeableMode);
+ void exitFreeformMode(in IBinder token);
+ void resizeTask(int taskId, in Rect bounds, int resizeMode);
+ void moveStackToDisplay(int stackId, int displayId);
+ void removeStack(int stackId);
+
+ /**
+ * Sets the windowing mode for a specific task. Only works on tasks of type
+ * {@link WindowConfiguration#ACTIVITY_TYPE_STANDARD}
+ * @param taskId The id of the task to set the windowing mode for.
+ * @param windowingMode The windowing mode to set for the task.
+ * @param toTop If the task should be moved to the top once the windowing mode changes.
+ */
+ void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop);
+ void moveTaskToStack(int taskId, int stackId, boolean toTop);
+ /**
+ * Resizes the input stack id to the given bounds.
+ *
+ * @param stackId Id of the stack to resize.
+ * @param bounds Bounds to resize the stack to or {@code null} for fullscreen.
+ * @param allowResizeInDockedMode True if the resize should be allowed when the docked stack is
+ * active.
+ * @param preserveWindows True if the windows of activities contained in the stack should be
+ * preserved.
+ * @param animate True if the stack resize should be animated.
+ * @param animationDuration The duration of the resize animation in milliseconds or -1 if the
+ * default animation duration should be used.
+ * @throws RemoteException
+ */
+ void resizeStack(int stackId, in Rect bounds, boolean allowResizeInDockedMode,
+ boolean preserveWindows, boolean animate, int animationDuration);
+ boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
+ boolean animate, in Rect initialBounds, boolean showRecents);
+
+
+ /**
+ * Removes stacks in the input windowing modes from the system if they are of activity type
+ * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
+ */
+ void removeStacksInWindowingModes(in int[] windowingModes);
+ /** Removes stack of the activity types from the system. */
+ void removeStacksWithActivityTypes(in int[] activityTypes);
+
+ List<ActivityManager.StackInfo> getAllStackInfos();
+ ActivityManager.StackInfo getStackInfo(int windowingMode, int activityType);
+
+ /**
+ * Informs ActivityManagerService that the keyguard is showing.
+ *
+ * @param showingKeyguard True if the keyguard is showing, false otherwise.
+ * @param showingAod True if AOD is showing, false otherwise.
+ * @param secondaryDisplayShowing The displayId of the secondary display on which the keyguard
+ * is showing, or INVALID_DISPLAY if there is no such display. Only meaningful if
+ * showing is true.
+ */
+ void setLockScreenShown(boolean showingKeyguard, boolean showingAod,
+ int secondaryDisplayShowing);
+ Bundle getAssistContextExtras(int requestType);
+ boolean launchAssistIntent(in Intent intent, int requestType, in String hint, int userHandle,
+ in Bundle args);
+ boolean requestAssistContextExtras(int requestType, in IAssistDataReceiver receiver,
+ in Bundle receiverExtras, in IBinder activityToken,
+ boolean focused, boolean newSessionId);
+ boolean requestAutofillData(in IAssistDataReceiver receiver, in Bundle receiverExtras,
+ in IBinder activityToken, int flags);
+ boolean isAssistDataAllowedOnCurrentActivity();
+ boolean showAssistFromActivity(in IBinder token, in Bundle args);
+ boolean isRootVoiceInteraction(in IBinder token);
+ oneway void showLockTaskEscapeMessage(in IBinder token);
+
+ /**
+ * Notify the system that the keyguard is going away.
+ *
+ * @param flags See
+ * {@link android.view.WindowManagerPolicyConstants#KEYGUARD_GOING_AWAY_FLAG_TO_SHADE}
+ * etc.
+ */
+ void keyguardGoingAway(int flags);
+ ComponentName getActivityClassForToken(in IBinder token);
+ String getPackageForToken(in IBinder token);
+
+ /**
+ * Try to place task to provided position. The final position might be different depending on
+ * current user and stacks state. The task will be moved to target stack if it's currently in
+ * different stack.
+ */
+ void positionTaskInStack(int taskId, int stackId, int position);
+ void reportSizeConfigurations(in IBinder token, in int[] horizontalSizeConfiguration,
+ in int[] verticalSizeConfigurations, in int[] smallestWidthConfigurations);
+ /**
+ * Dismisses split-screen multi-window mode.
+ * {@param toTop} If true the current primary split-screen stack will be placed or left on top.
+ */
+ void dismissSplitScreenMode(boolean toTop);
+
+ /**
+ * Dismisses PiP
+ * @param animate True if the dismissal should be animated.
+ * @param animationDuration The duration of the resize animation in milliseconds or -1 if the
+ * default animation duration should be used.
+ */
+ void dismissPip(boolean animate, int animationDuration);
+ void suppressResizeConfigChanges(boolean suppress);
+ void moveTasksToFullscreenStack(int fromStackId, boolean onTop);
+ boolean moveTopActivityToPinnedStack(int stackId, in Rect bounds);
+ boolean isInMultiWindowMode(in IBinder token);
+ boolean isInPictureInPictureMode(in IBinder token);
+ boolean enterPictureInPictureMode(in IBinder token, in PictureInPictureParams params);
+ void setPictureInPictureParams(in IBinder token, in PictureInPictureParams params);
+ int getMaxNumPictureInPictureActions(in IBinder token);
+ IBinder getUriPermissionOwnerForActivity(in IBinder activityToken);
+
+ /**
+ * Resizes the docked stack, and all other stacks as the result of the dock stack bounds change.
+ *
+ * @param dockedBounds The bounds for the docked stack.
+ * @param tempDockedTaskBounds The temporary bounds for the tasks in the docked stack, which
+ * might be different from the stack bounds to allow more
+ * flexibility while resizing, or {@code null} if they should be the
+ * same as the stack bounds.
+ * @param tempDockedTaskInsetBounds The temporary bounds for the tasks to calculate the insets.
+ * When resizing, we usually "freeze" the layout of a task. To
+ * achieve that, we also need to "freeze" the insets, which
+ * gets achieved by changing task bounds but not bounds used
+ * to calculate the insets in this transient state
+ * @param tempOtherTaskBounds The temporary bounds for the tasks in all other stacks, or
+ * {@code null} if they should be the same as the stack bounds.
+ * @param tempOtherTaskInsetBounds Like {@code tempDockedTaskInsetBounds}, but for the other
+ * stacks.
+ * @throws RemoteException
+ */
+ void resizeDockedStack(in Rect dockedBounds, in Rect tempDockedTaskBounds,
+ in Rect tempDockedTaskInsetBounds,
+ in Rect tempOtherTaskBounds, in Rect tempOtherTaskInsetBounds);
+
+ /**
+ * Sets whether we are currently in an interactive split screen resize operation where we
+ * are changing the docked stack size.
+ */
+ void setSplitScreenResizing(boolean resizing);
+ int setVrMode(in IBinder token, boolean enabled, in ComponentName packageName);
+ void startLocalVoiceInteraction(in IBinder token, in Bundle options);
+ void stopLocalVoiceInteraction(in IBinder token);
+ boolean supportsLocalVoiceInteraction();
+ void notifyPinnedStackAnimationStarted();
+ void notifyPinnedStackAnimationEnded();
+
+ /**
+ * Resizes the pinned stack.
+ *
+ * @param pinnedBounds The bounds for the pinned stack.
+ * @param tempPinnedTaskBounds The temporary bounds for the tasks in the pinned stack, which
+ * might be different from the stack bounds to allow more
+ * flexibility while resizing, or {@code null} if they should be the
+ * same as the stack bounds.
+ */
+ void resizePinnedStack(in Rect pinnedBounds, in Rect tempPinnedTaskBounds);
+
+ /**
+ * Updates override configuration applied to specific display.
+ * @param values Update values for display configuration. If null is passed it will request the
+ * Window Manager to compute new config for the specified display.
+ * @param displayId Id of the display to apply the config to.
+ * @throws RemoteException
+ * @return Returns true if the configuration was updated.
+ */
+ boolean updateDisplayOverrideConfiguration(in Configuration values, int displayId);
+ void dismissKeyguard(in IBinder token, in IKeyguardDismissCallback callback,
+ in CharSequence message);
+
+ /** Cancels the window transitions for the given task. */
+ void cancelTaskWindowTransition(int taskId);
+
+ /**
+ * @param taskId the id of the task to retrieve the sAutoapshots for
+ * @param reducedResolution if set, if the snapshot needs to be loaded from disk, this will load
+ * a reduced resolution of it, which is much faster
+ * @return a graphic buffer representing a screenshot of a task
+ */
+ ActivityManager.TaskSnapshot getTaskSnapshot(int taskId, boolean reducedResolution);
+
+ /**
+ * See {@link android.app.Activity#setDisablePreviewScreenshots}
+ */
+ void setDisablePreviewScreenshots(IBinder token, boolean disable);
+
+ /**
+ * Return the user id of last resumed activity.
+ */
+ int getLastResumedActivityUserId();
+
+ /**
+ * Updates global configuration and applies changes to the entire system.
+ * @param values Update values for global configuration. If null is passed it will request the
+ * Window Manager to compute new config for the default display.
+ * @throws RemoteException
+ * @return Returns true if the configuration was updated.
+ */
+ boolean updateConfiguration(in Configuration values);
+ void updateLockTaskFeatures(int userId, int flags);
+
+ void setShowWhenLocked(in IBinder token, boolean showWhenLocked);
+ void setTurnScreenOn(in IBinder token, boolean turnScreenOn);
+
+ /**
+ * Registers remote animations for a specific activity.
+ */
+ void registerRemoteAnimations(in IBinder token, in RemoteAnimationDefinition definition);
+
+ /**
+ * Registers a remote animation to be run for all activity starts from a certain package during
+ * a short predefined amount of time.
+ */
+ void registerRemoteAnimationForNextActivityStart(in String packageName,
+ in RemoteAnimationAdapter adapter);
+
+ /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */
+ void alwaysShowUnsupportedCompileSdkWarning(in ComponentName activity);
+}
diff --git a/core/java/android/app/IApplicationThread.aidl b/core/java/android/app/IApplicationThread.aidl
index ae9b83ec0122..fcb6c14d052c 100644
--- a/core/java/android/app/IApplicationThread.aidl
+++ b/core/java/android/app/IApplicationThread.aidl
@@ -38,6 +38,7 @@ import android.os.IBinder;
import android.os.IInterface;
import android.os.ParcelFileDescriptor;
import android.os.PersistableBundle;
+import android.os.RemoteCallback;
import com.android.internal.app.IVoiceInteractor;
import com.android.internal.content.ReferrerIntent;
@@ -95,7 +96,7 @@ oneway interface IApplicationThread {
void dispatchPackageBroadcast(int cmd, in String[] packages);
void scheduleCrash(in String msg);
void dumpHeap(boolean managed, boolean mallocInfo, boolean runGc, in String path,
- in ParcelFileDescriptor fd);
+ in ParcelFileDescriptor fd, in RemoteCallback finishCallback);
void dumpActivity(in ParcelFileDescriptor fd, IBinder servicetoken, in String prefix,
in String[] args);
void clearDnsCache();
diff --git a/core/java/android/app/Instrumentation.java b/core/java/android/app/Instrumentation.java
index c7618fe62c87..34be41b63233 100644
--- a/core/java/android/app/Instrumentation.java
+++ b/core/java/android/app/Instrumentation.java
@@ -1665,7 +1665,7 @@ public class Instrumentation {
try {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(who);
- int result = ActivityManager.getService()
+ int result = ActivityTaskManager.getService()
.startActivity(whoThread, who.getBasePackageName(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, target != null ? target.mEmbeddedID : null,
@@ -1736,7 +1736,7 @@ public class Instrumentation {
intents[i].prepareToLeaveProcess(who);
resolvedTypes[i] = intents[i].resolveTypeIfNeeded(who.getContentResolver());
}
- int result = ActivityManager.getService()
+ int result = ActivityTaskManager.getService()
.startActivities(whoThread, who.getBasePackageName(), intents, resolvedTypes,
token, options, userId);
checkStartActivityResult(result, intents[0]);
@@ -1803,7 +1803,7 @@ public class Instrumentation {
try {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(who);
- int result = ActivityManager.getService()
+ int result = ActivityTaskManager.getService()
.startActivity(whoThread, who.getBasePackageName(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, target, requestCode, 0, null, options);
@@ -1870,7 +1870,7 @@ public class Instrumentation {
try {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(who);
- int result = ActivityManager.getService()
+ int result = ActivityTaskManager.getService()
.startActivityAsUser(whoThread, who.getBasePackageName(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, resultWho,
@@ -1916,7 +1916,7 @@ public class Instrumentation {
try {
intent.migrateExtraStreamToClipData();
intent.prepareToLeaveProcess(who);
- int result = ActivityManager.getService()
+ int result = ActivityTaskManager.getService()
.startActivityAsCaller(whoThread, who.getBasePackageName(), intent,
intent.resolveTypeIfNeeded(who.getContentResolver()),
token, target != null ? target.mEmbeddedID : null,
diff --git a/core/java/android/app/KeyguardManager.java b/core/java/android/app/KeyguardManager.java
index b512e5ce8417..9ceecd96363f 100644
--- a/core/java/android/app/KeyguardManager.java
+++ b/core/java/android/app/KeyguardManager.java
@@ -513,7 +513,8 @@ public class KeyguardManager {
public void requestDismissKeyguard(@NonNull Activity activity, @Nullable CharSequence message,
@Nullable KeyguardDismissCallback callback) {
try {
- mAm.dismissKeyguard(activity.getActivityToken(), new IKeyguardDismissCallback.Stub() {
+ ActivityTaskManager.getService().dismissKeyguard(
+ activity.getActivityToken(), new IKeyguardDismissCallback.Stub() {
@Override
public void onDismissError() throws RemoteException {
if (callback != null && !activity.isDestroyed()) {
diff --git a/core/java/android/app/Notification.java b/core/java/android/app/Notification.java
index 1d1c738ada65..05bf6bfa3a8f 100644
--- a/core/java/android/app/Notification.java
+++ b/core/java/android/app/Notification.java
@@ -16,7 +16,7 @@
package android.app;
-import static com.android.internal.util.NotificationColorUtil.satisfiesTextContrast;
+import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast;
import android.annotation.ColorInt;
import android.annotation.DrawableRes;
@@ -79,7 +79,7 @@ import android.widget.RemoteViews;
import com.android.internal.R;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.util.ArrayUtils;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.internal.util.Preconditions;
import java.lang.annotation.Retention;
@@ -2769,7 +2769,6 @@ public class Notification implements Parcelable
*/
private void fixDuplicateExtras() {
if (extras != null) {
- fixDuplicateExtra(mSmallIcon, EXTRA_SMALL_ICON);
fixDuplicateExtra(mLargeIcon, EXTRA_LARGE_ICON);
}
}
@@ -3176,7 +3175,7 @@ public class Notification implements Parcelable
private Style mStyle;
private ArrayList<Action> mActions = new ArrayList<Action>(MAX_ACTION_BUTTONS);
private ArrayList<Person> mPersonList = new ArrayList<>();
- private NotificationColorUtil mColorUtil;
+ private ContrastColorUtil mColorUtil;
private boolean mIsLegacy;
private boolean mIsLegacyInitialized;
@@ -3307,9 +3306,9 @@ public class Notification implements Parcelable
}
}
- private NotificationColorUtil getColorUtil() {
+ private ContrastColorUtil getColorUtil() {
if (mColorUtil == null) {
- mColorUtil = NotificationColorUtil.getInstance(mContext);
+ mColorUtil = ContrastColorUtil.getInstance(mContext);
}
return mColorUtil;
}
@@ -4427,7 +4426,7 @@ public class Notification implements Parcelable
private CharSequence processTextSpans(CharSequence text) {
if (hasForegroundColor()) {
- return NotificationColorUtil.clearColorSpans(text);
+ return ContrastColorUtil.clearColorSpans(text);
}
return text;
}
@@ -4473,20 +4472,20 @@ public class Notification implements Parcelable
|| mTextColorsAreForBackground != backgroundColor) {
mTextColorsAreForBackground = backgroundColor;
if (!hasForegroundColor() || !isColorized()) {
- mPrimaryTextColor = NotificationColorUtil.resolvePrimaryColor(mContext,
+ mPrimaryTextColor = ContrastColorUtil.resolvePrimaryColor(mContext,
backgroundColor);
- mSecondaryTextColor = NotificationColorUtil.resolveSecondaryColor(mContext,
+ mSecondaryTextColor = ContrastColorUtil.resolveSecondaryColor(mContext,
backgroundColor);
if (backgroundColor != COLOR_DEFAULT && isColorized()) {
- mPrimaryTextColor = NotificationColorUtil.findAlphaToMeetContrast(
+ mPrimaryTextColor = ContrastColorUtil.findAlphaToMeetContrast(
mPrimaryTextColor, backgroundColor, 4.5);
- mSecondaryTextColor = NotificationColorUtil.findAlphaToMeetContrast(
+ mSecondaryTextColor = ContrastColorUtil.findAlphaToMeetContrast(
mSecondaryTextColor, backgroundColor, 4.5);
}
} else {
- double backLum = NotificationColorUtil.calculateLuminance(backgroundColor);
- double textLum = NotificationColorUtil.calculateLuminance(mForegroundColor);
- double contrast = NotificationColorUtil.calculateContrast(mForegroundColor,
+ double backLum = ContrastColorUtil.calculateLuminance(backgroundColor);
+ double textLum = ContrastColorUtil.calculateLuminance(mForegroundColor);
+ double contrast = ContrastColorUtil.calculateContrast(mForegroundColor,
backgroundColor);
// We only respect the given colors if worst case Black or White still has
// contrast
@@ -4496,46 +4495,46 @@ public class Notification implements Parcelable
&& !satisfiesTextContrast(backgroundColor, Color.WHITE);
if (contrast < 4.5f) {
if (backgroundLight) {
- mSecondaryTextColor = NotificationColorUtil.findContrastColor(
+ mSecondaryTextColor = ContrastColorUtil.findContrastColor(
mForegroundColor,
backgroundColor,
true /* findFG */,
4.5f);
- mPrimaryTextColor = NotificationColorUtil.changeColorLightness(
+ mPrimaryTextColor = ContrastColorUtil.changeColorLightness(
mSecondaryTextColor, -LIGHTNESS_TEXT_DIFFERENCE_LIGHT);
} else {
mSecondaryTextColor =
- NotificationColorUtil.findContrastColorAgainstDark(
+ ContrastColorUtil.findContrastColorAgainstDark(
mForegroundColor,
backgroundColor,
true /* findFG */,
4.5f);
- mPrimaryTextColor = NotificationColorUtil.changeColorLightness(
+ mPrimaryTextColor = ContrastColorUtil.changeColorLightness(
mSecondaryTextColor, -LIGHTNESS_TEXT_DIFFERENCE_DARK);
}
} else {
mPrimaryTextColor = mForegroundColor;
- mSecondaryTextColor = NotificationColorUtil.changeColorLightness(
+ mSecondaryTextColor = ContrastColorUtil.changeColorLightness(
mPrimaryTextColor, backgroundLight ? LIGHTNESS_TEXT_DIFFERENCE_LIGHT
: LIGHTNESS_TEXT_DIFFERENCE_DARK);
- if (NotificationColorUtil.calculateContrast(mSecondaryTextColor,
+ if (ContrastColorUtil.calculateContrast(mSecondaryTextColor,
backgroundColor) < 4.5f) {
// oh well the secondary is not good enough
if (backgroundLight) {
- mSecondaryTextColor = NotificationColorUtil.findContrastColor(
+ mSecondaryTextColor = ContrastColorUtil.findContrastColor(
mSecondaryTextColor,
backgroundColor,
true /* findFG */,
4.5f);
} else {
mSecondaryTextColor
- = NotificationColorUtil.findContrastColorAgainstDark(
+ = ContrastColorUtil.findContrastColorAgainstDark(
mSecondaryTextColor,
backgroundColor,
true /* findFG */,
4.5f);
}
- mPrimaryTextColor = NotificationColorUtil.changeColorLightness(
+ mPrimaryTextColor = ContrastColorUtil.changeColorLightness(
mSecondaryTextColor, backgroundLight
? -LIGHTNESS_TEXT_DIFFERENCE_LIGHT
: -LIGHTNESS_TEXT_DIFFERENCE_DARK);
@@ -5247,7 +5246,7 @@ public class Notification implements Parcelable
ColorStateList[] outResultColor = null;
int background = resolveBackgroundColor();
if (isLegacy()) {
- title = NotificationColorUtil.clearColorSpans(title);
+ title = ContrastColorUtil.clearColorSpans(title);
} else {
outResultColor = new ColorStateList[1];
title = ensureColorSpanContrast(title, background, outResultColor);
@@ -5260,7 +5259,7 @@ public class Notification implements Parcelable
// There's a span spanning the full text, let's take it and use it as the
// background color
background = outResultColor[0].getDefaultColor();
- int textColor = NotificationColorUtil.resolvePrimaryColor(mContext,
+ int textColor = ContrastColorUtil.resolvePrimaryColor(mContext,
background);
button.setTextColor(R.id.action0, textColor);
rippleColor = textColor;
@@ -5321,7 +5320,7 @@ public class Notification implements Parcelable
int[] colors = textColor.getColors();
int[] newColors = new int[colors.length];
for (int i = 0; i < newColors.length; i++) {
- newColors[i] = NotificationColorUtil.ensureLargeTextContrast(
+ newColors[i] = ContrastColorUtil.ensureLargeTextContrast(
colors[i], background, mInNightMode);
}
textColor = new ColorStateList(textColor.getStates().clone(),
@@ -5341,7 +5340,7 @@ public class Notification implements Parcelable
} else if (resultSpan instanceof ForegroundColorSpan) {
ForegroundColorSpan originalSpan = (ForegroundColorSpan) resultSpan;
int foregroundColor = originalSpan.getForegroundColor();
- foregroundColor = NotificationColorUtil.ensureLargeTextContrast(
+ foregroundColor = ContrastColorUtil.ensureLargeTextContrast(
foregroundColor, background, mInNightMode);
if (fullLength) {
outResultColor[0] = ColorStateList.valueOf(foregroundColor);
@@ -5441,14 +5440,14 @@ public class Notification implements Parcelable
com.android.internal.R.color.notification_material_background_color);
if (mN.color == COLOR_DEFAULT) {
ensureColors();
- color = NotificationColorUtil.resolveDefaultColor(mContext, background);
+ color = ContrastColorUtil.resolveDefaultColor(mContext, background);
} else {
- color = NotificationColorUtil.resolveContrastColor(mContext, mN.color,
+ color = ContrastColorUtil.resolveContrastColor(mContext, mN.color,
background, mInNightMode);
}
if (Color.alpha(color) < 255) {
// alpha doesn't go well for color filters, so let's blend it manually
- color = NotificationColorUtil.compositeColors(color, background);
+ color = ContrastColorUtil.compositeColors(color, background);
}
mCachedContrastColorIsFor = mN.color;
return mCachedContrastColor = color;
@@ -5460,10 +5459,10 @@ public class Notification implements Parcelable
}
int background = mContext.getColor(
com.android.internal.R.color.notification_material_background_color);
- mNeutralColor = NotificationColorUtil.resolveDefaultColor(mContext, background);
+ mNeutralColor = ContrastColorUtil.resolveDefaultColor(mContext, background);
if (Color.alpha(mNeutralColor) < 255) {
// alpha doesn't go well for color filters, so let's blend it manually
- mNeutralColor = NotificationColorUtil.compositeColors(mNeutralColor, background);
+ mNeutralColor = ContrastColorUtil.compositeColors(mNeutralColor, background);
}
return mNeutralColor;
}
@@ -5472,7 +5471,7 @@ public class Notification implements Parcelable
if (mCachedAmbientColorIsFor == mN.color && mCachedAmbientColorIsFor != COLOR_INVALID) {
return mCachedAmbientColor;
}
- final int contrasted = NotificationColorUtil.resolveAmbientColor(mContext, mN.color);
+ final int contrasted = ContrastColorUtil.resolveAmbientColor(mContext, mN.color);
mCachedAmbientColorIsFor = mN.color;
return mCachedAmbientColor = contrasted;
@@ -7833,7 +7832,7 @@ public class Notification implements Parcelable
// notification color. Otherwise, just use the passed-in color.
int tintColor = mBuilder.shouldTintActionButtons() || mBuilder.isColorized()
? color
- : NotificationColorUtil.resolveColor(mBuilder.mContext,
+ : ContrastColorUtil.resolveColor(mBuilder.mContext,
Notification.COLOR_DEFAULT);
button.setDrawableTint(R.id.action0, false, tintColor,
diff --git a/core/java/android/app/SearchManager.java b/core/java/android/app/SearchManager.java
index 49faf4029157..ed6d2f57ba48 100644
--- a/core/java/android/app/SearchManager.java
+++ b/core/java/android/app/SearchManager.java
@@ -951,7 +951,7 @@ public class SearchManager
try {
Intent intent = new Intent(Intent.ACTION_ASSIST);
if (inclContext) {
- IActivityManager am = ActivityManager.getService();
+ IActivityTaskManager am = ActivityTaskManager.getService();
Bundle extras = am.getAssistContextExtras(ActivityManager.ASSIST_CONTEXT_BASIC);
if (extras != null) {
intent.replaceExtras(extras);
diff --git a/core/java/android/app/StatusBarManager.java b/core/java/android/app/StatusBarManager.java
index b83b44d295b4..c8a831366e23 100644
--- a/core/java/android/app/StatusBarManager.java
+++ b/core/java/android/app/StatusBarManager.java
@@ -132,9 +132,10 @@ public class StatusBarManager {
*/
public void disable(int what) {
try {
+ final int userId = Binder.getCallingUserHandle().getIdentifier();
final IStatusBarService svc = getService();
if (svc != null) {
- svc.disable(what, mToken, mContext.getPackageName());
+ svc.disableForUser(what, mToken, mContext.getPackageName(), userId);
}
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
@@ -149,9 +150,10 @@ public class StatusBarManager {
*/
public void disable2(@Disable2Flags int what) {
try {
+ final int userId = Binder.getCallingUserHandle().getIdentifier();
final IStatusBarService svc = getService();
if (svc != null) {
- svc.disable2(what, mToken, mContext.getPackageName());
+ svc.disable2ForUser(what, mToken, mContext.getPackageName(), userId);
}
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
diff --git a/core/java/android/app/SystemServiceRegistry.java b/core/java/android/app/SystemServiceRegistry.java
index e8ca4ff9e91c..2ad00e0a7fd8 100644
--- a/core/java/android/app/SystemServiceRegistry.java
+++ b/core/java/android/app/SystemServiceRegistry.java
@@ -215,6 +215,14 @@ final class SystemServiceRegistry {
return new ActivityManager(ctx.getOuterContext(), ctx.mMainThread.getHandler());
}});
+ registerService(Context.ACTIVITY_TASK_SERVICE, ActivityTaskManager.class,
+ new CachedServiceFetcher<ActivityTaskManager>() {
+ @Override
+ public ActivityTaskManager createService(ContextImpl ctx) {
+ return new ActivityTaskManager(
+ ctx.getOuterContext(), ctx.mMainThread.getHandler());
+ }});
+
registerService(Context.ALARM_SERVICE, AlarmManager.class,
new CachedServiceFetcher<AlarmManager>() {
@Override
diff --git a/core/java/android/app/WallpaperColors.java b/core/java/android/app/WallpaperColors.java
index 60e8a121dc45..626b3be733a7 100644
--- a/core/java/android/app/WallpaperColors.java
+++ b/core/java/android/app/WallpaperColors.java
@@ -25,12 +25,15 @@ import android.graphics.Rect;
import android.graphics.drawable.Drawable;
import android.os.Parcel;
import android.os.Parcelable;
+import android.util.Log;
import android.util.Size;
import com.android.internal.graphics.ColorUtils;
import com.android.internal.graphics.palette.Palette;
import com.android.internal.graphics.palette.VariationalKMeansQuantizer;
+import com.android.internal.util.ContrastColorUtil;
+import java.io.FileOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@@ -44,6 +47,8 @@ import java.util.List;
*/
public final class WallpaperColors implements Parcelable {
+ private static final boolean DEBUG_DARK_PIXELS = false;
+
/**
* Specifies that dark text is preferred over the current wallpaper for best presentation.
* <p>
@@ -83,8 +88,8 @@ public final class WallpaperColors implements Parcelable {
private static final float BRIGHT_IMAGE_MEAN_LUMINANCE = 0.75f;
// We also check if the image has dark pixels in it,
// to avoid bright images with some dark spots.
- private static final float DARK_PIXEL_LUMINANCE = 0.45f;
- private static final float MAX_DARK_AREA = 0.05f;
+ private static final float DARK_PIXEL_CONTRAST = 6f;
+ private static final float MAX_DARK_AREA = 0.025f;
private final ArrayList<Color> mMainColors;
private int mColorHints;
@@ -382,8 +387,13 @@ public final class WallpaperColors implements Parcelable {
final int alpha = Color.alpha(pixels[i]);
// Make sure we don't have a dark pixel mass that will
// make text illegible.
- if (luminance < DARK_PIXEL_LUMINANCE && alpha != 0) {
+ final boolean satisfiesTextContrast = ContrastColorUtil
+ .calculateContrast(pixels[i], Color.BLACK) > DARK_PIXEL_CONTRAST;
+ if (!satisfiesTextContrast && alpha != 0) {
darkPixels++;
+ if (DEBUG_DARK_PIXELS) {
+ pixels[i] = Color.RED;
+ }
}
totalLuminance += luminance;
}
@@ -397,6 +407,18 @@ public final class WallpaperColors implements Parcelable {
hints |= HINT_SUPPORTS_DARK_THEME;
}
+ if (DEBUG_DARK_PIXELS) {
+ try (FileOutputStream out = new FileOutputStream("/data/pixels.png")) {
+ source.setPixels(pixels, 0, source.getWidth(), 0, 0, source.getWidth(),
+ source.getHeight());
+ source.compress(Bitmap.CompressFormat.PNG, 100, out);
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ Log.d("WallpaperColors", "l: " + meanLuminance + ", d: " + darkPixels +
+ " maxD: " + maxDarkPixels + " numPixels: " + pixels.length);
+ }
+
return hints;
}
diff --git a/core/java/android/app/admin/DevicePolicyManager.java b/core/java/android/app/admin/DevicePolicyManager.java
index 22367b21221a..ff38c1f37007 100644
--- a/core/java/android/app/admin/DevicePolicyManager.java
+++ b/core/java/android/app/admin/DevicePolicyManager.java
@@ -9398,9 +9398,9 @@ public class DevicePolicyManager {
* <ul>
* <li>{@link ApnSetting#getOperatorNumeric()}</li>
* <li>{@link ApnSetting#getApnName()}</li>
- * <li>{@link ApnSetting#getProxyAddress()}</li>
+ * <li>{@link ApnSetting#getProxyAddressAsString()}</li>
* <li>{@link ApnSetting#getProxyPort()}</li>
- * <li>{@link ApnSetting#getMmsProxyAddress()}</li>
+ * <li>{@link ApnSetting#getMmsProxyAddressAsString()}</li>
* <li>{@link ApnSetting#getMmsProxyPort()}</li>
* <li>{@link ApnSetting#getMmsc()}</li>
* <li>{@link ApnSetting#isEnabled()}</li>
diff --git a/core/java/android/app/backup/BackupManager.java b/core/java/android/app/backup/BackupManager.java
index e7ae32dbcdc0..912baf9f6d72 100644
--- a/core/java/android/app/backup/BackupManager.java
+++ b/core/java/android/app/backup/BackupManager.java
@@ -253,20 +253,27 @@ public class BackupManager {
}
/**
- * @deprecated Since Android P app can no longer request restoring of its backup.
+ * @deprecated Applications shouldn't request a restore operation using this method. In Android
+ * P and later, this method is a no-op.
*
- * Restore the calling application from backup. The data will be restored from the
+ * <p>Restore the calling application from backup. The data will be restored from the
* current backup dataset if the application has stored data there, or from
* the dataset used during the last full device setup operation if the current
* backup dataset has no matching data. If no backup data exists for this application
- * in either source, a nonzero value will be returned.
+ * in either source, a non-zero value is returned.
*
- * <p>If this method returns zero (meaning success), the OS will attempt to retrieve
- * a backed-up dataset from the remote transport, instantiate the application's
- * backup agent, and pass the dataset to the agent's
+ * <p>If this method returns zero (meaning success), the OS attempts to retrieve a backed-up
+ * dataset from the remote transport, instantiate the application's backup agent, and pass the
+ * dataset to the agent's
* {@link android.app.backup.BackupAgent#onRestore(BackupDataInput, int, android.os.ParcelFileDescriptor) onRestore()}
* method.
*
+ * <p class="caution">Unlike other restore operations, this method doesn't terminate the
+ * application after the restore. The application continues running to receive the
+ * {@link RestoreObserver} callbacks on the {@code observer} argument. Full backups use an
+ * {@link android.app.Application Application} base class while key-value backups use the
+ * application subclass declared in the AndroidManifest.xml {@code <application>} tag.
+ *
* @param observer The {@link RestoreObserver} to receive callbacks during the restore
* operation. This must not be null.
*
@@ -282,7 +289,7 @@ public class BackupManager {
/**
* @deprecated Since Android P app can no longer request restoring of its backup.
*
- * Restore the calling application from backup. The data will be restored from the
+ * <p>Restore the calling application from backup. The data will be restored from the
* current backup dataset if the application has stored data there, or from
* the dataset used during the last full device setup operation if the current
* backup dataset has no matching data. If no backup data exists for this application
@@ -656,7 +663,7 @@ public class BackupManager {
}
return false;
}
-
+
/**
* Request an immediate backup, providing an observer to which results of the backup operation
* will be published. The Android backup system will decide for each package whether it will
diff --git a/core/java/android/app/servertransaction/PauseActivityItem.java b/core/java/android/app/servertransaction/PauseActivityItem.java
index 0c1eab56ec30..cae93b305a1a 100644
--- a/core/java/android/app/servertransaction/PauseActivityItem.java
+++ b/core/java/android/app/servertransaction/PauseActivityItem.java
@@ -19,6 +19,7 @@ package android.app.servertransaction;
import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.ClientTransactionHandler;
import android.os.IBinder;
import android.os.Parcel;
@@ -60,7 +61,7 @@ public class PauseActivityItem extends ActivityLifecycleItem {
}
try {
// TODO(lifecycler): Use interface callback instead of AMS.
- ActivityManager.getService().activityPaused(token);
+ ActivityTaskManager.getService().activityPaused(token);
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
}
diff --git a/core/java/android/app/servertransaction/PendingTransactionActions.java b/core/java/android/app/servertransaction/PendingTransactionActions.java
index af7b7a21a582..52ba8fb73f5f 100644
--- a/core/java/android/app/servertransaction/PendingTransactionActions.java
+++ b/core/java/android/app/servertransaction/PendingTransactionActions.java
@@ -19,6 +19,7 @@ package android.app.servertransaction;
import static android.app.ActivityThread.DEBUG_MEMORY_TRIM;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.ActivityThread.ActivityClientRecord;
import android.os.Build;
import android.os.Bundle;
@@ -141,7 +142,7 @@ public class PendingTransactionActions {
try {
if (DEBUG_MEMORY_TRIM) Slog.v(TAG, "Reporting activity stopped: " + mActivity);
// TODO(lifecycler): Use interface callback instead of AMS.
- ActivityManager.getService().activityStopped(
+ ActivityTaskManager.getService().activityStopped(
mActivity.token, mState, mPersistentState, mDescription);
} catch (RemoteException ex) {
// Dump statistics about bundle to help developers debug
diff --git a/core/java/android/app/servertransaction/ResumeActivityItem.java b/core/java/android/app/servertransaction/ResumeActivityItem.java
index 909eec751d65..a5b6f7c74e18 100644
--- a/core/java/android/app/servertransaction/ResumeActivityItem.java
+++ b/core/java/android/app/servertransaction/ResumeActivityItem.java
@@ -19,6 +19,7 @@ package android.app.servertransaction;
import static android.os.Trace.TRACE_TAG_ACTIVITY_MANAGER;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.ClientTransactionHandler;
import android.os.IBinder;
import android.os.Parcel;
@@ -58,7 +59,7 @@ public class ResumeActivityItem extends ActivityLifecycleItem {
PendingTransactionActions pendingActions) {
try {
// TODO(lifecycler): Use interface callback instead of AMS.
- ActivityManager.getService().activityResumed(token);
+ ActivityTaskManager.getService().activityResumed(token);
} catch (RemoteException ex) {
throw ex.rethrowFromSystemServer();
}
diff --git a/core/java/android/app/timedetector/ITimeDetectorService.aidl b/core/java/android/app/timedetector/ITimeDetectorService.aidl
index bdbe111c7ebe..f624446a2027 100644
--- a/core/java/android/app/timedetector/ITimeDetectorService.aidl
+++ b/core/java/android/app/timedetector/ITimeDetectorService.aidl
@@ -16,6 +16,8 @@
package android.app.timedetector;
+import android.app.timedetector.TimeSignal;
+
/**
* System private API to comunicate with time detector service.
*
@@ -30,5 +32,5 @@ package android.app.timedetector;
* {@hide}
*/
interface ITimeDetectorService {
- void stubbedCall();
+ void suggestTime(in TimeSignal timeSignal);
}
diff --git a/core/java/android/app/timedetector/TimeDetector.java b/core/java/android/app/timedetector/TimeDetector.java
index ac1e2233357c..052050df8c9a 100644
--- a/core/java/android/app/timedetector/TimeDetector.java
+++ b/core/java/android/app/timedetector/TimeDetector.java
@@ -16,6 +16,7 @@
package android.app.timedetector;
+import android.annotation.NonNull;
import android.annotation.SystemService;
import android.content.Context;
import android.os.RemoteException;
@@ -40,15 +41,16 @@ public final class TimeDetector {
}
/**
- * Does nothing.
- * TODO: Remove this when the service implementation is built out.
+ * Suggests the current time to the detector. The detector may ignore the signal if better
+ * signals are available such as those that come from more reliable sources or were
+ * determined more recently.
*/
- public void stubbedCall() {
+ public void suggestTime(@NonNull TimeSignal timeSignal) {
if (DEBUG) {
- Log.d(TAG, "stubbedCall called");
+ Log.d(TAG, "suggestTime called: " + timeSignal);
}
try {
- mITimeDetectorService.stubbedCall();
+ mITimeDetectorService.suggestTime(timeSignal);
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
diff --git a/core/java/android/app/timedetector/TimeSignal.aidl b/core/java/android/app/timedetector/TimeSignal.aidl
new file mode 100644
index 000000000000..d2ec357555bc
--- /dev/null
+++ b/core/java/android/app/timedetector/TimeSignal.aidl
@@ -0,0 +1,19 @@
+/*
+ * Copyright (C) 2017 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package android.app.timedetector;
+
+parcelable TimeSignal; \ No newline at end of file
diff --git a/core/java/android/app/timedetector/TimeSignal.java b/core/java/android/app/timedetector/TimeSignal.java
new file mode 100644
index 000000000000..7ba03cc33454
--- /dev/null
+++ b/core/java/android/app/timedetector/TimeSignal.java
@@ -0,0 +1,110 @@
+/*
+ * 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 android.app.timedetector;
+
+import android.annotation.NonNull;
+import android.os.Parcel;
+import android.os.Parcelable;
+import android.util.TimestampedValue;
+
+import java.util.Objects;
+
+/**
+ * A time signal from a named source. The value consists of the number of milliseconds elapsed since
+ * 1/1/1970 00:00:00 UTC and the time according to the elapsed realtime clock when that number was
+ * established. The elapsed realtime clock is considered accurate but volatile, so time signals
+ * must not be persisted across device resets.
+ *
+ * @hide
+ */
+public final class TimeSignal implements Parcelable {
+
+ public static final Parcelable.Creator<TimeSignal> CREATOR =
+ new Parcelable.Creator<TimeSignal>() {
+ public TimeSignal createFromParcel(Parcel in) {
+ return TimeSignal.createFromParcel(in);
+ }
+
+ public TimeSignal[] newArray(int size) {
+ return new TimeSignal[size];
+ }
+ };
+
+ public static final String SOURCE_ID_NITZ = "nitz";
+
+ private final String mSourceId;
+ private final TimestampedValue<Long> mUtcTime;
+
+ public TimeSignal(String sourceId, TimestampedValue<Long> utcTime) {
+ mSourceId = Objects.requireNonNull(sourceId);
+ mUtcTime = Objects.requireNonNull(utcTime);
+ }
+
+ private static TimeSignal createFromParcel(Parcel in) {
+ String sourceId = in.readString();
+ TimestampedValue<Long> utcTime =
+ TimestampedValue.readFromParcel(in, null /* classLoader */, Long.class);
+ return new TimeSignal(sourceId, utcTime);
+ }
+
+ @Override
+ public int describeContents() {
+ return 0;
+ }
+
+ @Override
+ public void writeToParcel(@NonNull Parcel dest, int flags) {
+ dest.writeString(mSourceId);
+ TimestampedValue.writeToParcel(dest, mUtcTime);
+ }
+
+ @NonNull
+ public String getSourceId() {
+ return mSourceId;
+ }
+
+ @NonNull
+ public TimestampedValue<Long> getUtcTime() {
+ return mUtcTime;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ TimeSignal that = (TimeSignal) o;
+ return Objects.equals(mSourceId, that.mSourceId)
+ && Objects.equals(mUtcTime, that.mUtcTime);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mSourceId, mUtcTime);
+ }
+
+ @Override
+ public String toString() {
+ return "TimeSignal{"
+ + "mSourceId='" + mSourceId + '\''
+ + ", mUtcTime=" + mUtcTime
+ + '}';
+ }
+}
diff --git a/core/java/android/bluetooth/le/ScanRecord.java b/core/java/android/bluetooth/le/ScanRecord.java
index f8aaba910b7b..04dd060cae5d 100644
--- a/core/java/android/bluetooth/le/ScanRecord.java
+++ b/core/java/android/bluetooth/le/ScanRecord.java
@@ -117,7 +117,7 @@ public final class ScanRecord {
*/
@Nullable
public byte[] getServiceData(ParcelUuid serviceDataUuid) {
- if (serviceDataUuid == null) {
+ if (serviceDataUuid == null || mServiceData == null) {
return null;
}
return mServiceData.get(serviceDataUuid);
diff --git a/core/java/android/content/Context.java b/core/java/android/content/Context.java
index 1da77a24621e..c0cfb90e6676 100644
--- a/core/java/android/content/Context.java
+++ b/core/java/android/content/Context.java
@@ -3328,6 +3328,16 @@ public abstract class Context {
/**
* Use with {@link #getSystemService(String)} to retrieve a
+ * {@link android.app.ActivityTaskManager} for interacting with the global system state.
+ *
+ * @see #getSystemService(String)
+ * @see android.app.ActivityTaskManager
+ * @hide
+ */
+ public static final String ACTIVITY_TASK_SERVICE = "activity_task";
+
+ /**
+ * Use with {@link #getSystemService(String)} to retrieve a
* {@link android.app.AlarmManager} for receiving intents at a
* time of your choosing.
*
diff --git a/core/java/android/content/Intent.java b/core/java/android/content/Intent.java
index 1bc3bc9732eb..631c4b7d1912 100644
--- a/core/java/android/content/Intent.java
+++ b/core/java/android/content/Intent.java
@@ -4602,15 +4602,6 @@ public class Intent implements Parcelable, Cloneable {
public static final String EXTRA_INITIAL_INTENTS = "android.intent.extra.INITIAL_INTENTS";
/**
- * A {@link IntentSender} to start after ephemeral installation success.
- * @deprecated Use {@link #EXTRA_INSTANT_APP_SUCCESS).
- * @removed
- * @hide
- */
- @Deprecated
- public static final String EXTRA_EPHEMERAL_SUCCESS = "android.intent.extra.EPHEMERAL_SUCCESS";
-
- /**
* A {@link IntentSender} to start after instant app installation success.
* @hide
*/
@@ -4619,15 +4610,6 @@ public class Intent implements Parcelable, Cloneable {
"android.intent.extra.INSTANT_APP_SUCCESS";
/**
- * A {@link IntentSender} to start after ephemeral installation failure.
- * @deprecated Use {@link #EXTRA_INSTANT_APP_FAILURE).
- * @removed
- * @hide
- */
- @Deprecated
- public static final String EXTRA_EPHEMERAL_FAILURE = "android.intent.extra.EPHEMERAL_FAILURE";
-
- /**
* A {@link IntentSender} to start after instant app installation failure.
* @hide
*/
@@ -4636,15 +4618,6 @@ public class Intent implements Parcelable, Cloneable {
"android.intent.extra.INSTANT_APP_FAILURE";
/**
- * The host name that triggered an ephemeral resolution.
- * @deprecated Use {@link #EXTRA_INSTANT_APP_HOSTNAME).
- * @removed
- * @hide
- */
- @Deprecated
- public static final String EXTRA_EPHEMERAL_HOSTNAME = "android.intent.extra.EPHEMERAL_HOSTNAME";
-
- /**
* The host name that triggered an instant app resolution.
* @hide
*/
@@ -4653,15 +4626,6 @@ public class Intent implements Parcelable, Cloneable {
"android.intent.extra.INSTANT_APP_HOSTNAME";
/**
- * An opaque token to track ephemeral resolution.
- * @deprecated Use {@link #EXTRA_INSTANT_APP_TOKEN).
- * @removed
- * @hide
- */
- @Deprecated
- public static final String EXTRA_EPHEMERAL_TOKEN = "android.intent.extra.EPHEMERAL_TOKEN";
-
- /**
* An opaque token to track instant app resolution.
* @hide
*/
@@ -6994,6 +6958,7 @@ public class Intent implements Parcelable, Cloneable {
"<INTENT> specifications include these flags and arguments:",
" [-a <ACTION>] [-d <DATA_URI>] [-t <MIME_TYPE>]",
" [-c <CATEGORY> [-c <CATEGORY>] ...]",
+ " [-n <COMPONENT_NAME>]",
" [-e|--es <EXTRA_KEY> <EXTRA_STRING_VALUE> ...]",
" [--esn <EXTRA_KEY> ...]",
" [--ez <EXTRA_KEY> <EXTRA_BOOLEAN_VALUE> ...]",
diff --git a/core/java/android/content/pm/IPackageManager.aidl b/core/java/android/content/pm/IPackageManager.aidl
index 03e600ed3ba1..c988fa907f86 100644
--- a/core/java/android/content/pm/IPackageManager.aidl
+++ b/core/java/android/content/pm/IPackageManager.aidl
@@ -598,8 +598,6 @@ interface IPackageManager {
boolean setApplicationHiddenSettingAsUser(String packageName, boolean hidden, int userId);
boolean getApplicationHiddenSettingAsUser(String packageName, int userId);
- boolean setSystemAppInstallState(String packageName, boolean installed, int userId);
-
IPackageInstaller getPackageInstaller();
boolean setBlockUninstallForUser(String packageName, boolean blockUninstall, int userId);
diff --git a/core/java/android/content/pm/PackageManager.java b/core/java/android/content/pm/PackageManager.java
index 8d2c511e313e..43b698445507 100644
--- a/core/java/android/content/pm/PackageManager.java
+++ b/core/java/android/content/pm/PackageManager.java
@@ -147,7 +147,6 @@ public abstract class PackageManager {
GET_DISABLED_COMPONENTS,
GET_DISABLED_UNTIL_USED_COMPONENTS,
GET_UNINSTALLED_PACKAGES,
- MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS,
})
@Retention(RetentionPolicy.SOURCE)
public @interface PackageInfoFlags {}
@@ -165,7 +164,6 @@ public abstract class PackageManager {
MATCH_STATIC_SHARED_LIBRARIES,
GET_DISABLED_UNTIL_USED_COMPONENTS,
GET_UNINSTALLED_PACKAGES,
- MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS,
})
@Retention(RetentionPolicy.SOURCE)
public @interface ApplicationInfoFlags {}
@@ -524,12 +522,6 @@ public abstract class PackageManager {
public static final int MATCH_DEBUG_TRIAGED_MISSING = 0x10000000;
/**
- * Internal flag used to indicate that a package is a hidden system app.
- * @hide
- */
- public static final int MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS = 0x20000000;
-
- /**
* Flag for {@link #addCrossProfileIntentFilter}: if this flag is set: when
* resolving an intent that matches the {@code CrossProfileIntentFilter},
* the current profile will be skipped. Only activities in the target user
@@ -1965,8 +1957,6 @@ public abstract class PackageManager {
* </ul>
* A version of 1.1.0 or higher also indicates:
* <ul>
- * <li>The {@code VK_ANDROID_external_memory_android_hardware_buffer} extension is
- * supported.</li>
* <li>{@code SYNC_FD} external semaphore and fence handles are supported.</li>
* <li>{@code VkPhysicalDeviceSamplerYcbcrConversionFeatures::samplerYcbcrConversion} is
* supported.</li>
@@ -4857,8 +4847,7 @@ public abstract class PackageManager {
* on the system for other users, also install it for the specified user.
* @hide
*/
- @RequiresPermission(anyOf = {
- Manifest.permission.INSTALL_EXISTING_PACKAGES,
+ @RequiresPermission(anyOf = {
Manifest.permission.INSTALL_PACKAGES,
Manifest.permission.INTERACT_ACROSS_USERS_FULL})
public abstract int installExistingPackageAsUser(String packageName, @UserIdInt int userId)
diff --git a/core/java/android/content/pm/PackageParser.java b/core/java/android/content/pm/PackageParser.java
index b8eb074d1636..950070ee7d6e 100644
--- a/core/java/android/content/pm/PackageParser.java
+++ b/core/java/android/content/pm/PackageParser.java
@@ -40,12 +40,13 @@ import static android.os.Build.VERSION_CODES.O;
import static android.os.Trace.TRACE_TAG_PACKAGE_MANAGER;
import static android.view.WindowManager.LayoutParams.ROTATION_ANIMATION_UNSPECIFIED;
+import android.Manifest;
import android.annotation.IntDef;
import android.annotation.IntRange;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.annotation.TestApi;
-import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.content.ComponentName;
import android.content.Intent;
import android.content.IntentFilter;
@@ -303,7 +304,13 @@ public class PackageParser {
android.os.Build.VERSION_CODES.JELLY_BEAN),
new PackageParser.SplitPermissionInfo(android.Manifest.permission.WRITE_CONTACTS,
new String[] { android.Manifest.permission.WRITE_CALL_LOG },
- android.os.Build.VERSION_CODES.JELLY_BEAN)
+ android.os.Build.VERSION_CODES.JELLY_BEAN),
+ new PackageParser.SplitPermissionInfo(Manifest.permission.ACCESS_FINE_LOCATION,
+ new String[] { android.Manifest.permission.ACCESS_BACKGROUND_LOCATION },
+ android.os.Build.VERSION_CODES.P0),
+ new PackageParser.SplitPermissionInfo(Manifest.permission.ACCESS_COARSE_LOCATION,
+ new String[] { android.Manifest.permission.ACCESS_BACKGROUND_LOCATION },
+ android.os.Build.VERSION_CODES.P0),
};
/**
@@ -639,19 +646,11 @@ public class PackageParser {
*/
private static boolean checkUseInstalledOrHidden(int flags, PackageUserState state,
ApplicationInfo appInfo) {
- // Returns false if the package is hidden system app until installed.
- if ((flags & PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS) == 0
- && !state.installed
- && appInfo != null && appInfo.isSystemApp()) {
- return false;
- }
-
// If available for the target user, or trying to match uninstalled packages and it's
// a system app.
return state.isAvailable(flags)
|| (appInfo != null && appInfo.isSystemApp()
- && ((flags & PackageManager.MATCH_KNOWN_PACKAGES) != 0
- || (flags & PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS) != 0));
+ && (flags & PackageManager.MATCH_KNOWN_PACKAGES) != 0);
}
public static boolean isAvailable(PackageUserState state) {
@@ -4233,7 +4232,7 @@ public class PackageParser {
ActivityInfo.DOCUMENT_LAUNCH_NONE);
a.info.maxRecents = sa.getInt(
R.styleable.AndroidManifestActivity_maxRecents,
- ActivityManager.getDefaultAppRecentsLimitStatic());
+ ActivityTaskManager.getDefaultAppRecentsLimitStatic());
a.info.configChanges = getActivityConfigChanges(
sa.getInt(R.styleable.AndroidManifestActivity_configChanges, 0),
sa.getInt(R.styleable.AndroidManifestActivity_recreateOnConfigChanges, 0));
diff --git a/core/java/android/content/pm/PackageUserState.java b/core/java/android/content/pm/PackageUserState.java
index f471a1d9b36c..de173c437916 100644
--- a/core/java/android/content/pm/PackageUserState.java
+++ b/core/java/android/content/pm/PackageUserState.java
@@ -21,6 +21,7 @@ import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_DISABLED_USER;
import static android.content.pm.PackageManager.COMPONENT_ENABLED_STATE_ENABLED;
+import static android.content.pm.PackageManager.MATCH_ALL;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_AWARE;
import static android.content.pm.PackageManager.MATCH_DIRECT_BOOT_UNAWARE;
import static android.content.pm.PackageManager.MATCH_DISABLED_COMPONENTS;
@@ -125,6 +126,9 @@ public class PackageUserState {
* </p>
*/
public boolean isMatch(ComponentInfo componentInfo, int flags) {
+ if ((flags & MATCH_ALL) != 0) {
+ return true;
+ }
final boolean isSystemApp = componentInfo.applicationInfo.isSystemApp();
final boolean matchUninstalled = (flags & PackageManager.MATCH_KNOWN_PACKAGES) != 0;
if (!isAvailable(flags)
diff --git a/core/java/android/net/ConnectivityManager.java b/core/java/android/net/ConnectivityManager.java
index c5cb1f5b7cf8..104134ab859e 100644
--- a/core/java/android/net/ConnectivityManager.java
+++ b/core/java/android/net/ConnectivityManager.java
@@ -125,8 +125,8 @@ public class ConnectivityManager {
/**
* A temporary hack until SUPL system can get off the legacy APIS.
* They do too many network requests and the long list of apps listening
- * and waking due to the CONNECTIVITY_ACTION bcast makes it expensive.
- * Use this bcast intent instead for SUPL requests.
+ * and waking due to the CONNECTIVITY_ACTION broadcast makes it expensive.
+ * Use this broadcast intent instead for SUPL requests.
* @hide
*/
public static final String CONNECTIVITY_ACTION_SUPL =
@@ -152,7 +152,7 @@ public class ConnectivityManager {
* call {@link CaptivePortal#reportCaptivePortalDismissed} so the system can
* reevaluate the network. If reevaluation finds the network no longer
* subject to a captive portal, the network may become the default active
- * data network. </li>
+ * data network.</li>
* <li> When the app handling this action believes the user explicitly wants
* to ignore the captive portal and the network, the app should call
* {@link CaptivePortal#ignoreNetwork}. </li>
@@ -260,7 +260,8 @@ public class ConnectivityManager {
* {@hide}
*/
@SdkConstant(SdkConstantType.BROADCAST_INTENT_ACTION)
- public static final String ACTION_DATA_ACTIVITY_CHANGE = "android.net.conn.DATA_ACTIVITY_CHANGE";
+ public static final String ACTION_DATA_ACTIVITY_CHANGE =
+ "android.net.conn.DATA_ACTIVITY_CHANGE";
/**
* The lookup key for an enum that indicates the network device type on which this data activity
* change happens.
@@ -391,14 +392,14 @@ public class ConnectivityManager {
/**
* Invalid tethering type.
- * @see #startTethering(int, OnStartTetheringCallback, boolean)
+ * @see #startTethering(int, boolean, OnStartTetheringCallback)
* @hide
*/
public static final int TETHERING_INVALID = -1;
/**
* Wifi tethering type.
- * @see #startTethering(int, OnStartTetheringCallback, boolean)
+ * @see #startTethering(int, boolean, OnStartTetheringCallback)
* @hide
*/
@SystemApi
@@ -406,7 +407,7 @@ public class ConnectivityManager {
/**
* USB tethering type.
- * @see #startTethering(int, OnStartTetheringCallback, boolean)
+ * @see #startTethering(int, boolean, OnStartTetheringCallback)
* @hide
*/
@SystemApi
@@ -414,7 +415,7 @@ public class ConnectivityManager {
/**
* Bluetooth tethering type.
- * @see #startTethering(int, OnStartTetheringCallback, boolean)
+ * @see #startTethering(int, boolean, OnStartTetheringCallback)
* @hide
*/
@SystemApi
@@ -664,7 +665,7 @@ public class ConnectivityManager {
/**
* Static unique request used as a tombstone for NetworkCallbacks that have been unregistered.
* This allows to distinguish when unregistering NetworkCallbacks those that were never
- * registered and those that were already unregistered.
+ * registered from those that were already unregistered.
* @hide
*/
private static final NetworkRequest ALREADY_UNREGISTERED =
@@ -1494,8 +1495,8 @@ public class ConnectivityManager {
};
}
- private static HashMap<NetworkCapabilities, LegacyRequest> sLegacyRequests =
- new HashMap<NetworkCapabilities, LegacyRequest>();
+ private static final HashMap<NetworkCapabilities, LegacyRequest> sLegacyRequests =
+ new HashMap<>();
private NetworkRequest findRequestForFeature(NetworkCapabilities netCap) {
synchronized (sLegacyRequests) {
@@ -1635,8 +1636,9 @@ public class ConnectivityManager {
* {@code onStarted} method will be called. If an error occurs, {@code onError} will be called,
* specifying one of the {@code ERROR_*} constants in this class.
*
- * To stop an existing keepalive, call {@link stop}. The system will call {@code onStopped} if
- * the operation was successfull or {@code onError} if an error occurred.
+ * To stop an existing keepalive, call {@link PacketKeepalive#stop}. The system will call
+ * {@link PacketKeepaliveCallback#onStopped} if the operation was successful or
+ * {@link PacketKeepaliveCallback#onError} if an error occurred.
*
* @hide
*/
@@ -1897,7 +1899,7 @@ public class ConnectivityManager {
* to initiate network traffic), you can retrieve its instantaneous state with
* {@link ConnectivityManager#isDefaultNetworkActive}.
*/
- public void onNetworkActive();
+ void onNetworkActive();
}
private INetworkManagementService getNetworkManagementService() {
@@ -1912,8 +1914,7 @@ public class ConnectivityManager {
}
private final ArrayMap<OnNetworkActiveListener, INetworkActivityListener>
- mNetworkActivityListeners
- = new ArrayMap<OnNetworkActiveListener, INetworkActivityListener>();
+ mNetworkActivityListeners = new ArrayMap<>();
/**
* Start listening to reports when the system's default data network is active, meaning it is
@@ -2216,12 +2217,12 @@ public class ConnectivityManager {
/**
* Called when tethering has been successfully started.
*/
- public void onTetheringStarted() {};
+ public void onTetheringStarted() {}
/**
* Called when starting tethering failed.
*/
- public void onTetheringFailed() {};
+ public void onTetheringFailed() {}
}
/**
@@ -2658,9 +2659,6 @@ public class ConnectivityManager {
/**
* Set sign in error notification to visible or in visible
*
- * @param visible
- * @param networkType
- *
* {@hide}
* @deprecated Doesn't properly deal with multiple connected networks of the same type.
*/
@@ -2869,7 +2867,7 @@ public class ConnectivityManager {
* @hide
*/
public interface Errors {
- static int TOO_MANY_REQUESTS = 1;
+ int TOO_MANY_REQUESTS = 1;
}
/** @hide */
@@ -3126,7 +3124,7 @@ public class ConnectivityManager {
* as these {@code NetworkCapabilities} represent states that a particular
* network may never attain, and whether a network will attain these states
* is unknown prior to bringing up the network so the framework does not
- * know how to go about satisfing a request with these capabilities.
+ * know how to go about satisfying a request with these capabilities.
*
* <p>This method requires the caller to hold either the
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
@@ -3186,7 +3184,7 @@ public class ConnectivityManager {
* Request a network to satisfy a set of {@link android.net.NetworkCapabilities}, limited
* by a timeout.
*
- * This function behaves identically to the non-timedout version, but if a suitable
+ * This function behaves identically to the version without timeout, but if a suitable
* network is not found within the given time (in milliseconds) the
* {@link NetworkCallback#onUnavailable} callback is called. The request can still be
* released normally by calling {@link #unregisterNetworkCallback(NetworkCallback)} but does
@@ -3267,7 +3265,7 @@ public class ConnectivityManager {
* as these {@code NetworkCapabilities} represent states that a particular
* network may never attain, and whether a network will attain these states
* is unknown prior to bringing up the network so the framework does not
- * know how to go about satisfing a request with these capabilities.
+ * know how to go about satisfying a request with these capabilities.
*
* <p>This method requires the caller to hold either the
* {@link android.Manifest.permission#CHANGE_NETWORK_STATE} permission
@@ -3432,9 +3430,9 @@ public class ConnectivityManager {
// capabilities, this request is guaranteed, at all times, to be
// satisfied by the same network, if any, that satisfies the default
// request, i.e., the system default network.
- NetworkCapabilities nullCapabilities = null;
CallbackHandler cbHandler = new CallbackHandler(handler);
- sendRequestForNetwork(nullCapabilities, networkCallback, 0, REQUEST, TYPE_NONE, cbHandler);
+ sendRequestForNetwork(null /* NetworkCapabilities need */, networkCallback, 0,
+ REQUEST, TYPE_NONE, cbHandler);
}
/**
@@ -3669,7 +3667,7 @@ public class ConnectivityManager {
* @return {@code true} on success, {@code false} if the {@link Network} is no longer valid.
*/
public boolean bindProcessToNetwork(Network network) {
- // Forcing callers to call thru non-static function ensures ConnectivityManager
+ // Forcing callers to call through non-static function ensures ConnectivityManager
// instantiated.
return setProcessDefaultNetwork(network);
}
diff --git a/core/java/android/net/LinkProperties.java b/core/java/android/net/LinkProperties.java
index 300a78b87a41..bd2db92b7804 100644
--- a/core/java/android/net/LinkProperties.java
+++ b/core/java/android/net/LinkProperties.java
@@ -32,6 +32,7 @@ import java.util.Collections;
import java.util.Hashtable;
import java.util.List;
import java.util.Objects;
+import java.util.StringJoiner;
/**
* Describes the properties of a network link.
@@ -48,13 +49,13 @@ import java.util.Objects;
public final class LinkProperties implements Parcelable {
// The interface described by the network link.
private String mIfaceName;
- private ArrayList<LinkAddress> mLinkAddresses = new ArrayList<LinkAddress>();
- private ArrayList<InetAddress> mDnses = new ArrayList<InetAddress>();
- private ArrayList<InetAddress> mValidatedPrivateDnses = new ArrayList<InetAddress>();
+ private ArrayList<LinkAddress> mLinkAddresses = new ArrayList<>();
+ private ArrayList<InetAddress> mDnses = new ArrayList<>();
+ private ArrayList<InetAddress> mValidatedPrivateDnses = new ArrayList<>();
private boolean mUsePrivateDns;
private String mPrivateDnsServerName;
private String mDomains;
- private ArrayList<RouteInfo> mRoutes = new ArrayList<RouteInfo>();
+ private ArrayList<RouteInfo> mRoutes = new ArrayList<>();
private ProxyInfo mHttpProxy;
private int mMtu;
// in the format "rmem_min,rmem_def,rmem_max,wmem_min,wmem_def,wmem_max"
@@ -66,15 +67,14 @@ public final class LinkProperties implements Parcelable {
// Stores the properties of links that are "stacked" above this link.
// Indexed by interface name to allow modification and to prevent duplicates being added.
- private Hashtable<String, LinkProperties> mStackedLinks =
- new Hashtable<String, LinkProperties>();
+ private Hashtable<String, LinkProperties> mStackedLinks = new Hashtable<>();
/**
* @hide
*/
public static class CompareResult<T> {
- public final List<T> removed = new ArrayList<T>();
- public final List<T> added = new ArrayList<T>();
+ public final List<T> removed = new ArrayList<>();
+ public final List<T> added = new ArrayList<>();
public CompareResult() {}
@@ -93,12 +93,9 @@ public final class LinkProperties implements Parcelable {
@Override
public String toString() {
- String retVal = "removed=[";
- for (T addr : removed) retVal += addr.toString() + ",";
- retVal += "] added=[";
- for (T addr : added) retVal += addr.toString() + ",";
- retVal += "]";
- return retVal;
+ return "removed=[" + TextUtils.join(",", removed)
+ + "] added=[" + TextUtils.join(",", added)
+ + "]";
}
}
@@ -120,7 +117,7 @@ public final class LinkProperties implements Parcelable {
public static ProvisioningChange compareProvisioning(
LinkProperties before, LinkProperties after) {
if (before.isProvisioned() && after.isProvisioned()) {
- // On dualstack networks, DHCPv4 renewals can occasionally fail.
+ // On dual-stack networks, DHCPv4 renewals can occasionally fail.
// When this happens, IPv6-reachable services continue to function
// normally but IPv4-only services (naturally) fail.
//
@@ -131,7 +128,7 @@ public final class LinkProperties implements Parcelable {
//
// For users, this is confusing and unexpected behaviour, and is
// not necessarily easy to diagnose. Therefore, we treat changing
- // from a dualstack network to an IPv6-only network equivalent to
+ // from a dual-stack network to an IPv6-only network equivalent to
// a total loss of provisioning.
//
// For one such example of this, see b/18867306.
@@ -139,7 +136,7 @@ public final class LinkProperties implements Parcelable {
// Additionally, losing IPv6 provisioning can result in TCP
// connections getting stuck until timeouts fire and other
// baffling failures. Therefore, loss of either IPv4 or IPv6 on a
- // previously dualstack network is deemed a lost of provisioning.
+ // previously dual-stack network is deemed a lost of provisioning.
if ((before.isIPv4Provisioned() && !after.isIPv4Provisioned()) ||
(before.isIPv6Provisioned() && !after.isIPv6Provisioned())) {
return ProvisioningChange.LOST_PROVISIONING;
@@ -165,22 +162,19 @@ public final class LinkProperties implements Parcelable {
*/
public LinkProperties(LinkProperties source) {
if (source != null) {
- mIfaceName = source.getInterfaceName();
- for (LinkAddress l : source.getLinkAddresses()) mLinkAddresses.add(l);
- for (InetAddress i : source.getDnsServers()) mDnses.add(i);
- for (InetAddress i : source.getValidatedPrivateDnsServers()) {
- mValidatedPrivateDnses.add(i);
- }
+ mIfaceName = source.mIfaceName;
+ mLinkAddresses.addAll(source.mLinkAddresses);
+ mDnses.addAll(source.mDnses);
+ mValidatedPrivateDnses.addAll(source.mValidatedPrivateDnses);
mUsePrivateDns = source.mUsePrivateDns;
mPrivateDnsServerName = source.mPrivateDnsServerName;
- mDomains = source.getDomains();
- for (RouteInfo r : source.getRoutes()) mRoutes.add(r);
- mHttpProxy = (source.getHttpProxy() == null) ?
- null : new ProxyInfo(source.getHttpProxy());
+ mDomains = source.mDomains;
+ mRoutes.addAll(source.mRoutes);
+ mHttpProxy = (source.mHttpProxy == null) ? null : new ProxyInfo(source.mHttpProxy);
for (LinkProperties l: source.mStackedLinks.values()) {
addStackedLink(l);
}
- setMtu(source.getMtu());
+ setMtu(source.mMtu);
mTcpBufferSizes = source.mTcpBufferSizes;
}
}
@@ -194,7 +188,7 @@ public final class LinkProperties implements Parcelable {
*/
public void setInterfaceName(String iface) {
mIfaceName = iface;
- ArrayList<RouteInfo> newRoutes = new ArrayList<RouteInfo>(mRoutes.size());
+ ArrayList<RouteInfo> newRoutes = new ArrayList<>(mRoutes.size());
for (RouteInfo route : mRoutes) {
newRoutes.add(routeWithInterface(route));
}
@@ -214,8 +208,8 @@ public final class LinkProperties implements Parcelable {
* @hide
*/
public List<String> getAllInterfaceNames() {
- List<String> interfaceNames = new ArrayList<String>(mStackedLinks.size() + 1);
- if (mIfaceName != null) interfaceNames.add(new String(mIfaceName));
+ List<String> interfaceNames = new ArrayList<>(mStackedLinks.size() + 1);
+ if (mIfaceName != null) interfaceNames.add(mIfaceName);
for (LinkProperties stacked: mStackedLinks.values()) {
interfaceNames.addAll(stacked.getAllInterfaceNames());
}
@@ -229,11 +223,11 @@ public final class LinkProperties implements Parcelable {
* prefix lengths for each address. This is a simplified utility alternative to
* {@link LinkProperties#getLinkAddresses}.
*
- * @return An umodifiable {@link List} of {@link InetAddress} for this link.
+ * @return An unmodifiable {@link List} of {@link InetAddress} for this link.
* @hide
*/
public List<InetAddress> getAddresses() {
- List<InetAddress> addresses = new ArrayList<InetAddress>();
+ List<InetAddress> addresses = new ArrayList<>();
for (LinkAddress linkAddress : mLinkAddresses) {
addresses.add(linkAddress.getAddress());
}
@@ -245,7 +239,7 @@ public final class LinkProperties implements Parcelable {
* @hide
*/
public List<InetAddress> getAllAddresses() {
- List<InetAddress> addresses = new ArrayList<InetAddress>();
+ List<InetAddress> addresses = new ArrayList<>();
for (LinkAddress linkAddress : mLinkAddresses) {
addresses.add(linkAddress.getAddress());
}
@@ -322,8 +316,7 @@ public final class LinkProperties implements Parcelable {
* @hide
*/
public List<LinkAddress> getAllLinkAddresses() {
- List<LinkAddress> addresses = new ArrayList<LinkAddress>();
- addresses.addAll(mLinkAddresses);
+ List<LinkAddress> addresses = new ArrayList<>(mLinkAddresses);
for (LinkProperties stacked: mStackedLinks.values()) {
addresses.addAll(stacked.getAllLinkAddresses());
}
@@ -391,7 +384,7 @@ public final class LinkProperties implements Parcelable {
/**
* Returns all the {@link InetAddress} for DNS servers on this link.
*
- * @return An umodifiable {@link List} of {@link InetAddress} for DNS servers on
+ * @return An unmodifiable {@link List} of {@link InetAddress} for DNS servers on
* this link.
*/
public List<InetAddress> getDnsServers() {
@@ -643,7 +636,7 @@ public final class LinkProperties implements Parcelable {
* @hide
*/
public void ensureDirectlyConnectedRoutes() {
- for (LinkAddress addr: mLinkAddresses) {
+ for (LinkAddress addr : mLinkAddresses) {
addRoute(new RouteInfo(addr, null, mIfaceName));
}
}
@@ -653,8 +646,7 @@ public final class LinkProperties implements Parcelable {
* @hide
*/
public List<RouteInfo> getAllRoutes() {
- List<RouteInfo> routes = new ArrayList<>();
- routes.addAll(mRoutes);
+ List<RouteInfo> routes = new ArrayList<>(mRoutes);
for (LinkProperties stacked: mStackedLinks.values()) {
routes.addAll(stacked.getAllRoutes());
}
@@ -685,7 +677,7 @@ public final class LinkProperties implements Parcelable {
/**
* Adds a stacked link.
*
- * If there is already a stacked link with the same interfacename as link,
+ * If there is already a stacked link with the same interface name as link,
* that link is replaced with link. Otherwise, link is added to the list
* of stacked links. If link is null, nothing changes.
*
@@ -725,9 +717,9 @@ public final class LinkProperties implements Parcelable {
*/
public @NonNull List<LinkProperties> getStackedLinks() {
if (mStackedLinks.isEmpty()) {
- return Collections.EMPTY_LIST;
+ return Collections.emptyList();
}
- List<LinkProperties> stacked = new ArrayList<LinkProperties>();
+ List<LinkProperties> stacked = new ArrayList<>();
for (LinkProperties link : mStackedLinks.values()) {
stacked.add(new LinkProperties(link));
}
@@ -761,57 +753,76 @@ public final class LinkProperties implements Parcelable {
@Override
public String toString() {
- String ifaceName = (mIfaceName == null ? "" : "InterfaceName: " + mIfaceName + " ");
+ // Space as a separator, so no need for spaces at start/end of the individual fragments.
+ final StringJoiner resultJoiner = new StringJoiner(" ", "{", "}");
- String linkAddresses = "LinkAddresses: [";
- for (LinkAddress addr : mLinkAddresses) linkAddresses += addr.toString() + ",";
- linkAddresses += "] ";
+ if (mIfaceName != null) {
+ resultJoiner.add("InterfaceName:");
+ resultJoiner.add(mIfaceName);
+ }
- String dns = "DnsAddresses: [";
- for (InetAddress addr : mDnses) dns += addr.getHostAddress() + ",";
- dns += "] ";
+ resultJoiner.add("LinkAddresses: [");
+ if (!mLinkAddresses.isEmpty()) {
+ resultJoiner.add(TextUtils.join(",", mLinkAddresses));
+ }
+ resultJoiner.add("]");
- String usePrivateDns = "UsePrivateDns: " + mUsePrivateDns + " ";
+ resultJoiner.add("DnsAddresses: [");
+ if (!mDnses.isEmpty()) {
+ resultJoiner.add(TextUtils.join(",", mDnses));
+ }
+ resultJoiner.add("]");
- String privateDnsServerName = "";
- if (privateDnsServerName != null) {
- privateDnsServerName = "PrivateDnsServerName: " + mPrivateDnsServerName + " ";
+ if (mUsePrivateDns) {
+ resultJoiner.add("UsePrivateDns: true");
+ }
+
+ if (mPrivateDnsServerName != null) {
+ resultJoiner.add("PrivateDnsServerName:");
+ resultJoiner.add(mPrivateDnsServerName);
}
- String validatedPrivateDns = "";
if (!mValidatedPrivateDnses.isEmpty()) {
- validatedPrivateDns = "ValidatedPrivateDnsAddresses: [";
- for (InetAddress addr : mValidatedPrivateDnses) {
- validatedPrivateDns += addr.getHostAddress() + ",";
+ final StringJoiner validatedPrivateDnsesJoiner =
+ new StringJoiner(",", "ValidatedPrivateDnsAddresses: [", "]");
+ for (final InetAddress addr : mValidatedPrivateDnses) {
+ validatedPrivateDnsesJoiner.add(addr.getHostAddress());
}
- validatedPrivateDns += "] ";
+ resultJoiner.add(validatedPrivateDnsesJoiner.toString());
}
- String domainName = "Domains: " + mDomains;
+ resultJoiner.add("Domains:");
+ resultJoiner.add(mDomains);
- String mtu = " MTU: " + mMtu;
+ resultJoiner.add("MTU:");
+ resultJoiner.add(Integer.toString(mMtu));
- String tcpBuffSizes = "";
if (mTcpBufferSizes != null) {
- tcpBuffSizes = " TcpBufferSizes: " + mTcpBufferSizes;
+ resultJoiner.add("TcpBufferSizes:");
+ resultJoiner.add(mTcpBufferSizes);
+ }
+
+ resultJoiner.add("Routes: [");
+ if (!mRoutes.isEmpty()) {
+ resultJoiner.add(TextUtils.join(",", mRoutes));
}
+ resultJoiner.add("]");
- String routes = " Routes: [";
- for (RouteInfo route : mRoutes) routes += route.toString() + ",";
- routes += "] ";
- String proxy = (mHttpProxy == null ? "" : " HttpProxy: " + mHttpProxy.toString() + " ");
+ if (mHttpProxy != null) {
+ resultJoiner.add("HttpProxy:");
+ resultJoiner.add(mHttpProxy.toString());
+ }
- String stacked = "";
- if (mStackedLinks.values().size() > 0) {
- stacked += " Stacked: [";
- for (LinkProperties link: mStackedLinks.values()) {
- stacked += " [" + link.toString() + " ],";
+ final Collection<LinkProperties> stackedLinksValues = mStackedLinks.values();
+ if (!stackedLinksValues.isEmpty()) {
+ final StringJoiner stackedLinksJoiner = new StringJoiner(",", "Stacked: [", "]");
+ for (final LinkProperties lp : stackedLinksValues) {
+ stackedLinksJoiner.add("[ " + lp + " ]");
}
- stacked += "] ";
+ resultJoiner.add(stackedLinksJoiner.toString());
}
- return "{" + ifaceName + linkAddresses + routes + dns + usePrivateDns
- + privateDnsServerName + domainName + mtu + tcpBuffSizes + proxy
- + stacked + "}";
+
+ return resultJoiner.toString();
}
/**
@@ -1028,7 +1039,7 @@ public final class LinkProperties implements Parcelable {
if (mDomains == null) {
if (targetDomains != null) return false;
} else {
- if (mDomains.equals(targetDomains) == false) return false;
+ if (!mDomains.equals(targetDomains)) return false;
}
return (mDnses.size() == targetDnses.size()) ?
mDnses.containsAll(targetDnses) : false;
@@ -1130,7 +1141,6 @@ public final class LinkProperties implements Parcelable {
return Objects.equals(mTcpBufferSizes, target.mTcpBufferSizes);
}
- @Override
/**
* Compares this {@code LinkProperties} instance against the target
* LinkProperties in {@code obj}. Two LinkPropertieses are equal if
@@ -1145,13 +1155,14 @@ public final class LinkProperties implements Parcelable {
* @param obj the object to be tested for equality.
* @return {@code true} if both objects are equal, {@code false} otherwise.
*/
+ @Override
public boolean equals(Object obj) {
if (this == obj) return true;
if (!(obj instanceof LinkProperties)) return false;
LinkProperties target = (LinkProperties) obj;
- /**
+ /*
* This method does not check that stacked interfaces are equal, because
* stacked interfaces are not so much a property of the link as a
* description of connections between links.
@@ -1258,12 +1269,13 @@ public final class LinkProperties implements Parcelable {
}
- @Override
/**
- * generate hashcode based on significant fields
+ * Generate hashcode based on significant fields
+ *
* Equal objects must produce the same hash code, while unequal objects
* may have the same hash codes.
*/
+ @Override
public int hashCode() {
return ((null == mIfaceName) ? 0 : mIfaceName.hashCode()
+ mLinkAddresses.size() * 31
@@ -1313,7 +1325,7 @@ public final class LinkProperties implements Parcelable {
} else {
dest.writeByte((byte)0);
}
- ArrayList<LinkProperties> stackedLinks = new ArrayList(mStackedLinks.values());
+ ArrayList<LinkProperties> stackedLinks = new ArrayList<>(mStackedLinks.values());
dest.writeList(stackedLinks);
}
@@ -1331,7 +1343,7 @@ public final class LinkProperties implements Parcelable {
}
int addressCount = in.readInt();
for (int i = 0; i < addressCount; i++) {
- netProp.addLinkAddress((LinkAddress) in.readParcelable(null));
+ netProp.addLinkAddress(in.readParcelable(null));
}
addressCount = in.readInt();
for (int i = 0; i < addressCount; i++) {
@@ -1353,10 +1365,10 @@ public final class LinkProperties implements Parcelable {
netProp.setTcpBufferSizes(in.readString());
addressCount = in.readInt();
for (int i = 0; i < addressCount; i++) {
- netProp.addRoute((RouteInfo) in.readParcelable(null));
+ netProp.addRoute(in.readParcelable(null));
}
if (in.readByte() == 1) {
- netProp.setHttpProxy((ProxyInfo) in.readParcelable(null));
+ netProp.setHttpProxy(in.readParcelable(null));
}
ArrayList<LinkProperties> stackedLinks = new ArrayList<LinkProperties>();
in.readList(stackedLinks, LinkProperties.class.getClassLoader());
@@ -1377,10 +1389,9 @@ public final class LinkProperties implements Parcelable {
*/
public static boolean isValidMtu(int mtu, boolean ipv6) {
if (ipv6) {
- if (mtu >= MIN_MTU_V6 && mtu <= MAX_MTU) return true;
+ return mtu >= MIN_MTU_V6 && mtu <= MAX_MTU;
} else {
- if (mtu >= MIN_MTU && mtu <= MAX_MTU) return true;
+ return mtu >= MIN_MTU && mtu <= MAX_MTU;
}
- return false;
}
}
diff --git a/core/java/android/net/Network.java b/core/java/android/net/Network.java
index d75d4391dee3..512e35e70726 100644
--- a/core/java/android/net/Network.java
+++ b/core/java/android/net/Network.java
@@ -142,7 +142,7 @@ public class Network implements Parcelable {
/**
* Specify whether or not Private DNS should be bypassed when attempting
- * to use {@link getAllByName()}/{@link getByName()} methods on the given
+ * to use {@link #getAllByName(String)}/{@link #getByName(String)} methods on the given
* instance for hostname resolution.
*
* @hide
@@ -169,13 +169,6 @@ public class Network implements Parcelable {
* A {@code SocketFactory} that produces {@code Socket}'s bound to this network.
*/
private class NetworkBoundSocketFactory extends SocketFactory {
- private final int mNetId;
-
- public NetworkBoundSocketFactory(int netId) {
- super();
- mNetId = netId;
- }
-
private Socket connectToHost(String host, int port, SocketAddress localAddress)
throws IOException {
// Lookup addresses only on this Network.
@@ -201,7 +194,8 @@ public class Network implements Parcelable {
}
@Override
- public Socket createSocket(String host, int port, InetAddress localHost, int localPort) throws IOException {
+ public Socket createSocket(String host, int port, InetAddress localHost, int localPort)
+ throws IOException {
return connectToHost(host, port, new InetSocketAddress(localHost, localPort));
}
@@ -265,7 +259,7 @@ public class Network implements Parcelable {
if (mNetworkBoundSocketFactory == null) {
synchronized (mLock) {
if (mNetworkBoundSocketFactory == null) {
- mNetworkBoundSocketFactory = new NetworkBoundSocketFactory(netId);
+ mNetworkBoundSocketFactory = new NetworkBoundSocketFactory();
}
}
}
@@ -475,7 +469,7 @@ public class Network implements Parcelable {
@Override
public boolean equals(Object obj) {
- if (obj instanceof Network == false) return false;
+ if (!(obj instanceof Network)) return false;
Network other = (Network)obj;
return this.netId == other.netId;
}
diff --git a/core/java/android/os/Build.java b/core/java/android/os/Build.java
index e25043d39087..80c534cfd517 100644
--- a/core/java/android/os/Build.java
+++ b/core/java/android/os/Build.java
@@ -923,6 +923,12 @@ public class Build {
* engaged. It's now time to see if you can dance.</em>
*/
public static final int Q = CUR_DEVELOPMENT;
+
+ /**
+ * Stub for a potential new API level after P.
+ * @hide
+ */
+ public static final int P0 = Q;
}
/** The type of build, like "user" or "eng". */
diff --git a/core/java/android/os/ParcelFileDescriptor.aidl b/core/java/android/os/ParcelFileDescriptor.aidl
index 6bbd99e3f20a..c07b98055d5a 100644
--- a/core/java/android/os/ParcelFileDescriptor.aidl
+++ b/core/java/android/os/ParcelFileDescriptor.aidl
@@ -17,4 +17,4 @@
package android.os;
-parcelable ParcelFileDescriptor cpp_header "android/os/parcel_file_descriptor.h";
+parcelable ParcelFileDescriptor cpp_header "binder/ParcelFileDescriptor.h";
diff --git a/core/java/android/os/UserManager.java b/core/java/android/os/UserManager.java
index bc3d87062c7f..7a214b1bf1bf 100644
--- a/core/java/android/os/UserManager.java
+++ b/core/java/android/os/UserManager.java
@@ -2667,6 +2667,12 @@ public class UserManager {
if (isDeviceInDemoMode(mContext)) {
return false;
}
+ // If user disabled this feature, don't show switcher
+ final boolean userSwitcherEnabled = Settings.Global.getInt(mContext.getContentResolver(),
+ Settings.Global.USER_SWITCHER_ENABLED, 1) != 0;
+ if (!userSwitcherEnabled) {
+ return false;
+ }
List<UserInfo> users = getUsers(true);
if (users == null) {
return false;
diff --git a/core/java/android/provider/Settings.java b/core/java/android/provider/Settings.java
index 9e5efa1fe2d0..a6487a2651ec 100644
--- a/core/java/android/provider/Settings.java
+++ b/core/java/android/provider/Settings.java
@@ -6012,7 +6012,7 @@ public final class Settings {
new SettingsValidators.ComponentNameListValidator(":");
/**
- * Whether the hush gesture has ever been used // TODO: beverlyt
+ * Whether the hush gesture has ever been used
* @hide
*/
public static final String HUSH_GESTURE_USED = "hush_gesture_used";
@@ -9432,6 +9432,12 @@ public final class Settings {
public static final String USE_GOOGLE_MAIL = "use_google_mail";
/**
+ * Whether or not switching/creating users is enabled by user.
+ * @hide
+ */
+ public static final String USER_SWITCHER_ENABLED = "user_switcher_enabled";
+
+ /**
* Webview Data reduction proxy key.
* @hide
*/
@@ -11039,6 +11045,15 @@ public final class Settings {
= "user_absent_radios_off_for_small_battery_enabled";
/**
+ * Whether or not to enable the User Absent, Touch Off feature on small battery devices.
+ * Type: int (0 for false, 1 for true)
+ * Default: 0
+ * @hide
+ */
+ public static final String USER_ABSENT_TOUCH_OFF_FOR_SMALL_BATTERY_ENABLED
+ = "user_absent_touch_off_for_small_battery_enabled";
+
+ /**
* Whether or not to turn on Wifi when proxy is disconnected.
* Type: int (0 for false, 1 for true)
* Default: 1
diff --git a/core/java/android/service/autofill/TextValueSanitizer.java b/core/java/android/service/autofill/TextValueSanitizer.java
index e5ad77a1e8d6..a8c080a17818 100644
--- a/core/java/android/service/autofill/TextValueSanitizer.java
+++ b/core/java/android/service/autofill/TextValueSanitizer.java
@@ -37,7 +37,7 @@ import java.util.regex.Pattern;
* <p>For example, to remove spaces from groups of 4-digits in a credit card:
*
* <pre class="prettyprint">
- * new TextValueSanitizer(Pattern.compile("^(\\d{4})\\s?(\\d{4})\\s?(\\d{4})\\s?(\\d{4})$",
+ * new TextValueSanitizer(Pattern.compile("^(\\d{4})\\s?(\\d{4})\\s?(\\d{4})\\s?(\\d{4})$"),
* "$1$2$3$4")
* </pre>
*/
diff --git a/core/java/android/text/StaticLayout.java b/core/java/android/text/StaticLayout.java
index e17c8e7bd694..4b78aa2332d5 100644
--- a/core/java/android/text/StaticLayout.java
+++ b/core/java/android/text/StaticLayout.java
@@ -124,8 +124,6 @@ public class StaticLayout extends Layout {
b.mText = null;
b.mLeftIndents = null;
b.mRightIndents = null;
- b.mLeftPaddings = null;
- b.mRightPaddings = null;
sPool.release(b);
}
@@ -135,8 +133,6 @@ public class StaticLayout extends Layout {
mPaint = null;
mLeftIndents = null;
mRightIndents = null;
- mLeftPaddings = null;
- mRightPaddings = null;
}
public Builder setText(CharSequence source) {
@@ -364,28 +360,6 @@ public class StaticLayout extends Layout {
}
/**
- * Set available paddings to draw overhanging text on. Arguments are arrays holding the
- * amount of padding available, one per line, measured in pixels. For lines past the last
- * element in the array, the last element repeats.
- *
- * The individual padding amounts should be non-negative. The result of passing negative
- * paddings is undefined.
- *
- * @param leftPaddings array of amounts of available padding for left margin, in pixels
- * @param rightPaddings array of amounts of available padding for right margin, in pixels
- * @return this builder, useful for chaining
- *
- * @hide
- */
- @NonNull
- public Builder setAvailablePaddings(@Nullable int[] leftPaddings,
- @Nullable int[] rightPaddings) {
- mLeftPaddings = leftPaddings;
- mRightPaddings = rightPaddings;
- return this;
- }
-
- /**
* Set paragraph justification mode. The default value is
* {@link Layout#JUSTIFICATION_MODE_NONE}. If the last line is too short for justification,
* the last line will be displayed with the alignment set by {@link #setAlignment}.
@@ -445,8 +419,6 @@ public class StaticLayout extends Layout {
private int mHyphenationFrequency;
@Nullable private int[] mLeftIndents;
@Nullable private int[] mRightIndents;
- @Nullable private int[] mLeftPaddings;
- @Nullable private int[] mRightPaddings;
private int mJustificationMode;
private boolean mAddLastLineLineSpacing;
@@ -596,8 +568,6 @@ public class StaticLayout extends Layout {
mLeftIndents = b.mLeftIndents;
mRightIndents = b.mRightIndents;
- mLeftPaddings = b.mLeftPaddings;
- mRightPaddings = b.mRightPaddings;
setJustificationMode(b.mJustificationMode);
generate(b, b.mIncludePad, b.mIncludePad);
@@ -649,7 +619,7 @@ public class StaticLayout extends Layout {
b.mBreakStrategy, b.mHyphenationFrequency,
// TODO: Support more justification mode, e.g. letter spacing, stretching.
b.mJustificationMode != Layout.JUSTIFICATION_MODE_NONE,
- indents, mLeftPaddings, mRightPaddings);
+ indents);
PrecomputedText.ParagraphInfo[] paragraphInfo = null;
final Spanned spanned = (source instanceof Spanned) ? (Spanned) source : null;
@@ -1341,9 +1311,7 @@ public class StaticLayout extends Layout {
@BreakStrategy int breakStrategy,
@HyphenationFrequency int hyphenationFrequency,
boolean isJustified,
- @Nullable int[] indents,
- @Nullable int[] leftPaddings,
- @Nullable int[] rightPaddings);
+ @Nullable int[] indents);
@CriticalNative
private static native void nFinish(long nativePtr);
@@ -1442,6 +1410,4 @@ public class StaticLayout extends Layout {
@Nullable private int[] mLeftIndents;
@Nullable private int[] mRightIndents;
- @Nullable private int[] mLeftPaddings;
- @Nullable private int[] mRightPaddings;
}
diff --git a/core/java/android/util/FeatureFlagUtils.java b/core/java/android/util/FeatureFlagUtils.java
index ce334aeb529f..ec045b16a734 100644
--- a/core/java/android/util/FeatureFlagUtils.java
+++ b/core/java/android/util/FeatureFlagUtils.java
@@ -39,7 +39,6 @@ public class FeatureFlagUtils {
DEFAULT_FLAGS = new HashMap<>();
DEFAULT_FLAGS.put("settings_battery_display_app_list", "false");
DEFAULT_FLAGS.put("settings_bluetooth_while_driving", "false");
- DEFAULT_FLAGS.put("settings_data_usage_v2", "true");
DEFAULT_FLAGS.put("settings_audio_switcher", "true");
DEFAULT_FLAGS.put("settings_systemui_theme", "true");
}
diff --git a/core/java/android/util/TimestampedValue.java b/core/java/android/util/TimestampedValue.java
new file mode 100644
index 000000000000..21603801d4cb
--- /dev/null
+++ b/core/java/android/util/TimestampedValue.java
@@ -0,0 +1,121 @@
+/*
+ * 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 android.util;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.os.Parcel;
+import android.os.SystemClock;
+
+import java.util.Objects;
+
+/**
+ * A value with an associated reference time. The reference time will typically be provided by the
+ * elapsed realtime clock. The elapsed realtime clock can be obtained using methods like
+ * {@link SystemClock#elapsedRealtime()} or {@link SystemClock#elapsedRealtimeClock()}.
+ * If a suitable clock is used the reference time can be used to identify the age of a value or
+ * ordering between values.
+ *
+ * <p>To read and write a timestamped value from / to a Parcel see
+ * {@link #readFromParcel(Parcel, ClassLoader, Class)} and
+ * {@link #writeToParcel(Parcel, TimestampedValue)}.
+ *
+ * @param <T> the type of the value with an associated timestamp
+ * @hide
+ */
+public final class TimestampedValue<T> {
+ private final long mReferenceTimeMillis;
+ private final T mValue;
+
+ public TimestampedValue(long referenceTimeMillis, T value) {
+ mReferenceTimeMillis = referenceTimeMillis;
+ mValue = value;
+ }
+
+ public long getReferenceTimeMillis() {
+ return mReferenceTimeMillis;
+ }
+
+ public T getValue() {
+ return mValue;
+ }
+
+ @Override
+ public boolean equals(Object o) {
+ if (this == o) {
+ return true;
+ }
+ if (o == null || getClass() != o.getClass()) {
+ return false;
+ }
+ TimestampedValue<?> that = (TimestampedValue<?>) o;
+ return mReferenceTimeMillis == that.mReferenceTimeMillis
+ && Objects.equals(mValue, that.mValue);
+ }
+
+ @Override
+ public int hashCode() {
+ return Objects.hash(mReferenceTimeMillis, mValue);
+ }
+
+ /**
+ * Read a {@link TimestampedValue} from a parcel that was stored using
+ * {@link #writeToParcel(Parcel, TimestampedValue)}.
+ *
+ * <p>The marshalling/unmarshalling of the value relies upon {@link Parcel#writeValue(Object)}
+ * and {@link Parcel#readValue(ClassLoader)} and so this method can only be used with types
+ * supported by those methods.
+ *
+ * @param in the Parcel to read from
+ * @param classLoader the ClassLoader to pass to {@link Parcel#readValue(ClassLoader)}
+ * @param valueClass the expected type of the value, typically the same as {@code <T>} but can
+ * also be a subclass
+ * @throws RuntimeException if the value read is not compatible with {@code valueClass} or the
+ * object could not be read
+ */
+ @SuppressWarnings("unchecked")
+ @NonNull
+ public static <T> TimestampedValue<T> readFromParcel(
+ @NonNull Parcel in, @Nullable ClassLoader classLoader, Class<? extends T> valueClass) {
+ long referenceTimeMillis = in.readLong();
+ T value = (T) in.readValue(classLoader);
+ // Equivalent to static code: if (!(value.getClass() instanceof {valueClass})) {
+ if (value != null && !valueClass.isAssignableFrom(value.getClass())) {
+ throw new RuntimeException("Value was of type " + value.getClass()
+ + " is not assignable to " + valueClass);
+ }
+ return new TimestampedValue<>(referenceTimeMillis, value);
+ }
+
+ /**
+ * Write a {@link TimestampedValue} to a parcel so that it can be read using
+ * {@link #readFromParcel(Parcel, ClassLoader, Class)}.
+ *
+ * <p>The marshalling/unmarshalling of the value relies upon {@link Parcel#writeValue(Object)}
+ * and {@link Parcel#readValue(ClassLoader)} and so this method can only be used with types
+ * supported by those methods.
+ *
+ * @param dest the Parcel
+ * @param timestampedValue the value
+ * @throws RuntimeException if the value could not be written to the Parcel
+ */
+ public static void writeToParcel(
+ @NonNull Parcel dest, @NonNull TimestampedValue<?> timestampedValue) {
+ dest.writeLong(timestampedValue.mReferenceTimeMillis);
+ dest.writeValue(timestampedValue.mValue);
+ }
+}
diff --git a/core/java/android/view/View.java b/core/java/android/view/View.java
index 42e1adc65a79..964ee5eee06d 100644
--- a/core/java/android/view/View.java
+++ b/core/java/android/view/View.java
@@ -788,6 +788,13 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
protected static final String VIEW_LOG_TAG = "View";
/**
+ * The logging tag used by this class when logging verbose, autofill-related messages.
+ */
+ // NOTE: We cannot use android.view.autofill.Helper.sVerbose because that variable is not
+ // set if a session is not started.
+ private static final String AUTOFILL_LOG_TAG = "View.Autofill";
+
+ /**
* When set to true, apps will draw debugging information about their layouts.
*
* @hide
@@ -7979,10 +7986,9 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
private void onProvideVirtualStructureCompat(ViewStructure structure, boolean forAutofill) {
final AccessibilityNodeProvider provider = getAccessibilityNodeProvider();
if (provider != null) {
- if (android.view.autofill.Helper.sVerbose && forAutofill) {
- Log.v(VIEW_LOG_TAG, "onProvideVirtualStructureCompat() for " + this);
+ if (forAutofill && Log.isLoggable(AUTOFILL_LOG_TAG, Log.VERBOSE)) {
+ Log.v(AUTOFILL_LOG_TAG, "onProvideVirtualStructureCompat() for " + this);
}
-
final AccessibilityNodeInfo info = createAccessibilityNodeInfo();
structure.setChildCount(1);
final ViewStructure root = structure.newChild(0);
@@ -8220,8 +8226,8 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
*/
public void setAutofillId(@Nullable AutofillId id) {
// TODO(b/37566627): add unit / CTS test for all possible combinations below
- if (android.view.autofill.Helper.sVerbose) {
- Log.v(VIEW_LOG_TAG, "setAutofill(): from " + mAutofillId + " to " + id);
+ if (Log.isLoggable(AUTOFILL_LOG_TAG, Log.VERBOSE)) {
+ Log.v(AUTOFILL_LOG_TAG, "setAutofill(): from " + mAutofillId + " to " + id);
}
if (isAttachedToWindow()) {
throw new IllegalStateException("Cannot set autofill id when view is attached");
@@ -8424,6 +8430,11 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
final int parentImportance = ((View) parent).getImportantForAutofill();
if (parentImportance == IMPORTANT_FOR_AUTOFILL_NO_EXCLUDE_DESCENDANTS
|| parentImportance == IMPORTANT_FOR_AUTOFILL_YES_EXCLUDE_DESCENDANTS) {
+ if (Log.isLoggable(AUTOFILL_LOG_TAG, Log.VERBOSE)) {
+ Log.v(AUTOFILL_LOG_TAG, "View (autofillId=" + getAutofillViewId() + ", "
+ + getClass() + ") is not important for autofill because parent "
+ + parent + "'s importance is " + parentImportance);
+ }
return false;
}
parent = parent.getParent();
@@ -11905,6 +11916,7 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if ((getVisibility() == VISIBLE)
|| (changeType == AccessibilityEvent.CONTENT_CHANGE_TYPE_PANE_DISAPPEARED)) {
final AccessibilityEvent event = AccessibilityEvent.obtain();
+ onInitializeAccessibilityEvent(event);
event.setEventType(AccessibilityEvent.TYPE_WINDOW_STATE_CHANGED);
event.setContentChangeTypes(changeType);
event.setSource(this);
@@ -18636,10 +18648,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
if ((mPrivateFlags3 & PFLAG3_AUTOFILLID_EXPLICITLY_SET) != 0) {
// Ignore when view already set it through setAutofillId();
- if (android.view.autofill.Helper.sDebug) {
- Log.d(VIEW_LOG_TAG, "onRestoreInstanceState(): not setting autofillId to "
- + baseState.mAutofillViewId + " because view explicitly set it to "
- + mAutofillId);
+ if (Log.isLoggable(AUTOFILL_LOG_TAG, Log.DEBUG)) {
+ Log.d(AUTOFILL_LOG_TAG, "onRestoreInstanceState(): not setting autofillId "
+ + "to " + baseState.mAutofillViewId + " because view explicitly set"
+ + " it to " + mAutofillId);
}
} else {
mAutofillViewId = baseState.mAutofillViewId;
@@ -26901,10 +26913,10 @@ public class View implements Drawable.Callback, KeyEvent.Callback,
* version supported by the application. For example, the method
* {@link View#onInitializeAccessibilityNodeInfo(AccessibilityNodeInfo)} is not available
* in API version 4 when the accessibility APIs were first introduced. If a
- * developer would like his application to run on API version 4 devices (assuming
+ * developer would like their application to run on API version 4 devices (assuming
* all other APIs used by the application are version 4 or lower) and take advantage
* of this method, instead of overriding the method which would break the application's
- * backwards compatibility, he can override the corresponding method in this
+ * backwards compatibility, they can override the corresponding method in this
* delegate and register the delegate in the target View if the API version of
* the system is high enough, i.e. the API version is the same as or higher than the API
* version that introduced
diff --git a/core/java/android/view/ViewRootImpl.java b/core/java/android/view/ViewRootImpl.java
index d839d759b52e..dd241852a441 100644
--- a/core/java/android/view/ViewRootImpl.java
+++ b/core/java/android/view/ViewRootImpl.java
@@ -3297,8 +3297,11 @@ public final class ViewRootImpl implements ViewParent,
}
useAsyncReport = true;
- mAttachInfo.mThreadedRenderer.draw(mView, mAttachInfo, this, mNextRtFrameCallback);
+
+ // draw(...) might invoke post-draw, which might register the next callback already.
+ final FrameDrawingCallback callback = mNextRtFrameCallback;
mNextRtFrameCallback = null;
+ mAttachInfo.mThreadedRenderer.draw(mView, mAttachInfo, this, callback);
} else {
// If we get here with a disabled & requested hardware renderer, something went
// wrong (an invalidate posted right before we destroyed the hardware surface
diff --git a/core/java/android/view/accessibility/AccessibilityEvent.java b/core/java/android/view/accessibility/AccessibilityEvent.java
index fde9c0d08ebc..a6b8eb3ebf75 100644
--- a/core/java/android/view/accessibility/AccessibilityEvent.java
+++ b/core/java/android/view/accessibility/AccessibilityEvent.java
@@ -686,7 +686,9 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
CONTENT_CHANGE_TYPE_SUBTREE,
CONTENT_CHANGE_TYPE_TEXT,
CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION,
- CONTENT_CHANGE_TYPE_PANE_TITLE
+ CONTENT_CHANGE_TYPE_PANE_TITLE,
+ CONTENT_CHANGE_TYPE_PANE_APPEARED,
+ CONTENT_CHANGE_TYPE_PANE_DISAPPEARED
})
public @interface ContentChangeTypes {}
@@ -875,6 +877,8 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
* <li>{@link #CONTENT_CHANGE_TYPE_TEXT}
* <li>{@link #CONTENT_CHANGE_TYPE_PANE_TITLE}
* <li>{@link #CONTENT_CHANGE_TYPE_UNDEFINED}
+ * <li>{@link #CONTENT_CHANGE_TYPE_PANE_APPEARED}
+ * <li>{@link #CONTENT_CHANGE_TYPE_PANE_DISAPPEARED}
* </ul>
*/
@ContentChangeTypes
@@ -888,13 +892,15 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
private static String singleContentChangeTypeToString(int type) {
switch (type) {
- case CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION: {
+ case CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION:
return "CONTENT_CHANGE_TYPE_CONTENT_DESCRIPTION";
- }
case CONTENT_CHANGE_TYPE_SUBTREE: return "CONTENT_CHANGE_TYPE_SUBTREE";
case CONTENT_CHANGE_TYPE_TEXT: return "CONTENT_CHANGE_TYPE_TEXT";
case CONTENT_CHANGE_TYPE_PANE_TITLE: return "CONTENT_CHANGE_TYPE_PANE_TITLE";
case CONTENT_CHANGE_TYPE_UNDEFINED: return "CONTENT_CHANGE_TYPE_UNDEFINED";
+ case CONTENT_CHANGE_TYPE_PANE_APPEARED: return "CONTENT_CHANGE_TYPE_PANE_APPEARED";
+ case CONTENT_CHANGE_TYPE_PANE_DISAPPEARED:
+ return "CONTENT_CHANGE_TYPE_PANE_DISAPPEARED";
default: return Integer.toHexString(type);
}
}
@@ -945,6 +951,7 @@ public final class AccessibilityEvent extends AccessibilityRecord implements Par
return "WINDOWS_CHANGE_ACCESSIBILITY_FOCUSED";
case WINDOWS_CHANGE_PARENT: return "WINDOWS_CHANGE_PARENT";
case WINDOWS_CHANGE_CHILDREN: return "WINDOWS_CHANGE_CHILDREN";
+ case WINDOWS_CHANGE_PIP: return "WINDOWS_CHANGE_PIP";
default: return Integer.toHexString(type);
}
}
diff --git a/core/java/android/view/autofill/AutofillManager.java b/core/java/android/view/autofill/AutofillManager.java
index 7555ffff3e38..e989e1af742d 100644
--- a/core/java/android/view/autofill/AutofillManager.java
+++ b/core/java/android/view/autofill/AutofillManager.java
@@ -1582,29 +1582,9 @@ public final class AutofillManager {
Log.v(TAG, "updateSessionLocked(): id=" + id + ", bounds=" + bounds
+ ", value=" + value + ", action=" + action + ", flags=" + flags);
}
- boolean restartIfNecessary = (flags & FLAG_MANUAL_REQUEST) != 0;
-
try {
- if (restartIfNecessary) {
- final AutofillClient client = getClient();
- if (client == null) return; // NOTE: getClient() already logd it..
-
- final int newId = mService.updateOrRestartSession(
- client.autofillClientGetActivityToken(),
- mServiceClient.asBinder(), id, bounds, value, mContext.getUserId(),
- mCallback != null, flags, client.autofillClientGetComponentName(),
- mSessionId, action, isCompatibilityModeEnabledLocked());
- if (newId != mSessionId) {
- if (sDebug) Log.d(TAG, "Session restarted: " + mSessionId + "=>" + newId);
- mSessionId = newId;
- mState = (mSessionId == NO_SESSION) ? STATE_UNKNOWN : STATE_ACTIVE;
- client.autofillClientResetableStateAvailable();
- }
- } else {
- mService.updateSession(mSessionId, id, bounds, value, action, flags,
- mContext.getUserId());
- }
-
+ mService.updateSession(mSessionId, id, bounds, value, action, flags,
+ mContext.getUserId());
} catch (RemoteException e) {
throw e.rethrowFromSystemServer();
}
@@ -1738,7 +1718,6 @@ public final class AutofillManager {
return;
}
- AutofillCallback callback = null;
synchronized (mLock) {
if (mSessionId == sessionId) {
AutofillClient client = getClient();
@@ -1823,7 +1802,6 @@ public final class AutofillManager {
for (int i = 0; i < itemCount; i++) {
final AutofillId id = ids.get(i);
final AutofillValue value = values.get(i);
- final int viewId = id.getViewId();
final View view = views[i];
if (view == null) {
// Most likely view has been removed after the initial request was sent to the
@@ -2144,6 +2122,7 @@ public final class AutofillManager {
pw.print(pfx); pw.print("hasCallback: "); pw.println(mCallback != null);
pw.print(pfx); pw.print("onInvisibleCalled "); pw.println(mOnInvisibleCalled);
pw.print(pfx); pw.print("last autofilled data: "); pw.println(mLastAutofilledData);
+ pw.print(pfx); pw.print("id of last fill UI shown: "); pw.println(mIdShownFillUi);
pw.print(pfx); pw.print("tracked views: ");
if (mTrackedViews == null) {
pw.println("null");
diff --git a/core/java/android/view/autofill/IAutoFillManager.aidl b/core/java/android/view/autofill/IAutoFillManager.aidl
index 176df7327b16..738ff4d041f4 100644
--- a/core/java/android/view/autofill/IAutoFillManager.aidl
+++ b/core/java/android/view/autofill/IAutoFillManager.aidl
@@ -45,10 +45,6 @@ interface IAutoFillManager {
boolean restoreSession(int sessionId, in IBinder activityToken, in IBinder appCallback);
void updateSession(int sessionId, in AutofillId id, in Rect bounds,
in AutofillValue value, int action, int flags, int userId);
- int updateOrRestartSession(IBinder activityToken, in IBinder appCallback,
- in AutofillId autoFillId, in Rect bounds, in AutofillValue value, int userId,
- boolean hasCallback, int flags, in ComponentName componentName, int sessionId,
- int action, boolean compatMode);
void setAutofillFailure(int sessionId, in List<AutofillId> ids, int userId);
void finishSession(int sessionId, int userId);
void cancelSession(int sessionId, int userId);
diff --git a/core/java/android/widget/Editor.java b/core/java/android/widget/Editor.java
index d07721a3c27a..058736a71b5c 100644
--- a/core/java/android/widget/Editor.java
+++ b/core/java/android/widget/Editor.java
@@ -4930,6 +4930,7 @@ public class Editor {
protected final void dismissMagnifier() {
if (mMagnifierAnimator != null) {
+ mMagnifierAnimator.mMagnifier.setOnOperationCompleteCallback(null);
mMagnifierAnimator.dismiss();
mRenderCursorRegardlessTiming = false;
resumeBlink();
diff --git a/core/java/android/widget/RemoteViews.java b/core/java/android/widget/RemoteViews.java
index 4865dab6056a..22c840b3bf7e 100644
--- a/core/java/android/widget/RemoteViews.java
+++ b/core/java/android/widget/RemoteViews.java
@@ -68,7 +68,7 @@ import android.view.ViewStub;
import android.widget.AdapterView.OnItemClickListener;
import com.android.internal.R;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.internal.util.Preconditions;
import java.lang.annotation.ElementType;
@@ -2155,7 +2155,7 @@ public class RemoteViews implements Parcelable, Filter {
View v = viewsToProcess.pop();
if (v instanceof TextView) {
TextView textView = (TextView) v;
- textView.setText(NotificationColorUtil.clearColorSpans(textView.getText()));
+ textView.setText(ContrastColorUtil.clearColorSpans(textView.getText()));
textView.setTextColor(textColor);
}
if (v instanceof ViewGroup) {
diff --git a/core/java/android/widget/SpellChecker.java b/core/java/android/widget/SpellChecker.java
index 3d4f54624ecf..fc1172e0457a 100644
--- a/core/java/android/widget/SpellChecker.java
+++ b/core/java/android/widget/SpellChecker.java
@@ -119,8 +119,9 @@ public class SpellChecker implements SpellCheckerSessionListener {
mTextServicesManager = (TextServicesManager) mTextView.getContext().
getSystemService(Context.TEXT_SERVICES_MANAGER_SERVICE);
- if (!mTextServicesManager.isSpellCheckerEnabled()
- || mCurrentLocale == null
+ if (mCurrentLocale == null
+ || mTextView.length() == 0
+ || !mTextServicesManager.isSpellCheckerEnabled()
|| mTextServicesManager.getCurrentSpellCheckerSubtype(true) == null) {
mSpellCheckerSession = null;
} else {
diff --git a/core/java/com/android/internal/app/HeavyWeightSwitcherActivity.java b/core/java/com/android/internal/app/HeavyWeightSwitcherActivity.java
index 4f41875d0deb..7735d84ab751 100644
--- a/core/java/com/android/internal/app/HeavyWeightSwitcherActivity.java
+++ b/core/java/com/android/internal/app/HeavyWeightSwitcherActivity.java
@@ -20,6 +20,7 @@ import com.android.internal.R;
import android.app.Activity;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.content.Intent;
import android.content.IntentSender;
import android.content.pm.ApplicationInfo;
@@ -126,7 +127,7 @@ public class HeavyWeightSwitcherActivity extends Activity {
private OnClickListener mSwitchOldListener = new OnClickListener() {
public void onClick(View v) {
try {
- ActivityManager.getService().moveTaskToFront(mCurTask, 0, null);
+ ActivityTaskManager.getService().moveTaskToFront(mCurTask, 0, null);
} catch (RemoteException e) {
}
finish();
diff --git a/core/java/com/android/internal/app/IntentForwarderActivity.java b/core/java/com/android/internal/app/IntentForwarderActivity.java
index 398d08791b5c..abb9321a50a8 100644
--- a/core/java/com/android/internal/app/IntentForwarderActivity.java
+++ b/core/java/com/android/internal/app/IntentForwarderActivity.java
@@ -18,6 +18,7 @@ package com.android.internal.app;
import android.app.Activity;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.ActivityThread;
import android.app.AppGlobals;
import android.app.admin.DevicePolicyManager;
@@ -112,9 +113,9 @@ public class IntentForwarderActivity extends Activity {
int launchedFromUid = -1;
String launchedFromPackage = "?";
try {
- launchedFromUid = ActivityManager.getService().getLaunchedFromUid(
+ launchedFromUid = ActivityTaskManager.getService().getLaunchedFromUid(
getActivityToken());
- launchedFromPackage = ActivityManager.getService().getLaunchedFromPackage(
+ launchedFromPackage = ActivityTaskManager.getService().getLaunchedFromPackage(
getActivityToken());
} catch (RemoteException ignored) {
}
diff --git a/core/java/com/android/internal/app/ResolverActivity.java b/core/java/com/android/internal/app/ResolverActivity.java
index ceb06f511108..0a812c68854f 100644
--- a/core/java/com/android/internal/app/ResolverActivity.java
+++ b/core/java/com/android/internal/app/ResolverActivity.java
@@ -21,6 +21,7 @@ import android.annotation.StringRes;
import android.annotation.UiThread;
import android.app.Activity;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.ActivityThread;
import android.app.VoiceInteractor.PickOptionRequest;
import android.app.VoiceInteractor.PickOptionRequest.Option;
@@ -260,7 +261,7 @@ public class ResolverActivity extends Activity {
setProfileSwitchMessageId(intent.getContentUserHint());
try {
- mLaunchedFromUid = ActivityManager.getService().getLaunchedFromUid(
+ mLaunchedFromUid = ActivityTaskManager.getService().getLaunchedFromUid(
getActivityToken());
} catch (RemoteException e) {
mLaunchedFromUid = -1;
@@ -846,7 +847,7 @@ public class ResolverActivity extends Activity {
} catch (RuntimeException e) {
String launchedFromPackage;
try {
- launchedFromPackage = ActivityManager.getService().getLaunchedFromPackage(
+ launchedFromPackage = ActivityTaskManager.getService().getLaunchedFromPackage(
getActivityToken());
} catch (RemoteException e2) {
launchedFromPackage = "??";
diff --git a/core/java/com/android/internal/policy/PhoneWindow.java b/core/java/com/android/internal/policy/PhoneWindow.java
index c63edaff1098..ac7dc8e29b55 100644
--- a/core/java/com/android/internal/policy/PhoneWindow.java
+++ b/core/java/com/android/internal/policy/PhoneWindow.java
@@ -2031,7 +2031,7 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
* Do this in onKeyUp since the Search key is also used for
* chording quick launch shortcuts.
*/
- if (getKeyguardManager().inKeyguardRestrictedInputMode()) {
+ if (isNotInstantAppAndKeyguardRestricted()) {
break;
}
if ((getContext().getResources().getConfiguration().uiMode
@@ -2055,6 +2055,11 @@ public class PhoneWindow extends Window implements MenuBuilder.Callback {
return false;
}
+ private boolean isNotInstantAppAndKeyguardRestricted() {
+ return !getContext().getPackageManager().isInstantApp()
+ && getKeyguardManager().inKeyguardRestrictedInputMode();
+ }
+
@Override
protected void onActive() {
}
diff --git a/core/java/com/android/internal/util/NotificationColorUtil.java b/core/java/com/android/internal/util/ContrastColorUtil.java
index 318bccf68f57..60dd86b1fc10 100644
--- a/core/java/com/android/internal/util/NotificationColorUtil.java
+++ b/core/java/com/android/internal/util/ContrastColorUtil.java
@@ -48,13 +48,13 @@ import java.util.WeakHashMap;
*
* @hide
*/
-public class NotificationColorUtil {
+public class ContrastColorUtil {
- private static final String TAG = "NotificationColorUtil";
+ private static final String TAG = "ContrastColorUtil";
private static final boolean DEBUG = false;
private static final Object sLock = new Object();
- private static NotificationColorUtil sInstance;
+ private static ContrastColorUtil sInstance;
private final ImageUtils mImageUtils = new ImageUtils();
private final WeakHashMap<Bitmap, Pair<Boolean, Integer>> mGrayscaleBitmapCache =
@@ -62,16 +62,16 @@ public class NotificationColorUtil {
private final int mGrayscaleIconMaxSize; // @dimen/notification_large_icon_width (64dp)
- public static NotificationColorUtil getInstance(Context context) {
+ public static ContrastColorUtil getInstance(Context context) {
synchronized (sLock) {
if (sInstance == null) {
- sInstance = new NotificationColorUtil(context);
+ sInstance = new ContrastColorUtil(context);
}
return sInstance;
}
}
- private NotificationColorUtil(Context context) {
+ private ContrastColorUtil(Context context) {
mGrayscaleIconMaxSize = context.getResources().getDimensionPixelSize(
com.android.internal.R.dimen.notification_large_icon_width);
}
@@ -470,7 +470,7 @@ public class NotificationColorUtil {
*/
public static int resolveContrastColor(Context context, int notificationColor,
int backgroundColor) {
- return NotificationColorUtil.resolveContrastColor(context, notificationColor,
+ return ContrastColorUtil.resolveContrastColor(context, notificationColor,
backgroundColor, false /* isDark */);
}
@@ -489,7 +489,7 @@ public class NotificationColorUtil {
final int resolvedColor = resolveColor(context, notificationColor);
int color = resolvedColor;
- color = NotificationColorUtil.ensureTextContrast(color, backgroundColor, isDark);
+ color = ContrastColorUtil.ensureTextContrast(color, backgroundColor, isDark);
if (color != resolvedColor) {
if (DEBUG){
@@ -497,7 +497,7 @@ public class NotificationColorUtil {
"Enhanced contrast of notification for %s"
+ " and %s (over background) by changing #%s to %s",
context.getPackageName(),
- NotificationColorUtil.contrastChange(resolvedColor, color, backgroundColor),
+ ContrastColorUtil.contrastChange(resolvedColor, color, backgroundColor),
Integer.toHexString(resolvedColor), Integer.toHexString(color)));
}
}
@@ -523,7 +523,7 @@ public class NotificationColorUtil {
final int resolvedColor = resolveColor(context, notificationColor);
int color = resolvedColor;
- color = NotificationColorUtil.ensureTextContrastOnBlack(color);
+ color = ContrastColorUtil.ensureTextContrastOnBlack(color);
if (color != resolvedColor) {
if (DEBUG){
@@ -531,7 +531,7 @@ public class NotificationColorUtil {
"Ambient contrast of notification for %s is %s (over black)"
+ " by changing #%s to #%s",
context.getPackageName(),
- NotificationColorUtil.contrastChange(resolvedColor, color, Color.BLACK),
+ ContrastColorUtil.contrastChange(resolvedColor, color, Color.BLACK),
Integer.toHexString(resolvedColor), Integer.toHexString(color)));
}
}
@@ -609,7 +609,7 @@ public class NotificationColorUtil {
}
public static boolean satisfiesTextContrast(int backgroundColor, int foregroundColor) {
- return NotificationColorUtil.calculateContrast(foregroundColor, backgroundColor) >= 4.5;
+ return ContrastColorUtil.calculateContrast(foregroundColor, backgroundColor) >= 4.5;
}
/**
diff --git a/core/java/com/android/internal/widget/MessagingLayout.java b/core/java/com/android/internal/widget/MessagingLayout.java
index 0fd610908fd5..514874b1bdaa 100644
--- a/core/java/com/android/internal/widget/MessagingLayout.java
+++ b/core/java/com/android/internal/widget/MessagingLayout.java
@@ -45,7 +45,7 @@ import android.widget.TextView;
import com.android.internal.R;
import com.android.internal.graphics.ColorUtils;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import java.util.ArrayList;
import java.util.List;
@@ -315,13 +315,13 @@ public class MessagingLayout extends FrameLayout {
}
private int findColor(CharSequence senderName, int layoutColor) {
- double luminance = NotificationColorUtil.calculateLuminance(layoutColor);
+ double luminance = ContrastColorUtil.calculateLuminance(layoutColor);
float shift = Math.abs(senderName.hashCode()) % 5 / 4.0f - 0.5f;
// we need to offset the range if the luminance is too close to the borders
shift += Math.max(COLOR_SHIFT_AMOUNT / 2.0f / 100 - luminance, 0);
shift -= Math.max(COLOR_SHIFT_AMOUNT / 2.0f / 100 - (1.0f - luminance), 0);
- return NotificationColorUtil.getShiftedColor(layoutColor,
+ return ContrastColorUtil.getShiftedColor(layoutColor,
(int) (shift * COLOR_SHIFT_AMOUNT));
}
diff --git a/core/java/com/android/internal/widget/PointerLocationView.java b/core/java/com/android/internal/widget/PointerLocationView.java
index 5847033feb1e..4ee951aeddaf 100644
--- a/core/java/com/android/internal/widget/PointerLocationView.java
+++ b/core/java/com/android/internal/widget/PointerLocationView.java
@@ -32,6 +32,7 @@ import android.view.MotionEvent;
import android.view.VelocityTracker;
import android.view.View;
import android.view.ViewConfiguration;
+import android.view.WindowInsets;
import android.view.WindowManagerPolicyConstants.PointerEventListener;
import android.view.MotionEvent.PointerCoords;
@@ -120,6 +121,7 @@ public class PointerLocationView extends View implements InputDeviceListener,
private final Paint mPathPaint;
private final FontMetricsInt mTextMetrics = new FontMetricsInt();
private int mHeaderBottom;
+ private int mHeaderPaddingTop = 0;
private boolean mCurDown;
private int mCurNumPointers;
private int mMaxNumPointers;
@@ -189,12 +191,22 @@ public class PointerLocationView extends View implements InputDeviceListener,
public void setPrintCoords(boolean state) {
mPrintCoords = state;
}
-
+
+ @Override
+ public WindowInsets onApplyWindowInsets(WindowInsets insets) {
+ if (insets.getDisplayCutout() != null) {
+ mHeaderPaddingTop = insets.getDisplayCutout().getSafeInsetTop();
+ } else {
+ mHeaderPaddingTop = 0;
+ }
+ return super.onApplyWindowInsets(insets);
+ }
+
@Override
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
mTextPaint.getFontMetricsInt(mTextMetrics);
- mHeaderBottom = -mTextMetrics.ascent+mTextMetrics.descent+2;
+ mHeaderBottom = mHeaderPaddingTop-mTextMetrics.ascent+mTextMetrics.descent+2;
if (false) {
Log.i("foo", "Metrics: ascent=" + mTextMetrics.ascent
+ " descent=" + mTextMetrics.descent
@@ -223,7 +235,7 @@ public class PointerLocationView extends View implements InputDeviceListener,
protected void onDraw(Canvas canvas) {
final int w = getWidth();
final int itemW = w/7;
- final int base = -mTextMetrics.ascent+1;
+ final int base = mHeaderPaddingTop-mTextMetrics.ascent+1;
final int bottom = mHeaderBottom;
final int NP = mPointers.size();
@@ -232,7 +244,7 @@ public class PointerLocationView extends View implements InputDeviceListener,
if (mActivePointerId >= 0) {
final PointerState ps = mPointers.get(mActivePointerId);
- canvas.drawRect(0, 0, itemW-1, bottom,mTextBackgroundPaint);
+ canvas.drawRect(0, mHeaderPaddingTop, itemW-1, bottom,mTextBackgroundPaint);
canvas.drawText(mText.clear()
.append("P: ").append(mCurNumPointers)
.append(" / ").append(mMaxNumPointers)
@@ -240,24 +252,26 @@ public class PointerLocationView extends View implements InputDeviceListener,
final int N = ps.mTraceCount;
if ((mCurDown && ps.mCurDown) || N == 0) {
- canvas.drawRect(itemW, 0, (itemW * 2) - 1, bottom, mTextBackgroundPaint);
+ canvas.drawRect(itemW, mHeaderPaddingTop, (itemW * 2) - 1, bottom,
+ mTextBackgroundPaint);
canvas.drawText(mText.clear()
.append("X: ").append(ps.mCoords.x, 1)
.toString(), 1 + itemW, base, mTextPaint);
- canvas.drawRect(itemW * 2, 0, (itemW * 3) - 1, bottom, mTextBackgroundPaint);
+ canvas.drawRect(itemW * 2, mHeaderPaddingTop, (itemW * 3) - 1, bottom,
+ mTextBackgroundPaint);
canvas.drawText(mText.clear()
.append("Y: ").append(ps.mCoords.y, 1)
.toString(), 1 + itemW * 2, base, mTextPaint);
} else {
float dx = ps.mTraceX[N - 1] - ps.mTraceX[0];
float dy = ps.mTraceY[N - 1] - ps.mTraceY[0];
- canvas.drawRect(itemW, 0, (itemW * 2) - 1, bottom,
+ canvas.drawRect(itemW, mHeaderPaddingTop, (itemW * 2) - 1, bottom,
Math.abs(dx) < mVC.getScaledTouchSlop()
? mTextBackgroundPaint : mTextLevelPaint);
canvas.drawText(mText.clear()
.append("dX: ").append(dx, 1)
.toString(), 1 + itemW, base, mTextPaint);
- canvas.drawRect(itemW * 2, 0, (itemW * 3) - 1, bottom,
+ canvas.drawRect(itemW * 2, mHeaderPaddingTop, (itemW * 3) - 1, bottom,
Math.abs(dy) < mVC.getScaledTouchSlop()
? mTextBackgroundPaint : mTextLevelPaint);
canvas.drawText(mText.clear()
@@ -265,26 +279,29 @@ public class PointerLocationView extends View implements InputDeviceListener,
.toString(), 1 + itemW * 2, base, mTextPaint);
}
- canvas.drawRect(itemW * 3, 0, (itemW * 4) - 1, bottom, mTextBackgroundPaint);
+ canvas.drawRect(itemW * 3, mHeaderPaddingTop, (itemW * 4) - 1, bottom,
+ mTextBackgroundPaint);
canvas.drawText(mText.clear()
.append("Xv: ").append(ps.mXVelocity, 3)
.toString(), 1 + itemW * 3, base, mTextPaint);
- canvas.drawRect(itemW * 4, 0, (itemW * 5) - 1, bottom, mTextBackgroundPaint);
+ canvas.drawRect(itemW * 4, mHeaderPaddingTop, (itemW * 5) - 1, bottom,
+ mTextBackgroundPaint);
canvas.drawText(mText.clear()
.append("Yv: ").append(ps.mYVelocity, 3)
.toString(), 1 + itemW * 4, base, mTextPaint);
- canvas.drawRect(itemW * 5, 0, (itemW * 6) - 1, bottom, mTextBackgroundPaint);
- canvas.drawRect(itemW * 5, 0, (itemW * 5) + (ps.mCoords.pressure * itemW) - 1,
- bottom, mTextLevelPaint);
+ canvas.drawRect(itemW * 5, mHeaderPaddingTop, (itemW * 6) - 1, bottom,
+ mTextBackgroundPaint);
+ canvas.drawRect(itemW * 5, mHeaderPaddingTop,
+ (itemW * 5) + (ps.mCoords.pressure * itemW) - 1, bottom, mTextLevelPaint);
canvas.drawText(mText.clear()
.append("Prs: ").append(ps.mCoords.pressure, 2)
.toString(), 1 + itemW * 5, base, mTextPaint);
- canvas.drawRect(itemW * 6, 0, w, bottom, mTextBackgroundPaint);
- canvas.drawRect(itemW * 6, 0, (itemW * 6) + (ps.mCoords.size * itemW) - 1,
- bottom, mTextLevelPaint);
+ canvas.drawRect(itemW * 6, mHeaderPaddingTop, w, bottom, mTextBackgroundPaint);
+ canvas.drawRect(itemW * 6, mHeaderPaddingTop,
+ (itemW * 6) + (ps.mCoords.size * itemW) - 1, bottom, mTextLevelPaint);
canvas.drawText(mText.clear()
.append("Size: ").append(ps.mCoords.size, 2)
.toString(), 1 + itemW * 6, base, mTextPaint);
diff --git a/core/jni/AndroidRuntime.cpp b/core/jni/AndroidRuntime.cpp
index e784de9df874..bd2a8def2618 100644
--- a/core/jni/AndroidRuntime.cpp
+++ b/core/jni/AndroidRuntime.cpp
@@ -915,10 +915,13 @@ int AndroidRuntime::startVm(JavaVM** pJavaVM, JNIEnv** pEnv, bool zygote)
}
// Native bridge library. "0" means that native bridge is disabled.
+ //
+ // Note: bridging is only enabled for the zygote. Other runs of
+ // app_process may not have the permissions to mount etc.
property_get("ro.dalvik.vm.native.bridge", propBuf, "");
if (propBuf[0] == '\0') {
ALOGW("ro.dalvik.vm.native.bridge is not expected to be empty");
- } else if (strcmp(propBuf, "0") != 0) {
+ } else if (zygote && strcmp(propBuf, "0") != 0) {
snprintf(nativeBridgeLibrary, sizeof("-XX:NativeBridge=") + PROPERTY_VALUE_MAX,
"-XX:NativeBridge=%s", propBuf);
addOption(nativeBridgeLibrary);
diff --git a/core/jni/android_text_StaticLayout.cpp b/core/jni/android_text_StaticLayout.cpp
index 682dc8739869..ad84858bb8db 100644
--- a/core/jni/android_text_StaticLayout.cpp
+++ b/core/jni/android_text_StaticLayout.cpp
@@ -69,15 +69,12 @@ static inline minikin::android::StaticLayoutNative* toNative(jlong ptr) {
// set text and set a number of parameters for creating a layout (width, tabstops, strategy,
// hyphenFrequency)
static jlong nInit(JNIEnv* env, jclass /* unused */,
- jint breakStrategy, jint hyphenationFrequency, jboolean isJustified,
- jintArray indents, jintArray leftPaddings, jintArray rightPaddings) {
+ jint breakStrategy, jint hyphenationFrequency, jboolean isJustified, jintArray indents) {
return reinterpret_cast<jlong>(new minikin::android::StaticLayoutNative(
static_cast<minikin::BreakStrategy>(breakStrategy),
static_cast<minikin::HyphenationFrequency>(hyphenationFrequency),
isJustified,
- jintArrayToFloatVector(env, indents),
- jintArrayToFloatVector(env, leftPaddings),
- jintArrayToFloatVector(env, rightPaddings)));
+ jintArrayToFloatVector(env, indents)));
}
// CriticalNative
@@ -161,8 +158,6 @@ static const JNINativeMethod gMethods[] = {
"I" // hyphenationFrequency
"Z" // isJustified
"[I" // indents
- "[I" // left paddings
- "[I" // right paddings
")J", (void*) nInit},
// Critical Natives
diff --git a/core/proto/android/providers/settings/global.proto b/core/proto/android/providers/settings/global.proto
index 99f303431055..04e5658be5a0 100644
--- a/core/proto/android/providers/settings/global.proto
+++ b/core/proto/android/providers/settings/global.proto
@@ -600,14 +600,17 @@ message GlobalSettingsProto {
}
optional Ntp ntp = 84;
- // Details about the User Absent, Radios Off feature.
- message UserAbsentRadiosOff {
+ // Details about the User Absent For Small Battery feature.
+ message UserAbsentSmallBattery {
option (android.msg_privacy).dest = DEST_EXPLICIT;
- // Whether or not to enable the User Absent, Radios Off feature on small battery devices.
- optional SettingProto enabled_for_small_battery = 1 [ (android.privacy).dest = DEST_AUTOMATIC ];
+ // Whether or not to enable the User Absent, Radios Off feature
+ optional SettingProto radios_off_enabled = 1 [ (android.privacy).dest = DEST_AUTOMATIC ];
+
+ // Whether or not to enable the User Absent, Touch Off feature
+ optional SettingProto touch_off_enabled = 2 [ (android.privacy).dest = DEST_AUTOMATIC ];
}
- optional UserAbsentRadiosOff user_absent_radios_off = 85;
+ optional UserAbsentSmallBattery user_absent_small_battery = 85;
// Whether to disable the automatic scheduling of system updates.
optional SettingProto ota_disable_automatic_update = 86 [ (android.privacy).dest = DEST_AUTOMATIC ];
diff --git a/core/res/AndroidManifest.xml b/core/res/AndroidManifest.xml
index 1b41f993ce44..e33ecb89d9dd 100644
--- a/core/res/AndroidManifest.xml
+++ b/core/res/AndroidManifest.xml
@@ -843,6 +843,19 @@
android:description="@string/permdesc_accessCoarseLocation"
android:protectionLevel="dangerous|instant" />
+ <!-- Allows an app to access location in the background. If you
+ are requesting this, you should also request {@link #ACCESS_FINE_LOCATION}.
+ Requesting this by itself is not sufficient to give you
+ location access.
+ <p>Protection level: dangerous
+ @hide
+ -->
+ <permission android:name="android.permission.ACCESS_BACKGROUND_LOCATION"
+ android:permissionGroup="android.permission-group.LOCATION"
+ android:label="@string/permlab_accessBackgroundLocation"
+ android:description="@string/permdesc_accessBackgroundLocation"
+ android:protectionLevel="dangerous|instant" />
+
<!-- ====================================================================== -->
<!-- Permissions for accessing the call log -->
<!-- ====================================================================== -->
@@ -3024,15 +3037,6 @@
<permission android:name="android.permission.INSTALL_PACKAGE_UPDATES"
android:protectionLevel="signature|privileged" />
- <!-- Allows an application to install existing system packages. This is a limited
- version of {@link android.Manifest.permission#INSTALL_PACKAGES}.
- <p>Not for use by third-party applications.
- TODO(b/80204953): remove this permission once we have a long-term solution.
- @hide
- -->
- <permission android:name="com.android.permission.INSTALL_EXISTING_PACKAGES"
- android:protectionLevel="signature|privileged" />
-
<!-- @SystemApi Allows an application to clear user data.
<p>Not for use by third-party applications
@hide
diff --git a/core/res/res/drawable-watch/toast_frame.xml b/core/res/res/drawable-watch/toast_frame.xml
new file mode 100644
index 000000000000..60129a2086fd
--- /dev/null
+++ b/core/res/res/drawable-watch/toast_frame.xml
@@ -0,0 +1,24 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/* Copyright 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.
+*/
+-->
+<shape xmlns:android="http://schemas.android.com/apk/res/android"
+ android:shape="rectangle">
+ <!-- background is material_grey_700 with .9 alpha -->
+ <solid android:color="#E65F6368" />
+ <corners android:radius="24dp" />
+</shape>
+
diff --git a/core/res/res/layout-watch/transient_notification.xml b/core/res/res/layout-watch/transient_notification.xml
new file mode 100644
index 000000000000..aeae699eaa7d
--- /dev/null
+++ b/core/res/res/layout-watch/transient_notification.xml
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+/*
+**
+** Copyright 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.
+*/
+-->
+<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
+ android:layout_width="match_parent"
+ android:layout_height="match_parent"
+ android:paddingHorizontal="@dimen/screen_percentage_05"
+ android:orientation="vertical">
+ <TextView
+ android:id="@android:id/message"
+ android:layout_width="wrap_content"
+ android:layout_height="wrap_content"
+ android:layout_weight="1"
+ android:minHeight="48dp"
+ android:paddingHorizontal="16dp"
+ android:paddingVertical="8dp"
+ android:gravity="center"
+ android:textAppearance="@style/TextAppearance.Toast"
+ android:background="?android:attr/toastFrameBackground"
+ />
+</LinearLayout> \ No newline at end of file
diff --git a/core/res/res/values-w210dp-round-watch/styles.xml b/core/res/res/values-w210dp-round-watch/styles.xml
new file mode 100644
index 000000000000..f10374c67cb3
--- /dev/null
+++ b/core/res/res/values-w210dp-round-watch/styles.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources>
+ <style name="TextAppearance.Toast">
+ <item name="fontFamily">roboto</item>
+ <item name="textSize">15sp</item>
+ </style>
+</resources> \ No newline at end of file
diff --git a/core/res/res/values-watch/config.xml b/core/res/res/values-watch/config.xml
index e12f04af773b..8e824791ef15 100644
--- a/core/res/res/values-watch/config.xml
+++ b/core/res/res/values-watch/config.xml
@@ -68,4 +68,7 @@
<bool name="config_supportsMultiWindow">true</bool>
<bool name="config_supportsMultiDisplay">true</bool>
<bool name="config_supportsSplitScreenMultiWindow">false</bool>
+
+ <!-- Default Gravity setting for the system Toast view. Equivalent to: Gravity.CENTER -->
+ <integer name="config_toastDefaultGravity">0x00000011</integer>
</resources>
diff --git a/core/res/res/values-watch/dimens.xml b/core/res/res/values-watch/dimens.xml
index 4c8b39ca92a7..5472316487fb 100644
--- a/core/res/res/values-watch/dimens.xml
+++ b/core/res/res/values-watch/dimens.xml
@@ -18,4 +18,6 @@
<dimen name="alert_dialog_title_height">0dp</dimen>
<!-- Dialog button bar height, not used in watch due to dynamically sized button bar -->
<dimen name="alert_dialog_button_bar_height">0dp</dimen>
+
+ <dimen name="toast_y_offset">0dip</dimen>
</resources>
diff --git a/core/res/res/values-watch/styles.xml b/core/res/res/values-watch/styles.xml
new file mode 100644
index 000000000000..3172f735f3fc
--- /dev/null
+++ b/core/res/res/values-watch/styles.xml
@@ -0,0 +1,22 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!-- 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.
+-->
+
+<resources>
+ <style name="TextAppearance.Toast">
+ <item name="fontFamily">sans-serif-regular</item>
+ <item name="textSize">13sp</item>
+ </style>
+</resources>
diff --git a/core/res/res/values/strings.xml b/core/res/res/values/strings.xml
index 8f469b0db3ec..9dccc8818c0e 100644
--- a/core/res/res/values/strings.xml
+++ b/core/res/res/values/strings.xml
@@ -147,19 +147,19 @@
<!-- Displayed to tell the user that they cannot change the caller ID setting. -->
<string name="CLIRPermanent">You can\'t change the caller ID setting.</string>
- <!-- Notification title to tell the user that data service is blocked by access control. -->
+ <!-- Notification title to tell the user that data service is blocked by access control. [CHAR LIMIT=NOTIF_TITLE] -->
<string name="RestrictedOnDataTitle">No mobile data service</string>
- <!-- Notification title to tell the user that emergency calling is blocked by access control. -->
+ <!-- Notification title to tell the user that emergency calling is blocked by access control. [CHAR LIMIT=NOTIF_TITLE] -->
<string name="RestrictedOnEmergencyTitle">Emergency calling unavailable</string>
- <!-- Notification title to tell the user that normal service is blocked by access control. -->
+ <!-- Notification title to tell the user that normal service is blocked by access control. [CHAR LIMIT=NOTIF_TITLE] -->
<string name="RestrictedOnNormalTitle">No voice service</string>
- <!-- Notification title to tell the user that all emergency and normal voice services are blocked by access control. -->
+ <!-- Notification title to tell the user that all emergency and normal voice services are blocked by access control. [CHAR LIMIT=NOTIF_TITLE] -->
<string name="RestrictedOnAllVoiceTitle">No voice service or emergency calling</string>
- <!-- Notification content to tell the user that voice/data/emergency service is blocked by access control. -->
+ <!-- Notification content to tell the user that voice/data/emergency service is blocked by access control. [CHAR LIMIT=NOTIF_BODY] -->
<string name="RestrictedStateContent">Temporarily turned off by your carrier</string>
- <!-- Notification content to tell the user that voice/data/emergency service is blocked by access control when multiple SIMs are active. -->
+ <!-- Notification content to tell the user that voice/data/emergency service is blocked by access control when multiple SIMs are active. [CHAR LIMIT=NOTIF_BODY] -->
<string name="RestrictedStateContentMsimTemplate">Temporarily turned off by your carrier for SIM <xliff:g id="simNumber" example="1">%d</xliff:g></string>
<!-- Displayed to tell the user that they should switch their network preference. -->
@@ -321,18 +321,18 @@
<!-- Sync notifications --> <skip />
<!-- A notification is shown when there is a sync error. This is the text that will scroll through the notification bar (will be seen by the user as he uses another application). -->
<string name="contentServiceSync">Sync</string>
- <!-- A notification is shown when there is a sync error. This is the title of the notification. It will be seen in the pull-down notification tray. -->
+ <!-- A notification is shown when there is a sync error. This is the title of the notification. It will be seen in the pull-down notification tray. [CHAR LIMIT=NOTIF_TITLE] -->
<string name="contentServiceSyncNotificationTitle">Can\'t sync</string>
- <!-- A notification is shown when there is a sync error. This is the message of the notification. It describes the error, in this case is there were too many deletes. The argument is the type of content, for example Gmail or Calendar. It will be seen in the pull-down notification tray. -->
+ <!-- A notification is shown when there is a sync error. This is the message of the notification. It describes the error, in this case is there were too many deletes. The argument is the type of content, for example Gmail or Calendar. It will be seen in the pull-down notification tray. [CHAR LIMIT=NOTIF_BODY] -->
<string name="contentServiceTooManyDeletesNotificationDesc">Attempted to delete too many <xliff:g id="content_type">%s</xliff:g>.</string>
- <!-- If MMS discovers there isn't much space left on the device, it will show a toast with this message. -->
+ <!-- If MMS discovers there isn't much space left on the device, it will show a toast with this message. [CHAR LIMIT=TOAST] -->
<string name="low_memory" product="tablet">Tablet storage is full. Delete some files to free space.</string>
- <!-- If MMS discovers there isn't much space left on the device, it will show a toast with this message. -->
+ <!-- If MMS discovers there isn't much space left on the device, it will show a toast with this message. [CHAR LIMIT=TOAST] -->
<string name="low_memory" product="watch">Watch storage is full. Delete some files to free space.</string>
- <!-- If MMS discovers there isn't much space left on the device, it will show a toast with this message. -->
+ <!-- If MMS discovers there isn't much space left on the device, it will show a toast with this message. [CHAR LIMIT=TOAST] -->
<string name="low_memory" product="tv">TV storage is full. Delete some files to free space.</string>
- <!-- If MMS discovers there isn't much space left on the device, it will show a toast with this message. -->
+ <!-- If MMS discovers there isn't much space left on the device, it will show a toast with this message. [CHAR LIMIT=TOAST] -->
<string name="low_memory" product="default">Phone storage is full. Delete some files to free space.</string>
<!-- SSL CA cert notification --> <skip />
@@ -1082,10 +1082,9 @@
with the operation of the GPS or other location sources.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permlab_accessFineLocation">access precise location (GPS and
- network-based)</string>
+ <string name="permlab_accessFineLocation">access precise location only in the foreground</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
- <string name="permdesc_accessFineLocation">This app can get your location based on GPS or network location sources such as cell towers and Wi-Fi networks. These location services must be turned on and available on your phone for the app to be able to use them. This may increase battery consumption.</string>
+ <string name="permdesc_accessFineLocation">This app can get your exact location only when it is in the foreground. These location services must be turned on and available on your phone for the app to be able to use them. This may increase battery consumption.</string>
<!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_accessCoarseLocation">access approximate location
@@ -1097,7 +1096,12 @@
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permdesc_accessCoarseLocation" product="default">This app can get your location based on network sources such as cell towers and Wi-Fi networks. These location services must be turned on and available on your phone for the app to be able to use them.</string>
- <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permlab_accessBackgroundLocation">access precise location in the background</string>
+ <!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
+ <string name="permdesc_accessBackgroundLocation">This app can get your exact location any time it is in the background. These location services must be turned on and available on your phone for the app to be able to use them. This may increase battery consumption.</string>
+
+ <!-- Title of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permlab_modifyAudioSettings">change your audio settings</string>
<!-- Description of an application permission, listed so the user can choose whether they want to allow the application to do this. -->
<string name="permdesc_modifyAudioSettings">Allows the app to modify global audio settings such as volume and which speaker is used for output.</string>
diff --git a/core/tests/coretests/src/android/app/NotificationTest.java b/core/tests/coretests/src/android/app/NotificationTest.java
index 9ab7544618ab..e1cb911eaf72 100644
--- a/core/tests/coretests/src/android/app/NotificationTest.java
+++ b/core/tests/coretests/src/android/app/NotificationTest.java
@@ -16,7 +16,7 @@
package android.app;
-import static com.android.internal.util.NotificationColorUtil.satisfiesTextContrast;
+import static com.android.internal.util.ContrastColorUtil.satisfiesTextContrast;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
diff --git a/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java b/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
index 0906435db912..2801f32430ef 100644
--- a/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
+++ b/core/tests/coretests/src/android/app/servertransaction/TransactionParcelTests.java
@@ -47,6 +47,7 @@ import android.os.Parcel;
import android.os.ParcelFileDescriptor;
import android.os.Parcelable;
import android.os.PersistableBundle;
+import android.os.RemoteCallback;
import android.os.RemoteException;
import android.platform.test.annotations.Presubmit;
import android.support.test.filters.SmallTest;
@@ -609,7 +610,7 @@ public class TransactionParcelTests {
@Override
public void dumpHeap(boolean managed, boolean mallocInfo, boolean runGc, String path,
- ParcelFileDescriptor fd) {
+ ParcelFileDescriptor fd, RemoteCallback finishCallback) {
}
@Override
diff --git a/core/tests/coretests/src/android/provider/DocumentsProviderTest.java b/core/tests/coretests/src/android/provider/DocumentsProviderTest.java
index 09cbbff9077f..1465d0a98394 100644
--- a/core/tests/coretests/src/android/provider/DocumentsProviderTest.java
+++ b/core/tests/coretests/src/android/provider/DocumentsProviderTest.java
@@ -24,7 +24,6 @@ import android.support.test.filters.SmallTest;
import android.test.ProviderTestCase2;
import java.util.Arrays;
-import java.util.List;
/**
* Unit tests for {@link DocumentsProvider}.
@@ -84,7 +83,10 @@ public class DocumentsProviderTest extends ProviderTestCase2<TestDocumentsProvid
final Uri docUri = buildTreeDocumentUri(
TestDocumentsProvider.AUTHORITY, PARENT_DOCUMENT_ID, DOCUMENT_ID);
- assertNull(DocumentsContract.findDocumentPath(mResolver, docUri));
+ try {
+ DocumentsContract.findDocumentPath(mResolver, docUri);
+ fail("Expected a SecurityException to be throw");
+ } catch (SecurityException expected) { }
}
public void testFindDocumentPath_treeUri_erasesNonNullRootId() throws Exception {
diff --git a/core/tests/coretests/src/android/provider/SettingsBackupTest.java b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
index 156a2c0132f1..7428b1264348 100644
--- a/core/tests/coretests/src/android/provider/SettingsBackupTest.java
+++ b/core/tests/coretests/src/android/provider/SettingsBackupTest.java
@@ -340,7 +340,6 @@ public class SettingsBackupTest {
Settings.Global.NTP_SERVER,
Settings.Global.NTP_TIMEOUT,
Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
- Settings.Global.USER_ABSENT_RADIOS_OFF_FOR_SMALL_BATTERY_ENABLED,
Settings.Global.OVERLAY_DISPLAY_DEVICES,
Settings.Global.PAC_CHANGE_DELAY,
Settings.Global.PACKAGE_VERIFIER_DEFAULT_RESPONSE,
@@ -434,6 +433,8 @@ public class SettingsBackupTest {
Settings.Global.UNGAZE_SLEEP_ENABLED,
Settings.Global.UNLOCK_SOUND,
Settings.Global.USE_GOOGLE_MAIL,
+ Settings.Global.USER_ABSENT_RADIOS_OFF_FOR_SMALL_BATTERY_ENABLED,
+ Settings.Global.USER_ABSENT_TOUCH_OFF_FOR_SMALL_BATTERY_ENABLED,
Settings.Global.VT_IMS_ENABLED,
Settings.Global.WAIT_FOR_DEBUGGER,
Settings.Global.ENABLE_GPU_DEBUG_LAYERS,
@@ -442,6 +443,7 @@ public class SettingsBackupTest {
Settings.Global.ENABLE_GNSS_RAW_MEAS_FULL_TRACKING,
Settings.Global.INSTALL_CARRIER_APP_NOTIFICATION_PERSISTENT,
Settings.Global.INSTALL_CARRIER_APP_NOTIFICATION_SLEEP_MILLIS,
+ Settings.Global.USER_SWITCHER_ENABLED,
Settings.Global.NETWORK_ACCESS_TIMEOUT_MS,
Settings.Global.WARNING_TEMPERATURE,
Settings.Global.WEBVIEW_DATA_REDUCTION_PROXY_KEY,
diff --git a/core/tests/coretests/src/android/util/TimestampedValueTest.java b/core/tests/coretests/src/android/util/TimestampedValueTest.java
new file mode 100644
index 000000000000..7117c1b2d950
--- /dev/null
+++ b/core/tests/coretests/src/android/util/TimestampedValueTest.java
@@ -0,0 +1,119 @@
+/*
+ * 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 android.util;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.fail;
+
+import android.os.Parcel;
+import android.support.test.runner.AndroidJUnit4;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class TimestampedValueTest {
+
+ @Test
+ public void testEqualsAndHashcode() {
+ TimestampedValue<String> one1000one = new TimestampedValue<>(1000, "one");
+ assertEqualsAndHashCode(one1000one, one1000one);
+
+ TimestampedValue<String> one1000two = new TimestampedValue<>(1000, "one");
+ assertEqualsAndHashCode(one1000one, one1000two);
+
+ TimestampedValue<String> two1000 = new TimestampedValue<>(1000, "two");
+ assertNotEquals(one1000one, two1000);
+
+ TimestampedValue<String> one2000 = new TimestampedValue<>(2000, "one");
+ assertNotEquals(one1000one, one2000);
+ }
+
+ private static void assertEqualsAndHashCode(Object one, Object two) {
+ assertEquals(one, two);
+ assertEquals(one.hashCode(), two.hashCode());
+ }
+
+ @Test
+ public void testParceling() {
+ TimestampedValue<String> stringValue = new TimestampedValue<>(1000, "Hello");
+ Parcel parcel = Parcel.obtain();
+ try {
+ TimestampedValue.writeToParcel(parcel, stringValue);
+
+ parcel.setDataPosition(0);
+
+ TimestampedValue<String> stringValueCopy =
+ TimestampedValue.readFromParcel(parcel, null /* classLoader */, String.class);
+ assertEquals(stringValue, stringValueCopy);
+ } finally {
+ parcel.recycle();
+ }
+ }
+
+ @Test
+ public void testParceling_valueClassOk() {
+ TimestampedValue<String> stringValue = new TimestampedValue<>(1000, "Hello");
+ Parcel parcel = Parcel.obtain();
+ try {
+ TimestampedValue.writeToParcel(parcel, stringValue);
+
+ parcel.setDataPosition(0);
+
+ TimestampedValue<Object> stringValueCopy =
+ TimestampedValue.readFromParcel(parcel, null /* classLoader */, Object.class);
+ assertEquals(stringValue, stringValueCopy);
+ } finally {
+ parcel.recycle();
+ }
+ }
+
+ @Test
+ public void testParceling_valueClassIncompatible() {
+ TimestampedValue<String> stringValue = new TimestampedValue<>(1000, "Hello");
+ Parcel parcel = Parcel.obtain();
+ try {
+ TimestampedValue.writeToParcel(parcel, stringValue);
+
+ parcel.setDataPosition(0);
+
+ TimestampedValue.readFromParcel(parcel, null /* classLoader */, Double.class);
+ fail();
+ } catch (RuntimeException expected) {
+ } finally {
+ parcel.recycle();
+ }
+ }
+
+ @Test
+ public void testParceling_nullValue() {
+ TimestampedValue<String> nullValue = new TimestampedValue<>(1000, null);
+ Parcel parcel = Parcel.obtain();
+ try {
+ TimestampedValue.writeToParcel(parcel, nullValue);
+
+ parcel.setDataPosition(0);
+
+ TimestampedValue<Object> nullValueCopy =
+ TimestampedValue.readFromParcel(parcel, null /* classLoader */, String.class);
+ assertEquals(nullValue, nullValueCopy);
+ } finally {
+ parcel.recycle();
+ }
+ }
+}
diff --git a/data/etc/platform.xml b/data/etc/platform.xml
index df84a4cc2300..b3f05dc9fc98 100644
--- a/data/etc/platform.xml
+++ b/data/etc/platform.xml
@@ -168,6 +168,7 @@
<assign-permission name="android.permission.DUMP" uid="incidentd" />
<assign-permission name="android.permission.PACKAGE_USAGE_STATS" uid="incidentd" />
+ <assign-permission name="android.permission.INTERACT_ACROSS_USERS" uid="incidentd" />
<assign-permission name="android.permission.ACCESS_LOWPAN_STATE" uid="lowpan" />
<assign-permission name="android.permission.MANAGE_LOWPAN_INTERFACES" uid="lowpan" />
diff --git a/data/sounds/AllAudio.mk b/data/sounds/AllAudio.mk
index edfd3800600c..bf8067ccbd5c 100644
--- a/data/sounds/AllAudio.mk
+++ b/data/sounds/AllAudio.mk
@@ -232,4 +232,5 @@ PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/effects/ogg/WirelessChargingStarted.ogg:system/media/audio/ui/WirelessChargingStarted.ogg \
$(LOCAL_PATH)/effects/ogg/camera_click_48k.ogg:system/media/audio/ui/camera_click.ogg \
$(LOCAL_PATH)/effects/ogg/camera_focus.ogg:system/media/audio/ui/camera_focus.ogg \
-
+ $(LOCAL_PATH)/effects/ogg/ChargingStarted.ogg:system/media/audio/ui/ChargingStarted.ogg \
+ $(LOCAL_PATH)/effects/ogg/InCallNotification.ogg:system/media/audio/ui/InCallNotification.ogg \
diff --git a/data/sounds/AudioPackage10.mk b/data/sounds/AudioPackage10.mk
index c5222afcc2f7..72aa7fe1c38a 100644
--- a/data/sounds/AudioPackage10.mk
+++ b/data/sounds/AudioPackage10.mk
@@ -32,6 +32,8 @@ PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/effects/ogg/Lock_48k.ogg:system/media/audio/ui/Lock.ogg \
$(LOCAL_PATH)/effects/ogg/Unlock_48k.ogg:system/media/audio/ui/Unlock.ogg \
$(LOCAL_PATH)/effects/ogg/Trusted_48k.ogg:system/media/audio/ui/Trusted.ogg \
+ $(LOCAL_PATH)/effects/ogg/ChargingStarted.ogg:system/media/audio/ui/ChargingStarted.ogg \
+ $(LOCAL_PATH)/effects/ogg/InCallNotification.ogg:system/media/audio/ui/InCallNotification.ogg \
$(LOCAL_PATH)/effects/material/ogg/WirelessChargingStarted_48k.ogg:system/media/audio/ui/WirelessChargingStarted.ogg \
$(LOCAL_PATH)/notifications/ogg/Adara.ogg:system/media/audio/notifications/Adara.ogg \
$(LOCAL_PATH)/notifications/ogg/Alya.ogg:system/media/audio/notifications/Alya.ogg \
diff --git a/data/sounds/AudioPackage11.mk b/data/sounds/AudioPackage11.mk
index 43c83b99b11f..665ce521690e 100644
--- a/data/sounds/AudioPackage11.mk
+++ b/data/sounds/AudioPackage11.mk
@@ -32,6 +32,8 @@ PRODUCT_COPY_FILES += \
$(LOCAL_PATH)/effects/ogg/Lock_48k.ogg:system/media/audio/ui/Lock.ogg \
$(LOCAL_PATH)/effects/ogg/Unlock_48k.ogg:system/media/audio/ui/Unlock.ogg \
$(LOCAL_PATH)/effects/ogg/Trusted_48k.ogg:system/media/audio/ui/Trusted.ogg \
+ $(LOCAL_PATH)/effects/ogg/ChargingStarted.ogg:system/media/audio/ui/ChargingStarted.ogg \.
+ $(LOCAL_PATH)/effects/ogg/InCallNotification.ogg:system/media/audio/ui/InCallNotification.ogg \
$(LOCAL_PATH)/effects/material/ogg/WirelessChargingStarted_48k.ogg:system/media/audio/ui/WirelessChargingStarted.ogg \
$(LOCAL_PATH)/notifications/ogg/Adara.ogg:system/media/audio/notifications/Adara.ogg \
$(LOCAL_PATH)/notifications/ogg/Alya.ogg:system/media/audio/notifications/Alya.ogg \
diff --git a/data/sounds/AudioPackage12.mk b/data/sounds/AudioPackage12.mk
index cd4d35b4d3fc..44a8f9e34cd3 100644
--- a/data/sounds/AudioPackage12.mk
+++ b/data/sounds/AudioPackage12.mk
@@ -12,7 +12,7 @@ ALARM_FILES := Argon Carbon Helium Krypton Neon Oxygen Osmium Platinum
NOTIFICATION_FILES := Ariel Ceres Carme Elara Europa Iapetus Io Rhea Salacia Titan Tethys
RINGTONE_FILES := Callisto Dione Ganymede Luna Oberon Phobos Sedna Titania Triton Umbriel
EFFECT_FILES := Effect_Tick KeypressReturn KeypressInvalid KeypressDelete KeypressSpacebar KeypressStandard \
- camera_focus Dock Undock Lock Unlock Trusted
+ camera_focus Dock Undock Lock Unlock Trusted ChargingStarted InCallNotification
MATERIAL_EFFECT_FILES := camera_click VideoRecord LowBattery WirelessChargingStarted VideoStop
PRODUCT_COPY_FILES += $(foreach fn,$(ALARM_FILES),\
diff --git a/data/sounds/AudioPackage12_48.mk b/data/sounds/AudioPackage12_48.mk
index 80758f495035..09fab041505e 100644
--- a/data/sounds/AudioPackage12_48.mk
+++ b/data/sounds/AudioPackage12_48.mk
@@ -12,7 +12,7 @@ ALARM_FILES := Argon Carbon Helium Krypton Neon Oxygen Osmium Platinum
NOTIFICATION_FILES := Ariel Ceres Carme Elara Europa Iapetus Io Rhea Salacia Titan Tethys
RINGTONE_FILES := Callisto Dione Ganymede Luna Oberon Phobos Sedna Titania Triton Umbriel
EFFECT_FILES := Effect_Tick KeypressReturn KeypressInvalid KeypressDelete KeypressSpacebar KeypressStandard \
- Lock Unlock Trusted
+ Lock Unlock Trusted ChargingStarted InCallNotification
MATERIAL_EFFECT_FILES := camera_click VideoRecord LowBattery WirelessChargingStarted VideoStop
# Alarms not yet available in 48 kHz
diff --git a/data/sounds/AudioPackage13.mk b/data/sounds/AudioPackage13.mk
index d33a4aff22b8..de4ee047986d 100644
--- a/data/sounds/AudioPackage13.mk
+++ b/data/sounds/AudioPackage13.mk
@@ -13,7 +13,7 @@ NOTIFICATION_FILES := Ariel Ceres Carme Elara Europa Iapetus Io Rhea Salacia Tit
RINGTONE_FILES := Atria Callisto Dione Ganymede Luna Oberon Phobos Pyxis Sedna Titania Triton \
Umbriel
EFFECT_FILES := Effect_Tick KeypressReturn KeypressInvalid KeypressDelete KeypressSpacebar KeypressStandard \
- camera_focus Dock Undock Lock Unlock Trusted
+ camera_focus Dock Undock Lock Unlock Trusted ChargingStarted InCallNotification
MATERIAL_EFFECT_FILES := camera_click VideoRecord WirelessChargingStarted LowBattery VideoStop
PRODUCT_COPY_FILES += $(foreach fn,$(ALARM_FILES),\
diff --git a/data/sounds/AudioPackage13_48.mk b/data/sounds/AudioPackage13_48.mk
index 9c320ae8855e..889d58172290 100644
--- a/data/sounds/AudioPackage13_48.mk
+++ b/data/sounds/AudioPackage13_48.mk
@@ -13,7 +13,7 @@ NOTIFICATION_FILES := Ariel Ceres Carme Elara Europa Iapetus Io Rhea Salacia Tit
RINGTONE_FILES := Atria Callisto Dione Ganymede Luna Oberon Phobos Pyxis Sedna Titania Triton \
Umbriel
EFFECT_FILES := Effect_Tick KeypressReturn KeypressInvalid KeypressDelete KeypressSpacebar KeypressStandard \
- Lock Unlock Trusted
+ Lock Unlock Trusted ChargingStarted InCallNotification
MATERIAL_EFFECT_FILES := camera_click VideoRecord WirelessChargingStarted LowBattery VideoStop
PRODUCT_COPY_FILES += $(foreach fn,$(ALARM_FILES),\
diff --git a/data/sounds/effects/ChargingStarted.ogg b/data/sounds/effects/ChargingStarted.ogg
new file mode 100644
index 000000000000..f09e273ea5ac
--- /dev/null
+++ b/data/sounds/effects/ChargingStarted.ogg
Binary files differ
diff --git a/data/sounds/effects/ogg/ChargingStarted.ogg b/data/sounds/effects/ogg/ChargingStarted.ogg
new file mode 100644
index 000000000000..f09e273ea5ac
--- /dev/null
+++ b/data/sounds/effects/ogg/ChargingStarted.ogg
Binary files differ
diff --git a/data/sounds/effects/ogg/ChargingStarted_48k.ogg b/data/sounds/effects/ogg/ChargingStarted_48k.ogg
new file mode 100644
index 000000000000..f09e273ea5ac
--- /dev/null
+++ b/data/sounds/effects/ogg/ChargingStarted_48k.ogg
Binary files differ
diff --git a/data/sounds/effects/ogg/InCallNotification_48k.ogg b/data/sounds/effects/ogg/InCallNotification_48k.ogg
new file mode 100644
index 000000000000..4481ccb25614
--- /dev/null
+++ b/data/sounds/effects/ogg/InCallNotification_48k.ogg
Binary files differ
diff --git a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
index 34eac5620b13..8e9862c39af0 100644
--- a/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
+++ b/graphics/java/android/graphics/drawable/AnimatedVectorDrawable.java
@@ -168,7 +168,7 @@ import java.util.ArrayList;
* </p>
* Below is an example of a VectorDrawable defined in vectordrawable.xml. This VectorDrawable is
* referred to by its file name (not including file suffix) in the
- * <a href="AVDExample">AnimatedVectorDrawable XML example</a>.
+ * <a href="#AVDExample">AnimatedVectorDrawable XML example</a>.
* <pre>
* &lt;vector xmlns:android=&quot;http://schemas.android.com/apk/res/android&quot;
* android:height=&quot;64dp&quot;
diff --git a/keystore/java/android/security/KeyStore.java b/keystore/java/android/security/KeyStore.java
index fe05c13c999b..850230943458 100644
--- a/keystore/java/android/security/KeyStore.java
+++ b/keystore/java/android/security/KeyStore.java
@@ -190,22 +190,33 @@ public class KeyStore {
}
public byte[] get(String key, int uid) {
+ return get(key, uid, false);
+ }
+
+ public byte[] get(String key) {
+ return get(key, UID_SELF);
+ }
+
+ public byte[] get(String key, int uid, boolean suppressKeyNotFoundWarning) {
try {
key = key != null ? key : "";
return mBinder.get(key, uid);
} catch (RemoteException e) {
- Log.w(TAG, "Cannot connect to keystore", e);
+ Log.w(TAG, "Cannot connect to keystore", e);
return null;
} catch (android.os.ServiceSpecificException e) {
- Log.w(TAG, "KeyStore exception", e);
+ if (!suppressKeyNotFoundWarning || e.errorCode != KEY_NOT_FOUND) {
+ Log.w(TAG, "KeyStore exception", e);
+ }
return null;
}
}
- public byte[] get(String key) {
- return get(key, UID_SELF);
+ public byte[] get(String key, boolean suppressKeyNotFoundWarning) {
+ return get(key, UID_SELF, suppressKeyNotFoundWarning);
}
+
public boolean put(String key, byte[] value, int uid, int flags) {
return insert(key, value, uid, flags) == NO_ERROR;
}
diff --git a/libs/androidfw/ResourceTypes.cpp b/libs/androidfw/ResourceTypes.cpp
index b644cc365feb..861dc0f3879c 100644
--- a/libs/androidfw/ResourceTypes.cpp
+++ b/libs/androidfw/ResourceTypes.cpp
@@ -6824,8 +6824,16 @@ status_t ResTable::parsePackage(const ResTable_package* const pkg,
}
} else if (ctype == RES_TABLE_LIBRARY_TYPE) {
+
if (group->dynamicRefTable.entries().size() == 0) {
- status_t err = group->dynamicRefTable.load((const ResTable_lib_header*) chunk);
+ const ResTable_lib_header* lib = (const ResTable_lib_header*) chunk;
+ status_t err = validate_chunk(&lib->header, sizeof(*lib),
+ endPos, "ResTable_lib_header");
+ if (err != NO_ERROR) {
+ return (mError=err);
+ }
+
+ err = group->dynamicRefTable.load(lib);
if (err != NO_ERROR) {
return (mError=err);
}
diff --git a/media/java/android/media/MediaTimestamp.java b/media/java/android/media/MediaTimestamp.java
index dd43b4e001b0..e079a8e3a22b 100644
--- a/media/java/android/media/MediaTimestamp.java
+++ b/media/java/android/media/MediaTimestamp.java
@@ -51,8 +51,18 @@ public final class MediaTimestamp
/**
* Get the {@link java.lang.System#nanoTime system time} corresponding to the media time
* in nanoseconds.
+ * @deprecated use {@link #getAnchorSystemNanoTime} instead.
*/
+ @Deprecated
public long getAnchorSytemNanoTime() {
+ return getAnchorSystemNanoTime();
+ }
+
+ /**
+ * Get the {@link java.lang.System#nanoTime system time} corresponding to the media time
+ * in nanoseconds.
+ */
+ public long getAnchorSystemNanoTime() {
return nanoTime;
}
diff --git a/packages/CaptivePortalLogin/AndroidManifest.xml b/packages/CaptivePortalLogin/AndroidManifest.xml
index 72e37ed4756e..9ecaa03d6e53 100644
--- a/packages/CaptivePortalLogin/AndroidManifest.xml
+++ b/packages/CaptivePortalLogin/AndroidManifest.xml
@@ -22,8 +22,8 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.CONNECTIVITY_INTERNAL" />
- <uses-permission android:name="android.permission.NETWORK_SETTINGS" />
<uses-permission android:name="android.permission.NETWORK_BYPASS_PRIVATE_DNS" />
+ <uses-permission android:name="android.permission.NETWORK_SETTINGS" />
<application android:label="@string/app_name"
android:usesCleartextTraffic="true">
diff --git a/packages/SettingsLib/res/layout/preference_dropdown_material_settings.xml b/packages/SettingsLib/res/layout/preference_dropdown_material_settings.xml
deleted file mode 100644
index a0b8155c0818..000000000000
--- a/packages/SettingsLib/res/layout/preference_dropdown_material_settings.xml
+++ /dev/null
@@ -1,35 +0,0 @@
-<?xml version="1.0" encoding="utf-8"?>
-<!--
- Copyright (C) 2017 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.
- -->
-
-
-<!-- Based off frameworks/base/core/res/res/layout/preference_dropdown_material.xml
- except that icon space in this layout is always reserved -->
-<FrameLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- android:layout_width="match_parent"
- android:layout_height="wrap_content">
-
- <Spinner
- android:id="@+id/spinner"
- android:layout_width="0dp"
- android:layout_height="wrap_content"
- android:layout_marginStart="@dimen/preference_no_icon_padding_start"
- android:visibility="invisible" />
-
- <include layout="@layout/preference_material"/>
-
-</FrameLayout> \ No newline at end of file
diff --git a/packages/SettingsLib/res/values/styles_support_preference.xml b/packages/SettingsLib/res/values/styles_support_preference.xml
index 59de6c904e89..5d787f85e3ab 100644
--- a/packages/SettingsLib/res/values/styles_support_preference.xml
+++ b/packages/SettingsLib/res/values/styles_support_preference.xml
@@ -20,82 +20,14 @@
<dimen name="preference_no_icon_padding_start">72dp</dimen>
- <!-- Fragment style -->
- <style name="PreferenceFragmentStyle.SettingsBase" parent="@*android:style/PreferenceFragment.Material">
- <item name="allowDividerAfterLastItem">false</item>
- </style>
-
- <!-- Preferences -->
- <style name="Preference.SettingsBase" parent="@style/Preference.Material">
- <item name="allowDividerAbove">false</item>
- <item name="allowDividerBelow">true</item>
- <item name="singleLineTitle">false</item>
- <item name="iconSpaceReserved">true</item>
- </style>
-
- <!-- Preference category -->
- <style name="Preference.Category.SettingsBase" parent="@style/Preference.Category.Material">
- <item name="allowDividerAbove">true</item>
- <item name="allowDividerBelow">true</item>
- <item name="android:layout">@layout/preference_category_material_settings</item>
- </style>
-
- <!-- Preference screen -->
- <style name="Preference.Screen.SettingsBase" parent="@style/Preference.PreferenceScreen.Material">
- <item name="allowDividerAbove">false</item>
- <item name="allowDividerBelow">true</item>
- <item name="iconSpaceReserved">true</item>
- </style>
-
<!-- Footer Preferences -->
- <style name="Preference.FooterPreference.SettingsBase" parent="Preference.SettingsBase">
+ <style name="Preference.FooterPreference.SettingsBase" parent="@style/Preference.Material">
<item name="android:layout">@layout/preference_footer</item>
<item name="allowDividerAbove">true</item>
</style>
- <!-- Dropdown Preferences -->
- <style name="Preference.DropdownPreference.SettingsBase" parent="Preference.SettingsBase">
- <item name="android:layout">@layout/preference_dropdown_material_settings</item>
- </style>
-
- <!-- Switch Preferences -->
- <style name="Preference.SwitchPreference.SettingsBase" parent="@style/Preference.SwitchPreference.Material">
- <item name="allowDividerAbove">false</item>
- <item name="allowDividerBelow">true</item>
- <item name="iconSpaceReserved">true</item>
- <item name="singleLineTitle">false</item>
- </style>
-
- <!-- CheckBox Preferences -->
- <style name="Preference.CheckBoxPreference.SettingsBase" parent="@style/Preference.CheckBoxPreference.Material">
- <item name="allowDividerAbove">false</item>
- <item name="allowDividerBelow">true</item>
- <item name="iconSpaceReserved">true</item>
- <item name="singleLineTitle">false</item>
- </style>
-
- <!-- EditText Preferences -->
- <style name="Preference.EditTextPreference.SettingsBase"
- parent="@style/Preference.DialogPreference.EditTextPreference.Material">
- <item name="allowDividerAbove">false</item>
- <item name="allowDividerBelow">true</item>
- <item name="iconSpaceReserved">true</item>
- <item name="singleLineTitle">false</item>
- </style>
-
<style name="PreferenceThemeOverlay.SettingsBase" parent="@style/PreferenceThemeOverlay.v14.Material">
- <!-- Parent path frameworks/support/v14/preference/res/values/themes.xml -->
- <item name="android:scrollbars">vertical</item>
- <item name="preferenceFragmentStyle">@style/PreferenceFragmentStyle.SettingsBase</item>
- <item name="preferenceCategoryStyle">@style/Preference.Category.SettingsBase</item>
- <item name="preferenceScreenStyle">@style/Preference.Screen.SettingsBase</item>
- <item name="preferenceStyle">@style/Preference.SettingsBase</item>
- <item name="dialogPreferenceStyle">@style/Preference.SettingsBase</item>
- <item name="editTextPreferenceStyle">@style/Preference.EditTextPreference.SettingsBase</item>
<item name="footerPreferenceStyle">@style/Preference.FooterPreference.SettingsBase</item>
- <item name="switchPreferenceStyle">@style/Preference.SwitchPreference.SettingsBase</item>
- <item name="checkBoxPreferenceStyle">@style/Preference.CheckBoxPreference.SettingsBase</item>
- <item name="dropdownPreferenceStyle">@style/Preference.DropdownPreference.SettingsBase</item>
</style>
-</resources> \ No newline at end of file
+</resources>
diff --git a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
index a3c1fc6ff265..21bac88e802b 100644
--- a/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
+++ b/packages/SettingsLib/src/com/android/settingslib/applications/ApplicationsState.java
@@ -22,9 +22,6 @@ import android.app.AppGlobals;
import android.app.Application;
import android.app.usage.StorageStats;
import android.app.usage.StorageStatsManager;
-import androidx.lifecycle.Lifecycle;
-import androidx.lifecycle.LifecycleObserver;
-import androidx.lifecycle.OnLifecycleEvent;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -49,7 +46,6 @@ import android.os.RemoteException;
import android.os.SystemClock;
import android.os.UserHandle;
import android.os.UserManager;
-import androidx.annotation.VisibleForTesting;
import android.text.format.Formatter;
import android.util.IconDrawableFactory;
import android.util.Log;
@@ -62,6 +58,7 @@ import java.io.File;
import java.io.IOException;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
+import java.lang.ref.WeakReference;
import java.text.Collator;
import java.text.Normalizer;
import java.text.Normalizer.Form;
@@ -74,6 +71,11 @@ import java.util.Objects;
import java.util.UUID;
import java.util.regex.Pattern;
+import androidx.annotation.VisibleForTesting;
+import androidx.lifecycle.Lifecycle;
+import androidx.lifecycle.LifecycleObserver;
+import androidx.lifecycle.OnLifecycleEvent;
+
/**
* Keeps track of information about all installed applications, lazy-loading
* as needed.
@@ -132,7 +134,7 @@ public class ApplicationsState {
boolean mSessionsChanged;
// Temporary for dispatching session callbacks. Only touched by main thread.
- final ArrayList<Session> mActiveSessions = new ArrayList<Session>();
+ final ArrayList<WeakReference<Session>> mActiveSessions = new ArrayList<>();
final HandlerThread mThread;
final BackgroundHandler mBackgroundHandler;
@@ -618,7 +620,7 @@ public class ApplicationsState {
for (int i=0; i<mSessions.size(); i++) {
Session s = mSessions.get(i);
if (s.mResumed) {
- mActiveSessions.add(s);
+ mActiveSessions.add(new WeakReference<>(s));
}
}
}
@@ -830,46 +832,70 @@ public class ApplicationsState {
rebuildActiveSessions();
switch (msg.what) {
case MSG_REBUILD_COMPLETE: {
- Session s = (Session)msg.obj;
- if (mActiveSessions.contains(s)) {
- s.mCallbacks.onRebuildComplete(s.mLastAppList);
+ Session s = (Session) msg.obj;
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null && session == s) {
+ s.mCallbacks.onRebuildComplete(s.mLastAppList);
+ }
}
} break;
case MSG_PACKAGE_LIST_CHANGED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onPackageListChanged();
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onPackageListChanged();
+ }
}
} break;
case MSG_PACKAGE_ICON_CHANGED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onPackageIconChanged();
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onPackageIconChanged();
+ }
}
} break;
case MSG_PACKAGE_SIZE_CHANGED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onPackageSizeChanged(
- (String)msg.obj);
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onPackageSizeChanged(
+ (String) msg.obj);
+ }
}
} break;
case MSG_ALL_SIZES_COMPUTED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onAllSizesComputed();
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onAllSizesComputed();
+ }
}
} break;
case MSG_RUNNING_STATE_CHANGED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onRunningStateChanged(
- msg.arg1 != 0);
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onRunningStateChanged(
+ msg.arg1 != 0);
+ }
}
} break;
case MSG_LAUNCHER_INFO_CHANGED: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onLauncherInfoChanged();
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onLauncherInfoChanged();
+ }
}
} break;
case MSG_LOAD_ENTRIES_COMPLETE: {
- for (int i=0; i<mActiveSessions.size(); i++) {
- mActiveSessions.get(i).mCallbacks.onLoadEntriesCompleted();
+ for (WeakReference<Session> sessionRef : mActiveSessions) {
+ final Session session = sessionRef.get();
+ if (session != null) {
+ session.mCallbacks.onLoadEntriesCompleted();
+ }
}
} break;
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
index 1faca0cb540a..b80badb15509 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/CachedBluetoothDevice.java
@@ -1205,4 +1205,12 @@ public class CachedBluetoothDevice implements Comparable<CachedBluetoothDevice>
return mProfileManager.getHeadsetProfile().getConnectionStatus(mDevice) ==
BluetoothProfile.STATE_CONNECTED;
}
+
+ /**
+ * @return {@code true} if {@code cachedBluetoothDevice} is Hearing Aid device
+ */
+ public boolean isConnectedHearingAidDevice() {
+ return mProfileManager.getHearingAidProfile().getConnectionStatus(mDevice) ==
+ BluetoothProfile.STATE_CONNECTED;
+ }
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothManager.java b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothManager.java
index 373247162563..1c50953bac12 100644
--- a/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothManager.java
+++ b/packages/SettingsLib/src/com/android/settingslib/bluetooth/LocalBluetoothManager.java
@@ -19,6 +19,8 @@ package com.android.settingslib.bluetooth;
import android.content.Context;
import android.util.Log;
+import java.lang.ref.WeakReference;
+
/**
* LocalBluetoothManager provides a simplified interface on top of a subset of
* the Bluetooth API. Note that {@link #getInstance} will return null
@@ -34,7 +36,7 @@ public class LocalBluetoothManager {
private final Context mContext;
/** If a BT-related activity is in the foreground, this will be it. */
- private Context mForegroundActivity;
+ private WeakReference<Context> mForegroundActivity;
private final LocalBluetoothAdapter mLocalAdapter;
@@ -85,17 +87,19 @@ public class LocalBluetoothManager {
}
public Context getForegroundActivity() {
- return mForegroundActivity;
+ return mForegroundActivity == null
+ ? null
+ : mForegroundActivity.get();
}
public boolean isForegroundActivity() {
- return mForegroundActivity != null;
+ return mForegroundActivity != null && mForegroundActivity.get() != null;
}
public synchronized void setForegroundActivity(Context context) {
if (context != null) {
Log.d(TAG, "setting foreground activity to non-null context");
- mForegroundActivity = context;
+ mForegroundActivity = new WeakReference<>(context);
} else {
if (mForegroundActivity != null) {
Log.d(TAG, "setting foreground activity to null");
diff --git a/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java b/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java
index 988060eac64d..e5d97c9b4a7b 100644
--- a/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java
+++ b/packages/SettingsLib/src/com/android/settingslib/dream/DreamBackend.java
@@ -36,12 +36,12 @@ import android.util.AttributeSet;
import android.util.Log;
import android.util.Xml;
-import java.lang.annotation.Retention;
-import java.lang.annotation.RetentionPolicy;
import org.xmlpull.v1.XmlPullParser;
import org.xmlpull.v1.XmlPullParserException;
import java.io.IOException;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
@@ -97,15 +97,15 @@ public class DreamBackend {
}
public DreamBackend(Context context) {
- mContext = context;
+ mContext = context.getApplicationContext();
mDreamManager = IDreamManager.Stub.asInterface(
ServiceManager.getService(DreamService.DREAM_SERVICE));
mComparator = new DreamInfoComparator(getDefaultDream());
- mDreamsEnabledByDefault = context.getResources()
+ mDreamsEnabledByDefault = mContext.getResources()
.getBoolean(com.android.internal.R.bool.config_dreamsEnabledByDefault);
- mDreamsActivatedOnSleepByDefault = context.getResources()
+ mDreamsActivatedOnSleepByDefault = mContext.getResources()
.getBoolean(com.android.internal.R.bool.config_dreamsActivatedOnSleepByDefault);
- mDreamsActivatedOnDockByDefault = context.getResources()
+ mDreamsActivatedOnDockByDefault = mContext.getResources()
.getBoolean(com.android.internal.R.bool.config_dreamsActivatedOnDockByDefault);
}
diff --git a/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java b/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
index e609a40d1712..17c2b02ed576 100644
--- a/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
+++ b/packages/SettingsLib/src/com/android/settingslib/graph/BatteryMeterDrawableBase.java
@@ -210,6 +210,10 @@ public class BatteryMeterDrawableBase extends Drawable {
postInvalidate();
}
+ public boolean getPowerSave() {
+ return mPowerSaveEnabled;
+ }
+
protected void setPowerSaveAsColorError(boolean asError) {
mPowerSaveAsColorError = asError;
}
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/SettingsLibRobolectricTestRunner.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/SettingsLibRobolectricTestRunner.java
index 8778ae949e20..914d1828981e 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/SettingsLibRobolectricTestRunner.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/SettingsLibRobolectricTestRunner.java
@@ -54,7 +54,7 @@ public class SettingsLibRobolectricTestRunner extends RobolectricTestRunner {
final List<ResourcePath> paths = super.getIncludedResourcePaths();
paths.add(resourcePath("file:frameworks/base/packages/SettingsLib/res"));
paths.add(resourcePath("file:frameworks/base/core/res/res"));
- paths.add(resourcePath("file:frameworks/support/v7/appcompat/res"));
+ paths.add(resourcePath("file:frameworks/support/appcompat/res"));
return paths;
}
};
diff --git a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
index 927a94f6b017..9bc47eb210c1 100644
--- a/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
+++ b/packages/SettingsLib/tests/robotests/src/com/android/settingslib/bluetooth/CachedBluetoothDeviceTest.java
@@ -572,4 +572,22 @@ public class CachedBluetoothDeviceTest {
assertThat(mCachedDevice.isHfpDevice()).isFalse();
}
+
+ @Test
+ public void isConnectedHearingAidDevice_connected_returnTrue() {
+ when(mProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
+ when(mHearingAidProfile.getConnectionStatus(mDevice)).
+ thenReturn(BluetoothProfile.STATE_CONNECTED);
+
+ assertThat(mCachedDevice.isConnectedHearingAidDevice()).isTrue();
+ }
+
+ @Test
+ public void isConnectedHearingAidDevice_disconnected_returnFalse() {
+ when(mProfileManager.getHearingAidProfile()).thenReturn(mHearingAidProfile);
+ when(mHearingAidProfile.getConnectionStatus(mDevice)).
+ thenReturn(BluetoothProfile.STATE_DISCONNECTED);
+
+ assertThat(mCachedDevice.isConnectedHearingAidDevice()).isFalse();
+ }
}
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
index d5efcb549e64..77eb6c472e4a 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProtoDumpUtil.java
@@ -963,11 +963,14 @@ class SettingsProtoDumpUtil {
GlobalSettingsProto.Ntp.TIMEOUT_MS);
p.end(ntpToken);
- final long uaroToken = p.start(GlobalSettingsProto.USER_ABSENT_RADIOS_OFF);
+ final long uasbToken = p.start(GlobalSettingsProto.USER_ABSENT_SMALL_BATTERY);
dumpSetting(s, p,
Settings.Global.USER_ABSENT_RADIOS_OFF_FOR_SMALL_BATTERY_ENABLED,
- GlobalSettingsProto.UserAbsentRadiosOff.ENABLED_FOR_SMALL_BATTERY);
- p.end(uaroToken);
+ GlobalSettingsProto.UserAbsentSmallBattery.RADIOS_OFF_ENABLED);
+ dumpSetting(s, p,
+ Settings.Global.USER_ABSENT_TOUCH_OFF_FOR_SMALL_BATTERY_ENABLED,
+ GlobalSettingsProto.UserAbsentSmallBattery.TOUCH_OFF_ENABLED);
+ p.end(uasbToken);
dumpSetting(s, p,
Settings.Global.OTA_DISABLE_AUTOMATIC_UPDATE,
diff --git a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
index 960d30524b95..375fef8ac3f9 100644
--- a/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
+++ b/packages/SettingsProvider/src/com/android/providers/settings/SettingsProvider.java
@@ -3726,17 +3726,7 @@ public class SettingsProvider extends ContentProvider {
}
if (currentVersion == 164) {
- // Version 164: show zen upgrade notification
- final SettingsState settings = getGlobalSettingsLocked();
- final Setting currentSetting = settings.getSettingLocked(
- Global.SHOW_ZEN_UPGRADE_NOTIFICATION);
- if (!currentSetting.isNull()
- && TextUtils.equals("0", currentSetting.getValue())) {
- settings.insertSettingLocked(
- Global.SHOW_ZEN_UPGRADE_NOTIFICATION, "1",
- null, true, SettingsState.SYSTEM_PACKAGE_NAME);
- }
-
+ // Version 164: REMOVED: show zen upgrade notification
currentVersion = 165;
}
diff --git a/packages/SystemUI/res/drawable-nodpi/icon.xml b/packages/SystemUI/res/drawable-nodpi/icon.xml
index abafb689f169..48094c48aa68 100644
--- a/packages/SystemUI/res/drawable-nodpi/icon.xml
+++ b/packages/SystemUI/res/drawable-nodpi/icon.xml
@@ -1,5 +1,5 @@
<!--
-Copyright (C) 2017 The Android Open Source Project
+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.
@@ -13,28 +13,7 @@ Copyright (C) 2017 The Android Open Source Project
See the License for the specific language governing permissions and
limitations under the License.
-->
-<vector xmlns:android="http://schemas.android.com/apk/res/android"
- android:width="48dp"
- android:height="48dp"
- android:viewportWidth="48.0"
- android:viewportHeight="48.0">
- <path
- android:pathData="M25.0,25.0m-20.5,0.0a20.5,20.5,0,1,1,41.0,0.0a20.5,20.5,0,1,1,-41.0,0.0"
- android:fillAlpha="0.066"
- android:fillColor="#000000"/>
- <path
- android:pathData="M24.0,24.0m-20.0,0.0a20.0,20.0,0,1,1,40.0,0.0a20.0,20.0,0,1,1,-40.0,0.0"
- android:fillColor="#FFC107"/>
- <path
- android:pathData="M44,24.2010101 L33.9004889,14.101499 L14.101499,33.9004889 L24.2010101,44 C29.2525804,43.9497929 34.2887564,41.9975027 38.1431296,38.1431296 C41.9975027,34.2887564 43.9497929,29.2525804 44,24.2010101 Z"
- android:fillColor="#FE9F00"/>
- <path
- android:pathData="M24.0,24.0m-14.0,0.0a14.0,14.0,0,1,1,28.0,0.0a14.0,14.0,0,1,1,-28.0,0.0"
- android:fillColor="#FED44F"/>
- <path
- android:pathData="M37.7829445,26.469236 L29.6578482,18.3441397 L18.3441397,29.6578482 L26.469236,37.7829445 C29.1911841,37.2979273 31.7972024,36.0037754 33.9004889,33.9004889 C36.0037754,31.7972024 37.2979273,29.1911841 37.7829445,26.469236 Z"
- android:fillColor="#FFC107"/>
- <path
- android:pathData="M24.0,24.0m-8.0,0.0a8.0,8.0,0,1,1,16.0,0.0a8.0,8.0,0,1,1,-16.0,0.0"
- android:fillColor="#FFFFFF"/>
-</vector>
+<adaptive-icon xmlns:android="http://schemas.android.com/apk/res/android">
+ <background android:drawable="@drawable/icon_bg"/>
+ <foreground android:drawable="@drawable/p"/>
+</adaptive-icon>
diff --git a/packages/SystemUI/res/drawable-nodpi/icon_bg.xml b/packages/SystemUI/res/drawable-nodpi/icon_bg.xml
new file mode 100644
index 000000000000..31ecf7edfb11
--- /dev/null
+++ b/packages/SystemUI/res/drawable-nodpi/icon_bg.xml
@@ -0,0 +1,18 @@
+<!--
+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.
+-->
+<color xmlns:android="http://schemas.android.com/apk/res/android"
+ android:color="#C5E1A5" />
+
diff --git a/packages/SystemUI/res/drawable-nodpi/p.xml b/packages/SystemUI/res/drawable-nodpi/p.xml
new file mode 100644
index 000000000000..596b7824cdb7
--- /dev/null
+++ b/packages/SystemUI/res/drawable-nodpi/p.xml
@@ -0,0 +1,33 @@
+<!--
+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.
+-->
+<vector xmlns:android="http://schemas.android.com/apk/res/android"
+ android:width="108dp"
+ android:height="108dp"
+ android:viewportWidth="108"
+ android:viewportHeight="108">
+ <path
+ android:pathData="M49,65L54,65C60.075,65 65,60.075 65,54C65,47.925 60.075,43 54,43C47.925,43 43,47.925 43,54L43,108"
+ android:strokeWidth="16"
+ android:fillColor="#00000000"
+ android:strokeColor="#7CB342"
+ android:fillType="evenOdd"/>
+ <path
+ android:pathData="M51,65L54,65C60.075,65 65,60.075 65,54C65,47.925 60.075,43 54,43C47.925,43 43,47.925 43,54L43,108"
+ android:strokeWidth="8"
+ android:fillColor="#00000000"
+ android:strokeColor="#FFFFFF"
+ android:fillType="evenOdd"/>
+</vector>
diff --git a/packages/SystemUI/res/drawable/ic_qs_auto_rotate.xml b/packages/SystemUI/res/drawable/ic_qs_auto_rotate.xml
index 9c24c2ce9f83..47e1059fab44 100644
--- a/packages/SystemUI/res/drawable/ic_qs_auto_rotate.xml
+++ b/packages/SystemUI/res/drawable/ic_qs_auto_rotate.xml
@@ -22,5 +22,5 @@
android:viewportHeight="24.0">
<path
android:fillColor="#FFFFFFFF"
- android:pathData="M12.72,23H11C5.49,23 1,18.51 1,13h2c0,3.78 2.63,6.95 6.15,7.79L8.13,19L9.87,18L12.72,23zM13,1h-1.72l2.85,5L15.87,5l-1.02,-1.79C18.37,4.05 21,7.22 21,11h2C23,5.49 18.51,1 13,1zM10.23,6L18,13.76L13.77,18L6,10.24L10.23,6C10.23,6 10.23,6 10.23,6M10.23,4C9.72,4 9.21,4.2 8.82,4.59L4.59,8.82c-0.78,0.78 -0.78,2.04 0,2.82l7.77,7.77c0.39,0.39 0.9,0.59 1.41,0.59c0.51,0 1.02,-0.2 1.41,-0.59l4.24,-4.24c0.78,-0.78 0.78,-2.04 0,-2.82l-7.77,-7.77C11.26,4.2 10.75,4 10.23,4L10.23,4z"/>
+ android:pathData="M7.4,10.94H2.45V5.99l2,0.01v1.53l4.61,-4.61c0.64,-0.64 1.67,-0.66 2.29,-0.04l8.18,8.18h-2.83l-6.48,-6.48L5.86,8.95H7.4V10.94zM16.6,13.06l0.01,2h1.53l-4.36,4.36l-6.48,-6.48H4.46l8.19,8.19c0.62,0.62 1.65,0.6 2.29,-0.04l4.61,-4.61l0.01,0.01v1.53h1.99v-4.95H16.6z"/>
</vector>
diff --git a/packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml
index 2cd788303279..3304c19b1ed8 100644
--- a/packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml
+++ b/packages/SystemUI/res/drawable/ic_sysbar_rotate_button.xml
@@ -17,16 +17,16 @@
<animated-vector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:aapt="http://schemas.android.com/aapt">
<aapt:attr name="android:drawable">
<vector android:name="root"
- android:width="21dp"
- android:height="21dp"
- android:viewportWidth="24.0"
- android:viewportHeight="24.0">
+ android:width="28dp"
+ android:height="28dp"
+ android:viewportWidth="28.0"
+ android:viewportHeight="28.0">
<!-- Use scaleX to flip icon so arrows always point in the direction of motion -->
- <group android:name="icon" android:pivotX="12" android:pivotY="12"
+ <group android:name="icon" android:pivotX="14" android:pivotY="14"
android:scaleX="?attr/rotateButtonScaleX">
<!-- Tint color to be set directly -->
<path android:fillColor="#FFFFFFFF"
- android:pathData="M19,12c0,1.72 -0.63,3.3 -1.66,4.52l-1.44,-1.44C16.58,14.23 17,13.17 17,12c0,-2.76 -2.24,-5 -5,-5c-0.06,0 -0.11,0.01 -0.17,0.01l1.08,1.08L11.5,9.5L8,6l3.5,-3.5l1.41,1.42l-1.09,1.09C11.88,5.01 11.94,5 12,5C15.87,5 19,8.13 19,12zM12.5,14.51l-1.41,1.41l1.06,1.06C12.1,16.99 12.05,17 12,17c-2.76,0 -5,-2.24 -5,-5c0,-1.17 0.42,-2.23 1.09,-3.08L6.66,7.48C5.62,8.7 5,10.28 5,12c0,3.87 3.13,7 7,7c0.06,0 0.13,-0.01 0.19,-0.01v0l-1.1,1.1l1.41,1.41L16,18L12.5,14.51z"/>
+ android:pathData="M12.02,10.83L9.25,8.06l2.77,-2.77l1.12,1.12l-0.85,0.86h5.16c0.72,0 1.31,0.56 1.31,1.26v9.16l-1.58,-1.58V8.85h-4.89l0.86,0.86L12.02,10.83zM15.98,17.17l-1.12,1.12l0.85,0.86h-4.88v-7.26L9.25,10.3v9.17c0,0.7 0.59,1.26 1.31,1.26h5.16v0.01l-0.85,0.85l1.12,1.12l2.77,-2.77L15.98,17.17z"/>
</group>
</vector>
</aapt:attr>
diff --git a/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml b/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml
index 2e1487c21024..37e2b537f90c 100644
--- a/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml
+++ b/packages/SystemUI/res/layout/car_fullscreen_user_switcher.xml
@@ -39,7 +39,7 @@
android:layout_height="match_parent"
android:layout_marginTop="@dimen/car_user_switcher_margin_top"
app:verticallyCenterListContent="true"
- app:dayNightStyle="force_night"
+ app:dayNightStyle="always_light"
app:showPagedListViewDivider="false"
app:gutter="both"
app:itemSpacing="@dimen/car_user_switcher_vertical_spacing_between_users"/>
diff --git a/packages/SystemUI/res/layout/car_qs_panel.xml b/packages/SystemUI/res/layout/car_qs_panel.xml
index 0e8db77db588..c43afc980bbf 100644
--- a/packages/SystemUI/res/layout/car_qs_panel.xml
+++ b/packages/SystemUI/res/layout/car_qs_panel.xml
@@ -39,7 +39,7 @@
android:id="@+id/user_grid"
android:layout_width="match_parent"
android:layout_height="match_parent"
- app:dayNightStyle="force_night"
+ app:dayNightStyle="always_light"
app:showPagedListViewDivider="false"
app:gutter="both"
app:itemSpacing="@dimen/car_user_switcher_vertical_spacing_between_users"/>
diff --git a/packages/SystemUI/res/values-land/dimens.xml b/packages/SystemUI/res/values-land/dimens.xml
index b81d363eab81..c59dbdc32158 100644
--- a/packages/SystemUI/res/values-land/dimens.xml
+++ b/packages/SystemUI/res/values-land/dimens.xml
@@ -22,7 +22,7 @@
<dimen name="docked_divider_handle_width">2dp</dimen>
<dimen name="docked_divider_handle_height">16dp</dimen>
- <dimen name="brightness_mirror_height">96dp</dimen>
+ <dimen name="brightness_mirror_height">40dp</dimen>
<!-- Width for the spacer, used between QS tiles. -->
<dimen name="qs_quick_tile_space_width">38dp</dimen>
diff --git a/packages/SystemUI/res/values/dimens.xml b/packages/SystemUI/res/values/dimens.xml
index 9a3bdf271dc0..3b58b7249b05 100644
--- a/packages/SystemUI/res/values/dimens.xml
+++ b/packages/SystemUI/res/values/dimens.xml
@@ -204,7 +204,7 @@
<dimen name="status_bar_padding_end">6dp</dimen>
<!-- the radius of the overflow dot in the status bar -->
- <dimen name="overflow_dot_radius">1dp</dimen>
+ <dimen name="overflow_dot_radius">2dp</dimen>
<!-- the padding between dots in the icon overflow -->
<dimen name="overflow_icon_dot_padding">3dp</dimen>
@@ -287,7 +287,7 @@
<dimen name="notification_panel_width">@dimen/match_parent</dimen>
- <dimen name="brightness_mirror_height">108dp</dimen>
+ <dimen name="brightness_mirror_height">48dp</dimen>
<!-- The width of the panel that holds the quick settings. -->
<dimen name="qs_panel_width">@dimen/notification_panel_width</dimen>
@@ -1012,4 +1012,7 @@
<!-- How much into a DisplayCutout's bounds we can go, on each side -->
<dimen name="display_cutout_margin_consumption">0px</dimen>
+ <!-- How much we expand the touchable region of the status bar below the notch to catch touches
+ that just start below the notch. -->
+ <dimen name="display_cutout_touchable_region_size">12dp</dimen>
</resources>
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/RecentsTaskLoadPlan.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/RecentsTaskLoadPlan.java
index a04a6a3fe0c5..f69e91145dfc 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/RecentsTaskLoadPlan.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/RecentsTaskLoadPlan.java
@@ -19,6 +19,7 @@ package com.android.systemui.shared.recents.model;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.KeyguardManager;
import android.content.ComponentName;
import android.content.Context;
@@ -92,7 +93,7 @@ public class RecentsTaskLoadPlan {
ArrayList<Task> allTasks = new ArrayList<>();
if (mRawTasks == null) {
mRawTasks = ActivityManagerWrapper.getInstance().getRecentTasks(
- ActivityManager.getMaxRecentTasksStatic(), currentUserId);
+ ActivityTaskManager.getMaxRecentTasksStatic(), currentUserId);
// Since the raw tasks are given in most-recent to least-recent order, we need to reverse it
Collections.reverse(mRawTasks);
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/RecentsTaskLoader.java b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/RecentsTaskLoader.java
index 1309a6065c8a..ab2e277ecfd6 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/RecentsTaskLoader.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/recents/model/RecentsTaskLoader.java
@@ -17,6 +17,7 @@
package com.android.systemui.shared.recents.model;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.content.ComponentCallbacks2;
import android.content.ComponentName;
import android.content.Context;
@@ -98,7 +99,7 @@ public class RecentsTaskLoader {
mSvelteLevel = svelteLevel;
// Initialize the proxy, cache and loaders
- int numRecentTasks = ActivityManager.getMaxRecentTasksStatic();
+ int numRecentTasks = ActivityTaskManager.getMaxRecentTasksStatic();
mHighResThumbnailLoader = new HighResThumbnailLoader(ActivityManagerWrapper.getInstance(),
Looper.getMainLooper(), ActivityManager.isLowRamDeviceStatic());
mLoadQueue = new TaskResourceLoadQueue();
@@ -221,14 +222,14 @@ public class RecentsTaskLoader {
// We are leaving recents, so trim the data a bit
mIconCache.trimToSize(Math.max(1, mMaxIconCacheSize / 2));
mActivityInfoCache.trimToSize(Math.max(1,
- ActivityManager.getMaxRecentTasksStatic() / 2));
+ ActivityTaskManager.getMaxRecentTasksStatic() / 2));
break;
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_LOW:
case ComponentCallbacks2.TRIM_MEMORY_MODERATE:
// We are going to be low on memory
mIconCache.trimToSize(Math.max(1, mMaxIconCacheSize / 4));
mActivityInfoCache.trimToSize(Math.max(1,
- ActivityManager.getMaxRecentTasksStatic() / 4));
+ ActivityTaskManager.getMaxRecentTasksStatic() / 4));
break;
case ComponentCallbacks2.TRIM_MEMORY_RUNNING_CRITICAL:
case ComponentCallbacks2.TRIM_MEMORY_COMPLETE:
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java
index 63a4cd497bc1..dce72b440f58 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityManagerWrapper.java
@@ -30,6 +30,7 @@ import android.annotation.NonNull;
import android.app.ActivityManager;
import android.app.ActivityManager.RecentTaskInfo;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.app.AppGlobals;
import android.app.IAssistDataReceiver;
import android.app.WindowConfiguration.ActivityType;
@@ -113,7 +114,7 @@ public class ActivityManagerWrapper {
// Note: The set of running tasks from the system is ordered by recency
try {
List<ActivityManager.RunningTaskInfo> tasks =
- ActivityManager.getService().getFilteredTasks(1, ignoreActivityType,
+ ActivityTaskManager.getService().getFilteredTasks(1, ignoreActivityType,
WINDOWING_MODE_PINNED /* ignoreWindowingMode */);
if (tasks.isEmpty()) {
return null;
@@ -129,7 +130,7 @@ public class ActivityManagerWrapper {
*/
public List<RecentTaskInfo> getRecentTasks(int numTasks, int userId) {
try {
- return ActivityManager.getService().getRecentTasks(numTasks,
+ return ActivityTaskManager.getService().getRecentTasks(numTasks,
RECENT_IGNORE_UNAVAILABLE, userId).getList();
} catch (RemoteException e) {
Log.e(TAG, "Failed to get recent tasks", e);
@@ -143,7 +144,7 @@ public class ActivityManagerWrapper {
public @NonNull ThumbnailData getTaskThumbnail(int taskId, boolean reducedResolution) {
ActivityManager.TaskSnapshot snapshot = null;
try {
- snapshot = ActivityManager.getService().getTaskSnapshot(taskId, reducedResolution);
+ snapshot = ActivityTaskManager.getService().getTaskSnapshot(taskId, reducedResolution);
} catch (RemoteException e) {
Log.w(TAG, "Failed to retrieve task snapshot", e);
}
@@ -234,7 +235,7 @@ public class ActivityManagerWrapper {
}
};
}
- ActivityManager.getService().startRecentsActivity(intent, receiver, runner);
+ ActivityTaskManager.getService().startRecentsActivity(intent, receiver, runner);
if (resultCallback != null) {
resultCallbackHandler.post(new Runnable() {
@Override
@@ -260,7 +261,7 @@ public class ActivityManagerWrapper {
*/
public void cancelRecentsAnimation(boolean restoreHomeStackPosition) {
try {
- ActivityManager.getService().cancelRecentsAnimation(restoreHomeStackPosition);
+ ActivityTaskManager.getService().cancelRecentsAnimation(restoreHomeStackPosition);
} catch (RemoteException e) {
Log.e(TAG, "Failed to cancel recents animation", e);
}
@@ -333,7 +334,7 @@ public class ActivityManagerWrapper {
public boolean startActivityFromRecents(int taskId, ActivityOptions options) {
try {
Bundle optsBundle = options == null ? null : options.toBundle();
- ActivityManager.getService().startActivityFromRecents(taskId, optsBundle);
+ ActivityTaskManager.getService().startActivityFromRecents(taskId, optsBundle);
return true;
} catch (Exception e) {
return false;
@@ -384,7 +385,7 @@ public class ActivityManagerWrapper {
@Override
public void run() {
try {
- ActivityManager.getService().removeTask(taskId);
+ ActivityTaskManager.getService().removeTask(taskId);
} catch (RemoteException e) {
Log.w(TAG, "Failed to remove task=" + taskId, e);
}
@@ -397,7 +398,7 @@ public class ActivityManagerWrapper {
*/
public void cancelWindowTransition(int taskId) {
try {
- ActivityManager.getService().cancelTaskWindowTransition(taskId);
+ ActivityTaskManager.getService().cancelTaskWindowTransition(taskId);
} catch (RemoteException e) {
Log.w(TAG, "Failed to cancel window transition for task=" + taskId, e);
}
@@ -408,7 +409,7 @@ public class ActivityManagerWrapper {
*/
public boolean isScreenPinningActive() {
try {
- return ActivityManager.getService().getLockTaskModeState() == LOCK_TASK_MODE_PINNED;
+ return ActivityTaskManager.getService().getLockTaskModeState() == LOCK_TASK_MODE_PINNED;
} catch (RemoteException e) {
return false;
}
@@ -427,7 +428,7 @@ public class ActivityManagerWrapper {
*/
public boolean isLockToAppActive() {
try {
- return ActivityManager.getService().getLockTaskModeState() != LOCK_TASK_MODE_NONE;
+ return ActivityTaskManager.getService().getLockTaskModeState() != LOCK_TASK_MODE_NONE;
} catch (RemoteException e) {
return false;
}
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java
index 712cca67c5d6..36fb3a7b4307 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/ActivityOptionsCompat.java
@@ -16,8 +16,8 @@
package com.android.systemui.shared.system;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import android.app.ActivityOptions;
diff --git a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
index 5e293c61c35a..628b3c6e21dc 100644
--- a/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
+++ b/packages/SystemUI/shared/src/com/android/systemui/shared/system/TaskStackChangeListeners.java
@@ -16,6 +16,7 @@
package com.android.systemui.shared.system;
+import android.app.ActivityTaskManager;
import android.app.ActivityManager.TaskSnapshot;
import android.app.IActivityManager;
import android.app.TaskStackListener;
@@ -57,7 +58,7 @@ public class TaskStackChangeListeners extends TaskStackListener {
if (!mRegistered) {
// Register mTaskStackListener to IActivityManager only once if needed.
try {
- am.registerTaskStackListener(this);
+ ActivityTaskManager.getService().registerTaskStackListener(this);
mRegistered = true;
} catch (Exception e) {
Log.w(TAG, "Failed to call registerTaskStackListener", e);
diff --git a/packages/SystemUI/src/com/android/keyguard/CarrierText.java b/packages/SystemUI/src/com/android/keyguard/CarrierText.java
index 5b0f1c39f74b..66475e29128d 100644
--- a/packages/SystemUI/src/com/android/keyguard/CarrierText.java
+++ b/packages/SystemUI/src/com/android/keyguard/CarrierText.java
@@ -334,8 +334,10 @@ public class CarrierText extends TextView {
break;
case SimPermDisabled:
- carrierText = getContext().getText(
- R.string.keyguard_permanent_disabled_sim_message_short);
+ carrierText = makeCarrierStringOnEmergencyCapable(
+ getContext().getText(
+ R.string.keyguard_permanent_disabled_sim_message_short),
+ text);
break;
case SimMissingLocked:
diff --git a/packages/SystemUI/src/com/android/keyguard/EmergencyButton.java b/packages/SystemUI/src/com/android/keyguard/EmergencyButton.java
index 943558943821..5605b7a4babe 100644
--- a/packages/SystemUI/src/com/android/keyguard/EmergencyButton.java
+++ b/packages/SystemUI/src/com/android/keyguard/EmergencyButton.java
@@ -18,6 +18,7 @@ package com.android.keyguard;
import android.app.ActivityManager;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.content.Context;
import android.content.Intent;
import android.content.res.Configuration;
@@ -171,7 +172,7 @@ public class EmergencyButton extends Button {
// should be the equivalent to the old userActivity(EMERGENCY_CALL_TIMEOUT)
mPowerManager.userActivity(SystemClock.uptimeMillis(), true);
try {
- ActivityManager.getService().stopSystemLockTaskMode();
+ ActivityTaskManager.getService().stopSystemLockTaskMode();
} catch (RemoteException e) {
Slog.w(LOG_TAG, "Failed to stop app pinning");
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java b/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java
index 39271224d943..62b8e7c388de 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardConstants.java
@@ -26,6 +26,6 @@ public class KeyguardConstants {
* be used temporarily for debugging.
*/
public static final boolean DEBUG = false;
- public static final boolean DEBUG_SIM_STATES = false;
+ public static final boolean DEBUG_SIM_STATES = true;
public static final boolean DEBUG_FP_WAKELOCK = true;
}
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java
index 6d65f4f23134..4e060f652eb4 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardStatusView.java
@@ -282,6 +282,7 @@ public class KeyguardStatusView extends GridLayout implements
mClockView.setPivotX(mClockView.getWidth() / 2);
mClockView.setPivotY(0);
mLastLayoutHeight = getHeight();
+ layoutOwnerInfo();
}
@Override
@@ -418,9 +419,11 @@ public class KeyguardStatusView extends GridLayout implements
if (mLogoutView != null) {
mLogoutView.setAlpha(dark ? 0 : 1);
}
+
if (mOwnerInfo != null) {
boolean hasText = !TextUtils.isEmpty(mOwnerInfo.getText());
- mOwnerInfo.setVisibility(hasText && mDarkAmount != 1 ? VISIBLE : GONE);
+ mOwnerInfo.setVisibility(hasText ? VISIBLE : GONE);
+ layoutOwnerInfo();
}
final int blendedTextColor = ColorUtils.blendARGB(mTextColor, Color.WHITE, mDarkAmount);
@@ -430,6 +433,20 @@ public class KeyguardStatusView extends GridLayout implements
mClockSeparator.setBackgroundColor(blendedTextColor);
}
+ private void layoutOwnerInfo() {
+ if (mOwnerInfo != null && mOwnerInfo.getVisibility() != GONE) {
+ // Animate owner info during wake-up transition
+ mOwnerInfo.setAlpha(1f - mDarkAmount);
+
+ float ratio = mDarkAmount;
+ // Calculate how much of it we should crop in order to have a smooth transition
+ int collapsed = mOwnerInfo.getTop() - mOwnerInfo.getPaddingTop();
+ int expanded = mOwnerInfo.getBottom() + mOwnerInfo.getPaddingBottom();
+ int toRemove = (int) ((expanded - collapsed) * ratio);
+ setBottom(getMeasuredHeight() - toRemove);
+ }
+ }
+
public void setPulsing(boolean pulsing, boolean animate) {
mPulsing = pulsing;
mKeyguardSlice.setPulsing(pulsing, animate);
diff --git a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
index 62cd13b7dc17..d9a1b111345a 100644
--- a/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
+++ b/packages/SystemUI/src/com/android/keyguard/KeyguardUpdateMonitor.java
@@ -32,6 +32,7 @@ import static android.os.BatteryManager.EXTRA_STATUS;
import android.annotation.AnyThread;
import android.annotation.MainThread;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.AlarmManager;
import android.app.Instrumentation;
import android.app.PendingIntent;
@@ -1843,7 +1844,7 @@ public class KeyguardUpdateMonitor implements TrustManager.TrustListener {
@Override
public void onTaskStackChangedBackground() {
try {
- ActivityManager.StackInfo info = ActivityManager.getService().getStackInfo(
+ ActivityManager.StackInfo info = ActivityTaskManager.getService().getStackInfo(
WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_ASSISTANT);
if (info == null) {
return;
diff --git a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
index 7aef9fddedae..61784fa9a64e 100644
--- a/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
+++ b/packages/SystemUI/src/com/android/systemui/BatteryMeterView.java
@@ -56,6 +56,8 @@ import com.android.systemui.tuner.TunerService;
import com.android.systemui.tuner.TunerService.Tunable;
import com.android.systemui.util.Utils.DisableStateTracker;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.text.NumberFormat;
public class BatteryMeterView extends LinearLayout implements
@@ -343,6 +345,17 @@ public class BatteryMeterView extends LinearLayout implements
return (int) ArgbEvaluator.getInstance().evaluate(darkIntensity, lightColor, darkColor);
}
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ String powerSave = mDrawable == null ? null : mDrawable.getPowerSave() + "";
+ CharSequence percent = mBatteryPercentView == null ? null : mBatteryPercentView.getText();
+ pw.println(" BatteryMeterView:");
+ pw.println(" mDrawable.getPowerSave: " + powerSave);
+ pw.println(" mBatteryPercentView.getText(): " + percent);
+ pw.println(" mTextColor: #" + Integer.toHexString(mTextColor));
+ pw.println(" mLevel: " + mLevel);
+ pw.println(" mForceShowPercent: " + mForceShowPercent);
+ }
+
private final class SettingObserver extends ContentObserver {
public SettingObserver(Handler handler) {
super(handler);
diff --git a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
index 33cc25864522..3b2c9df313c9 100644
--- a/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
+++ b/packages/SystemUI/src/com/android/systemui/ScreenDecorations.java
@@ -582,31 +582,34 @@ public class ScreenDecorations extends SystemUI implements Tunable {
resolveSizeAndState(mBoundingRect.height(), heightMeasureSpec, 0));
}
- public static void boundsFromDirection(DisplayCutout displayCutout, int gravity, Rect out) {
+ public static void boundsFromDirection(DisplayCutout displayCutout, int gravity,
+ Rect out) {
+ Region bounds = boundsFromDirection(displayCutout, gravity);
+ out.set(bounds.getBounds());
+ bounds.recycle();
+ }
+
+ public static Region boundsFromDirection(DisplayCutout displayCutout, int gravity) {
Region bounds = displayCutout.getBounds();
switch (gravity) {
case Gravity.TOP:
bounds.op(0, 0, Integer.MAX_VALUE, displayCutout.getSafeInsetTop(),
Region.Op.INTERSECT);
- out.set(bounds.getBounds());
break;
case Gravity.LEFT:
bounds.op(0, 0, displayCutout.getSafeInsetLeft(), Integer.MAX_VALUE,
Region.Op.INTERSECT);
- out.set(bounds.getBounds());
break;
case Gravity.BOTTOM:
bounds.op(0, displayCutout.getSafeInsetTop() + 1, Integer.MAX_VALUE,
Integer.MAX_VALUE, Region.Op.INTERSECT);
- out.set(bounds.getBounds());
break;
case Gravity.RIGHT:
bounds.op(displayCutout.getSafeInsetLeft() + 1, 0, Integer.MAX_VALUE,
Integer.MAX_VALUE, Region.Op.INTERSECT);
- out.set(bounds.getBounds());
break;
}
- bounds.recycle();
+ return bounds;
}
private void localBounds(Rect out) {
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
index 6809e76c18e3..cf6f16a0e154 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/KeyguardViewMediator.java
@@ -26,6 +26,7 @@ import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STR
import static com.android.internal.widget.LockPatternUtils.StrongAuthTracker.STRONG_AUTH_REQUIRED_AFTER_TIMEOUT;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.AlarmManager;
import android.app.PendingIntent;
import android.app.StatusBarManager;
@@ -495,6 +496,7 @@ public class KeyguardViewMediator extends SystemUI {
break;
case READY:
synchronized (KeyguardViewMediator.this) {
+ if (DEBUG_SIM_STATES) Log.d(TAG, "READY, reset state? " + mShowing);
if (mShowing) {
resetStateLocked();
}
@@ -1749,7 +1751,7 @@ public class KeyguardViewMediator extends SystemUI {
int secondaryDisplayShowing) {
mUiOffloadThread.submit(() -> {
try {
- ActivityManager.getService().setLockScreenShown(showing, aodShowing,
+ ActivityTaskManager.getService().setLockScreenShown(showing, aodShowing,
secondaryDisplayShowing);
} catch (RemoteException e) {
}
@@ -1812,7 +1814,7 @@ public class KeyguardViewMediator extends SystemUI {
// Don't actually hide the Keyguard at the moment, wait for window
// manager until it tells us it's safe to do so with
// startKeyguardExitAnimation.
- ActivityManager.getService().keyguardGoingAway(flags);
+ ActivityTaskManager.getService().keyguardGoingAway(flags);
} catch (RemoteException e) {
Log.e(TAG, "Error while calling WindowManager", e);
}
diff --git a/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java b/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java
index b9e9e0a7f529..0cedf9825990 100644
--- a/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/keyguard/WorkLockActivityController.java
@@ -18,7 +18,9 @@ package com.android.systemui.keyguard;
import android.app.ActivityManager;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.KeyguardManager;
import android.content.ComponentName;
import android.content.Context;
@@ -37,16 +39,17 @@ public class WorkLockActivityController {
private static final String TAG = WorkLockActivityController.class.getSimpleName();
private final Context mContext;
- private final IActivityManager mIam;
+ private final IActivityTaskManager mIatm;
public WorkLockActivityController(Context context) {
- this(context, ActivityManagerWrapper.getInstance(), ActivityManager.getService());
+ this(context, ActivityManagerWrapper.getInstance(), ActivityTaskManager.getService());
}
@VisibleForTesting
- WorkLockActivityController(Context context, ActivityManagerWrapper am, IActivityManager iAm) {
+ WorkLockActivityController(
+ Context context, ActivityManagerWrapper am, IActivityTaskManager iAtm) {
mContext = context;
- mIam = iAm;
+ mIatm = iAtm;
am.registerTaskStackListener(mLockListener);
}
@@ -54,7 +57,7 @@ public class WorkLockActivityController {
private void startWorkChallengeInTask(int taskId, int userId) {
ActivityManager.TaskDescription taskDescription = null;
try {
- taskDescription = mIam.getTaskDescription(taskId);
+ taskDescription = mIatm.getTaskDescription(taskId);
} catch (RemoteException e) {
Log.w(TAG, "Failed to get description for task=" + taskId);
}
@@ -76,7 +79,7 @@ public class WorkLockActivityController {
// Starting the activity inside the task failed. We can't be sure why, so to be
// safe just remove the whole task if it still exists.
try {
- mIam.removeTask(taskId);
+ mIatm.removeTask(taskId);
} catch (RemoteException e) {
Log.w(TAG, "Failed to get description for task=" + taskId);
}
@@ -89,7 +92,7 @@ public class WorkLockActivityController {
*/
private int startActivityAsUser(Intent intent, Bundle options, int userId) {
try {
- return mIam.startActivityAsUser(
+ return mIatm.startActivityAsUser(
mContext.getIApplicationThread() /*caller*/,
mContext.getBasePackageName() /*callingPackage*/,
intent /*intent*/,
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
index 2af7ae27873c..ee15655d87b2 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipManager.java
@@ -20,7 +20,9 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.INPUT_CONSUMER_PIP;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ParceledListSlice;
@@ -55,6 +57,7 @@ public class PipManager implements BasePipManager {
private Context mContext;
private IActivityManager mActivityManager;
+ private IActivityTaskManager mActivityTaskManager;
private IWindowManager mWindowManager;
private Handler mHandler = new Handler();
@@ -172,6 +175,7 @@ public class PipManager implements BasePipManager {
public void initialize(Context context) {
mContext = context;
mActivityManager = ActivityManager.getService();
+ mActivityTaskManager = ActivityTaskManager.getService();
mWindowManager = WindowManagerGlobal.getWindowManagerService();
try {
@@ -186,8 +190,8 @@ public class PipManager implements BasePipManager {
mMediaController = new PipMediaController(context, mActivityManager);
mMenuController = new PipMenuActivityController(context, mActivityManager, mMediaController,
mInputConsumerController);
- mTouchHandler = new PipTouchHandler(context, mActivityManager, mMenuController,
- mInputConsumerController);
+ mTouchHandler = new PipTouchHandler(context, mActivityManager, mActivityTaskManager,
+ mMenuController, mInputConsumerController);
mAppOpsListener = new PipAppOpsListener(context, mActivityManager,
mTouchHandler.getMotionHelper());
EventBus.getDefault().register(this);
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
index a4927b7704c5..615b29f93269 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivity.java
@@ -342,7 +342,7 @@ public class PipMenuActivity extends Activity {
mHandler.post(() -> {
event.getAnimationTrigger().decrement();
});
- }, true /* notifyMenuVisibility */);
+ }, true /* notifyMenuVisibility */, false /* isDismissing */);
}
}
@@ -396,10 +396,12 @@ public class PipMenuActivity extends Activity {
}
private void hideMenu() {
- hideMenu(null /* animationFinishedRunnable */, true /* notifyMenuVisibility */);
+ hideMenu(null /* animationFinishedRunnable */, true /* notifyMenuVisibility */,
+ false /* isDismissing */);
}
- private void hideMenu(final Runnable animationFinishedRunnable, boolean notifyMenuVisibility) {
+ private void hideMenu(final Runnable animationFinishedRunnable, boolean notifyMenuVisibility,
+ boolean isDismissing) {
if (mMenuState != MENU_STATE_NONE) {
cancelDelayedFinish();
if (notifyMenuVisibility) {
@@ -422,7 +424,12 @@ public class PipMenuActivity extends Activity {
if (animationFinishedRunnable != null) {
animationFinishedRunnable.run();
}
- finish();
+
+ if (!isDismissing) {
+ // If we are dismissing the PiP, then don't try to pre-emptively finish the
+ // menu activity
+ finish();
+ }
}
});
mMenuContainerAnimator.start();
@@ -583,7 +590,7 @@ public class PipMenuActivity extends Activity {
hideMenu(() -> {
sendEmptyMessage(PipMenuActivityController.MESSAGE_EXPAND_PIP,
"Could not notify controller to expand PIP");
- }, false /* notifyMenuVisibility */);
+ }, false /* notifyMenuVisibility */, false /* isDismissing */);
}
private void minimizePip() {
@@ -597,7 +604,7 @@ public class PipMenuActivity extends Activity {
hideMenu(() -> {
sendEmptyMessage(PipMenuActivityController.MESSAGE_DISMISS_PIP,
"Could not notify controller to dismiss PIP");
- }, false /* notifyMenuVisibility */);
+ }, false /* notifyMenuVisibility */, true /* isDismissing */);
}
private void showPipMenu() {
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
index 26fced307bac..360fe73be95a 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMenuActivityController.java
@@ -19,6 +19,7 @@ package com.android.systemui.pip.phone;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
+import android.app.ActivityTaskManager;
import android.app.ActivityManager.StackInfo;
import android.app.ActivityOptions;
import android.app.IActivityManager;
@@ -384,7 +385,7 @@ public class PipMenuActivityController {
private void startMenuActivity(int menuState, Rect stackBounds, Rect movementBounds,
boolean allowMenuTimeout, boolean willResizeMenu) {
try {
- StackInfo pinnedStackInfo = mActivityManager.getStackInfo(
+ StackInfo pinnedStackInfo = ActivityTaskManager.getService().getStackInfo(
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
if (pinnedStackInfo != null && pinnedStackInfo.taskIds != null &&
pinnedStackInfo.taskIds.length > 0) {
@@ -423,7 +424,7 @@ public class PipMenuActivityController {
// Fetch the pinned stack bounds
Rect stackBounds = null;
try {
- StackInfo pinnedStackInfo = mActivityManager.getStackInfo(
+ StackInfo pinnedStackInfo = ActivityTaskManager.getService().getStackInfo(
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
if (pinnedStackInfo != null) {
stackBounds = pinnedStackInfo.bounds;
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java
index ad841308cb0d..f0ab046f7dbe 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipMotionHelper.java
@@ -30,7 +30,9 @@ import android.animation.RectEvaluator;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.ActivityManager.StackInfo;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.content.Context;
import android.graphics.Point;
import android.graphics.PointF;
@@ -81,6 +83,7 @@ public class PipMotionHelper implements Handler.Callback {
private Context mContext;
private IActivityManager mActivityManager;
+ private IActivityTaskManager mActivityTaskManager;
private Handler mHandler;
private PipMenuActivityController mMenuController;
@@ -94,11 +97,12 @@ public class PipMotionHelper implements Handler.Callback {
private ValueAnimator mBoundsAnimator = null;
public PipMotionHelper(Context context, IActivityManager activityManager,
- PipMenuActivityController menuController, PipSnapAlgorithm snapAlgorithm,
- FlingAnimationUtils flingAnimationUtils) {
+ IActivityTaskManager activityTaskManager, PipMenuActivityController menuController,
+ PipSnapAlgorithm snapAlgorithm, FlingAnimationUtils flingAnimationUtils) {
mContext = context;
mHandler = new Handler(ForegroundThread.get().getLooper(), this);
mActivityManager = activityManager;
+ mActivityTaskManager = activityTaskManager;
mMenuController = menuController;
mSnapAlgorithm = snapAlgorithm;
mFlingAnimationUtils = flingAnimationUtils;
@@ -121,8 +125,8 @@ public class PipMotionHelper implements Handler.Callback {
void synchronizePinnedStackBounds() {
cancelAnimations();
try {
- StackInfo stackInfo =
- mActivityManager.getStackInfo(WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
+ StackInfo stackInfo = mActivityTaskManager.getStackInfo(
+ WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
if (stackInfo != null) {
mBounds.set(stackInfo.bounds);
}
@@ -159,7 +163,7 @@ public class PipMotionHelper implements Handler.Callback {
mMenuController.hideMenuWithoutResize();
mHandler.post(() -> {
try {
- mActivityManager.dismissPip(!skipAnimation, EXPAND_STACK_TO_FULLSCREEN_DURATION);
+ mActivityTaskManager.dismissPip(!skipAnimation, EXPAND_STACK_TO_FULLSCREEN_DURATION);
} catch (RemoteException e) {
Log.e(TAG, "Error expanding PiP activity", e);
}
@@ -177,7 +181,8 @@ public class PipMotionHelper implements Handler.Callback {
mMenuController.hideMenuWithoutResize();
mHandler.post(() -> {
try {
- mActivityManager.removeStacksInWindowingModes(new int[]{ WINDOWING_MODE_PINNED });
+ mActivityTaskManager.removeStacksInWindowingModes(
+ new int[]{ WINDOWING_MODE_PINNED });
} catch (RemoteException e) {
Log.e(TAG, "Failed to remove PiP", e);
}
@@ -512,7 +517,8 @@ public class PipMotionHelper implements Handler.Callback {
SomeArgs args = (SomeArgs) msg.obj;
Rect toBounds = (Rect) args.arg1;
try {
- mActivityManager.resizePinnedStack(toBounds, null /* tempPinnedTaskBounds */);
+ mActivityTaskManager.resizePinnedStack(
+ toBounds, null /* tempPinnedTaskBounds */);
mBounds.set(toBounds);
} catch (RemoteException e) {
Log.e(TAG, "Could not resize pinned stack to bounds: " + toBounds, e);
@@ -525,7 +531,7 @@ public class PipMotionHelper implements Handler.Callback {
Rect toBounds = (Rect) args.arg1;
int duration = args.argi1;
try {
- StackInfo stackInfo = mActivityManager.getStackInfo(
+ StackInfo stackInfo = mActivityTaskManager.getStackInfo(
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
if (stackInfo == null) {
// In the case where we've already re-expanded or dismissed the PiP, then
@@ -533,7 +539,7 @@ public class PipMotionHelper implements Handler.Callback {
return true;
}
- mActivityManager.resizeStack(stackInfo.stackId, toBounds,
+ mActivityTaskManager.resizeStack(stackInfo.stackId, toBounds,
false /* allowResizeInDockedMode */, true /* preserveWindows */,
true /* animate */, duration);
mBounds.set(toBounds);
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
index 02345c9ffdb8..3742194738b0 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipTouchHandler.java
@@ -25,6 +25,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.animation.ValueAnimator.AnimatorUpdateListener;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.res.Resources;
@@ -69,6 +70,7 @@ public class PipTouchHandler {
private final boolean mEnableDimissDragToEdge;
private final Context mContext;
private final IActivityManager mActivityManager;
+ private final IActivityTaskManager mActivityTaskManager;
private final ViewConfiguration mViewConfig;
private final PipMenuListener mMenuListener = new PipMenuListener();
private IPinnedStackController mPinnedStackController;
@@ -172,12 +174,13 @@ public class PipTouchHandler {
}
public PipTouchHandler(Context context, IActivityManager activityManager,
- PipMenuActivityController menuController,
+ IActivityTaskManager activityTaskManager, PipMenuActivityController menuController,
InputConsumerController inputConsumerController) {
// Initialize the Pip input consumer
mContext = context;
mActivityManager = activityManager;
+ mActivityTaskManager = activityTaskManager;
mAccessibilityManager = context.getSystemService(AccessibilityManager.class);
mViewConfig = ViewConfiguration.get(context);
mMenuController = menuController;
@@ -188,8 +191,8 @@ public class PipTouchHandler {
mGestures = new PipTouchGesture[] {
mDefaultMovementGesture
};
- mMotionHelper = new PipMotionHelper(mContext, mActivityManager, mMenuController,
- mSnapAlgorithm, mFlingAnimationUtils);
+ mMotionHelper = new PipMotionHelper(mContext, mActivityManager, mActivityTaskManager,
+ mMenuController, mSnapAlgorithm, mFlingAnimationUtils);
mTouchState = new PipTouchState(mViewConfig, mHandler,
() -> mMenuController.showMenu(MENU_STATE_FULL, mMotionHelper.getBounds(),
mMovementBounds, true /* allowMenuTimeout */, willResizeMenu()));
diff --git a/packages/SystemUI/src/com/android/systemui/pip/phone/PipUtils.java b/packages/SystemUI/src/com/android/systemui/pip/phone/PipUtils.java
index 2f53de96db2d..1ed1904d30fb 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/phone/PipUtils.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/phone/PipUtils.java
@@ -20,6 +20,7 @@ import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import android.app.ActivityManager.StackInfo;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
import android.content.ComponentName;
import android.content.Context;
@@ -39,8 +40,8 @@ public class PipUtils {
IActivityManager activityManager) {
try {
final String sysUiPackageName = context.getPackageName();
- final StackInfo pinnedStackInfo =
- activityManager.getStackInfo(WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
+ final StackInfo pinnedStackInfo = ActivityTaskManager.getService().getStackInfo(
+ WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
if (pinnedStackInfo != null && pinnedStackInfo.taskIds != null &&
pinnedStackInfo.taskIds.length > 0) {
for (int i = pinnedStackInfo.taskNames.length - 1; i >= 0; i--) {
diff --git a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
index d6f67604a050..d9f923f2b4e3 100644
--- a/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
+++ b/packages/SystemUI/src/com/android/systemui/pip/tv/PipManager.java
@@ -19,7 +19,9 @@ package com.android.systemui.pip.tv;
import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
import android.app.ActivityManager.StackInfo;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -53,7 +55,7 @@ import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
-import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
+import static android.app.ActivityTaskManager.INVALID_STACK_ID;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
import static android.view.Display.DEFAULT_DISPLAY;
@@ -108,6 +110,7 @@ public class PipManager implements BasePipManager {
private Context mContext;
private IActivityManager mActivityManager;
+ private IActivityTaskManager mActivityTaskManager;
private IWindowManager mWindowManager;
private MediaSessionManager mMediaSessionManager;
private int mState = STATE_NO_PIP;
@@ -238,6 +241,7 @@ public class PipManager implements BasePipManager {
mContext = context;
mActivityManager = ActivityManager.getService();
+ mActivityTaskManager = ActivityTaskManager.getService();
mWindowManager = WindowManagerGlobal.getWindowManagerService();
ActivityManagerWrapper.getInstance().registerTaskStackListener(mTaskStackListener);
IntentFilter intentFilter = new IntentFilter();
@@ -343,7 +347,7 @@ public class PipManager implements BasePipManager {
mMediaSessionManager.removeOnActiveSessionsChangedListener(mActiveMediaSessionListener);
if (removePipStack) {
try {
- mActivityManager.removeStack(mPinnedStackId);
+ mActivityTaskManager.removeStack(mPinnedStackId);
} catch (RemoteException e) {
Log.e(TAG, "removeStack failed", e);
} finally {
@@ -433,7 +437,7 @@ public class PipManager implements BasePipManager {
}
try {
int animationDurationMs = -1;
- mActivityManager.resizeStack(mPinnedStackId, mCurrentPipBounds,
+ mActivityTaskManager.resizeStack(mPinnedStackId, mCurrentPipBounds,
true, true, true, animationDurationMs);
} catch (RemoteException e) {
Log.e(TAG, "resizeStack failed", e);
@@ -511,7 +515,7 @@ public class PipManager implements BasePipManager {
private StackInfo getPinnedStackInfo() {
StackInfo stackInfo = null;
try {
- stackInfo = mActivityManager.getStackInfo(
+ stackInfo = ActivityTaskManager.getService().getStackInfo(
WINDOWING_MODE_PINNED, ACTIVITY_TYPE_UNDEFINED);
} catch (RemoteException e) {
Log.e(TAG, "getStackInfo failed", e);
@@ -604,7 +608,7 @@ public class PipManager implements BasePipManager {
private boolean isSettingsShown() {
List<RunningTaskInfo> runningTasks;
try {
- runningTasks = mActivityManager.getTasks(1);
+ runningTasks = mActivityTaskManager.getTasks(1);
if (runningTasks.isEmpty()) {
return false;
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
index d8bf990f6465..80b6c73f0ddf 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSContainerImpl.java
@@ -17,6 +17,7 @@
package com.android.systemui.qs;
import static android.app.StatusBarManager.DISABLE2_QUICK_SETTINGS;
+import static android.content.res.Configuration.ORIENTATION_LANDSCAPE;
import android.content.Context;
import android.content.res.Configuration;
@@ -77,16 +78,7 @@ public class QSContainerImpl extends FrameLayout {
@Override
protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(newConfig);
-
- // Hide the backgrounds when in landscape mode.
- if (newConfig.orientation == Configuration.ORIENTATION_LANDSCAPE) {
- mBackgroundGradient.setVisibility(View.INVISIBLE);
- mStatusBarBackground.setVisibility(View.INVISIBLE);
- } else {
- mBackgroundGradient.setVisibility(View.VISIBLE);
- mStatusBarBackground.setVisibility(View.VISIBLE);
- }
-
+ setBackgroundGradientVisibility(newConfig);
updateResources();
mSizePoint.set(0, 0); // Will be retrieved on next measure pass.
}
@@ -128,7 +120,7 @@ public class QSContainerImpl extends FrameLayout {
final boolean disabled = (state2 & DISABLE2_QUICK_SETTINGS) != 0;
if (disabled == mQsDisabled) return;
mQsDisabled = disabled;
- mBackgroundGradient.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
+ setBackgroundGradientVisibility(getResources().getConfiguration());
mBackground.setVisibility(mQsDisabled ? View.GONE : View.VISIBLE);
}
@@ -168,6 +160,16 @@ public class QSContainerImpl extends FrameLayout {
+ mHeader.getHeight();
}
+ private void setBackgroundGradientVisibility(Configuration newConfig) {
+ if (newConfig.orientation == ORIENTATION_LANDSCAPE) {
+ mBackgroundGradient.setVisibility(View.INVISIBLE);
+ mStatusBarBackground.setVisibility(View.INVISIBLE);
+ } else {
+ mBackgroundGradient.setVisibility(mQsDisabled ? View.INVISIBLE : View.VISIBLE);
+ mStatusBarBackground.setVisibility(View.VISIBLE);
+ }
+ }
+
public void setExpansion(float expansion) {
mQsExpansion = expansion;
updateExpansion();
diff --git a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java
index a48bcbd1f840..6418c8075b1e 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/QSSecurityFooter.java
@@ -153,9 +153,14 @@ public class QSSecurityFooter implements OnClickListener, DialogInterface.OnClic
hasCACerts, hasCACertsInWorkProfile, isNetworkLoggingEnabled, vpnName,
vpnNameWorkProfile, organizationName, workProfileName);
// Update the icon
- int footerIconId = vpnName != null || vpnNameWorkProfile != null
- ? R.drawable.ic_qs_vpn
- : R.drawable.ic_info_outline;
+ int footerIconId = R.drawable.ic_info_outline;
+ if (vpnName != null || vpnNameWorkProfile != null) {
+ if (mSecurityController.isVpnBranded()) {
+ footerIconId = R.drawable.ic_qs_branded_vpn;
+ } else {
+ footerIconId = R.drawable.ic_qs_vpn;
+ }
+ }
if (mFooterIconId != footerIconId) {
mFooterIconId = footerIconId;
mMainHandler.post(mUpdateIcon);
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
index 23e3f25f6f5a..7f3537c2d41d 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/BatterySaverTile.java
@@ -70,6 +70,9 @@ public class BatterySaverTile extends QSTileImpl<BooleanState> implements
@Override
protected void handleClick() {
+ if (getState().state == Tile.STATE_UNAVAILABLE) {
+ return;
+ }
mBatteryController.setPowerSaveMode(!mPowerSave);
}
diff --git a/packages/SystemUI/src/com/android/systemui/qs/tiles/NightDisplayTile.java b/packages/SystemUI/src/com/android/systemui/qs/tiles/NightDisplayTile.java
index 7cb54bee789b..e0a9148b1230 100644
--- a/packages/SystemUI/src/com/android/systemui/qs/tiles/NightDisplayTile.java
+++ b/packages/SystemUI/src/com/android/systemui/qs/tiles/NightDisplayTile.java
@@ -26,6 +26,7 @@ import android.provider.Settings;
import android.service.quicksettings.Tile;
import androidx.annotation.StringRes;
import android.text.TextUtils;
+import android.text.format.DateFormat;
import android.util.Log;
import android.widget.Switch;
@@ -48,6 +49,7 @@ public class NightDisplayTile extends QSTileImpl<BooleanState>
*/
private static final String PATTERN_HOUR = "h a";
private static final String PATTERN_HOUR_MINUTE = "h:mm a";
+ private static final String PATTERN_HOUR_NINUTE_24 = "HH:mm";
private ColorDisplayController mController;
@@ -145,6 +147,7 @@ public class NightDisplayTile extends QSTileImpl<BooleanState>
// Choose between just showing the hour or also showing the minutes (based on the
// user-selected toggle time). This helps reduce how much space the label takes.
toggleTimeFormat = DateTimeFormatter.ofPattern(
+ DateFormat.is24HourFormat(mContext) ? PATTERN_HOUR_NINUTE_24 :
toggleTime.getMinute() == 0 ? PATTERN_HOUR : PATTERN_HOUR_MINUTE);
return mContext.getString(toggleTimeStringRes, toggleTime.format(toggleTimeFormat));
diff --git a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
index 481d54f3bbb6..91512dd53f96 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/ScreenPinningRequest.java
@@ -19,6 +19,7 @@ package com.android.systemui.recents;
import android.animation.ArgbEvaluator;
import android.animation.ValueAnimator;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
@@ -124,7 +125,7 @@ public class ScreenPinningRequest implements View.OnClickListener {
public void onClick(View v) {
if (v.getId() == R.id.screen_pinning_ok_button || mRequestWindow == v) {
try {
- ActivityManager.getService().startSystemLockTaskMode(taskId);
+ ActivityTaskManager.getService().startSystemLockTaskMode(taskId);
} catch (RemoteException e) {}
}
clearPrompt();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
index 544d95c7b62f..350fe7848d9d 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/misc/SystemServicesProxy.java
@@ -28,8 +28,10 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import android.app.ActivityManager;
import android.app.ActivityManager.StackInfo;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.app.AppGlobals;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.WindowConfiguration;
import android.content.ComponentName;
import android.content.ContentResolver;
@@ -94,6 +96,7 @@ public class SystemServicesProxy {
AccessibilityManager mAccm;
ActivityManager mAm;
IActivityManager mIam;
+ IActivityTaskManager mIatm;
PackageManager mPm;
IPackageManager mIpm;
private final IDreamManager mDreamManager;
@@ -133,6 +136,7 @@ public class SystemServicesProxy {
mAccm = AccessibilityManager.getInstance(context);
mAm = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
mIam = ActivityManager.getService();
+ mIatm = ActivityTaskManager.getService();
mPm = context.getPackageManager();
mIpm = AppGlobals.getPackageManager();
mAssistUtils = new AssistUtils(context);
@@ -203,7 +207,7 @@ public class SystemServicesProxy {
if (mIam == null) return false;
try {
- List<StackInfo> stackInfos = mIam.getAllStackInfos();
+ List<StackInfo> stackInfos = mIatm.getAllStackInfos();
ActivityManager.StackInfo homeStackInfo = null;
ActivityManager.StackInfo fullscreenStackInfo = null;
ActivityManager.StackInfo recentsStackInfo = null;
@@ -261,13 +265,13 @@ public class SystemServicesProxy {
/** Moves an already resumed task to the side of the screen to initiate split screen. */
public boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode,
Rect initialBounds) {
- if (mIam == null) {
+ if (mIatm == null) {
return false;
}
try {
- return mIam.setTaskWindowingModeSplitScreenPrimary(taskId, createMode, true /* onTop */,
- false /* animate */, initialBounds, true /* showRecents */);
+ return mIatm.setTaskWindowingModeSplitScreenPrimary(taskId, createMode,
+ true /* onTop */, false /* animate */, initialBounds, true /* showRecents */);
} catch (RemoteException e) {
e.printStackTrace();
}
@@ -276,7 +280,7 @@ public class SystemServicesProxy {
public ActivityManager.StackInfo getSplitScreenPrimaryStack() {
try {
- return mIam.getStackInfo(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, ACTIVITY_TYPE_UNDEFINED);
+ return mIatm.getStackInfo(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, ACTIVITY_TYPE_UNDEFINED);
} catch (RemoteException e) {
return null;
}
@@ -324,10 +328,10 @@ public class SystemServicesProxy {
/** Set the task's windowing mode. */
public void setTaskWindowingMode(int taskId, int windowingMode) {
- if (mIam == null) return;
+ if (mIatm == null) return;
try {
- mIam.setTaskWindowingMode(taskId, windowingMode, false /* onTop */);
+ mIatm.setTaskWindowingMode(taskId, windowingMode, false /* onTop */);
} catch (RemoteException | IllegalArgumentException e) {
e.printStackTrace();
}
@@ -372,7 +376,7 @@ public class SystemServicesProxy {
if (mIam == null) return false;
try {
- return mIam.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_PINNED;
+ return mIatm.getLockTaskModeState() == ActivityManager.LOCK_TASK_MODE_PINNED;
} catch (RemoteException e) {
return false;
}
@@ -413,9 +417,9 @@ public class SystemServicesProxy {
try {
// Use the recents stack bounds, fallback to fullscreen stack if it is null
ActivityManager.StackInfo stackInfo =
- mIam.getStackInfo(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_RECENTS);
+ mIatm.getStackInfo(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_RECENTS);
if (stackInfo == null) {
- stackInfo = mIam.getStackInfo(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
+ stackInfo = mIatm.getStackInfo(WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_STANDARD);
}
if (stackInfo != null) {
windowRect.set(stackInfo.bounds);
@@ -437,7 +441,7 @@ public class SystemServicesProxy {
if (mIam == null) return;
try {
- mIam.startInPlaceAnimationOnFrontMostApplication(
+ mIatm.startInPlaceAnimationOnFrontMostApplication(
opts == null ? null : opts.toBundle());
} catch (Exception e) {
e.printStackTrace();
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/DockState.java b/packages/SystemUI/src/com/android/systemui/recents/views/DockState.java
index 65b96fbb52f9..a246141c74f8 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/DockState.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/DockState.java
@@ -16,8 +16,8 @@
package com.android.systemui.recents.views;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.view.WindowManager.DOCKED_BOTTOM;
import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.DOCKED_LEFT;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
index 0f64ea33176e..5c925fda640e 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsView.java
@@ -16,7 +16,7 @@
package com.android.systemui.recents.views;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static com.android.systemui.statusbar.phone.StatusBar.SYSTEM_DIALOG_REASON_RECENT_APPS;
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
index 5c69ae3915b3..53a91e536c8a 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/RecentsViewTouchHandler.java
@@ -17,6 +17,7 @@
package com.android.systemui.recents.views;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.graphics.Point;
import android.graphics.Rect;
import android.view.InputDevice;
@@ -137,7 +138,7 @@ public class RecentsViewTouchHandler {
}
mVisibleDockStates.clear();
- if (ActivityManager.supportsMultiWindow(mRv.getContext()) && !ssp.hasDockedTask()
+ if (ActivityTaskManager.supportsMultiWindow(mRv.getContext()) && !ssp.hasDockedTask()
&& mDividerSnapAlgorithm.isSplitScreenFeasible()) {
Recents.logDockAttempt(mRv.getContext(), event.task.getTopComponent(),
event.task.resizeMode);
diff --git a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewAccessibilityDelegate.java b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewAccessibilityDelegate.java
index 0fc507b92bf3..f217596bd4a9 100644
--- a/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewAccessibilityDelegate.java
+++ b/packages/SystemUI/src/com/android/systemui/recents/views/TaskViewAccessibilityDelegate.java
@@ -17,6 +17,7 @@
package com.android.systemui.recents.views;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.content.Context;
import android.graphics.Point;
import android.os.Bundle;
@@ -58,7 +59,7 @@ public class TaskViewAccessibilityDelegate extends View.AccessibilityDelegate {
@Override
public void onInitializeAccessibilityNodeInfo(View host, AccessibilityNodeInfo info) {
super.onInitializeAccessibilityNodeInfo(host, info);
- if (ActivityManager.supportsSplitScreenMultiWindow(mTaskView.getContext())
+ if (ActivityTaskManager.supportsSplitScreenMultiWindow(mTaskView.getContext())
&& !Recents.getSystemServices().hasDockedTask()) {
DockState[] dockStates = Recents.getConfiguration()
.getDockStatesForCurrentOrientation();
diff --git a/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java b/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java
index da798848f7e8..750002cbc5ca 100644
--- a/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java
+++ b/packages/SystemUI/src/com/android/systemui/shortcut/ShortcutKeyDispatcher.java
@@ -16,8 +16,8 @@
package com.android.systemui.shortcut;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.os.UserHandle.USER_CURRENT;
import static com.android.systemui.statusbar.phone.NavigationBarGestureHelper.DRAG_MODE_NONE;
diff --git a/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java b/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
index 1e5b37c9af50..600964e98b84 100644
--- a/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
+++ b/packages/SystemUI/src/com/android/systemui/stackdivider/WindowManagerProxy.java
@@ -19,6 +19,7 @@ package com.android.systemui.stackdivider;
import static android.view.WindowManager.DOCKED_INVALID;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.graphics.Rect;
import android.os.RemoteException;
import android.util.Log;
@@ -71,7 +72,7 @@ public class WindowManagerProxy {
mTmpRect5.set(mTempOtherInsetRect);
}
try {
- ActivityManager.getService()
+ ActivityTaskManager.getService()
.resizeDockedStack(mTmpRect1,
mTmpRect2.isEmpty() ? null : mTmpRect2,
mTmpRect3.isEmpty() ? null : mTmpRect3,
@@ -87,7 +88,7 @@ public class WindowManagerProxy {
@Override
public void run() {
try {
- ActivityManager.getService().dismissSplitScreenMode(false /* onTop */);
+ ActivityTaskManager.getService().dismissSplitScreenMode(false /* onTop */);
} catch (RemoteException e) {
Log.w(TAG, "Failed to remove stack: " + e);
}
@@ -98,7 +99,7 @@ public class WindowManagerProxy {
@Override
public void run() {
try {
- ActivityManager.getService().dismissSplitScreenMode(true /* onTop */);
+ ActivityTaskManager.getService().dismissSplitScreenMode(true /* onTop */);
} catch (RemoteException e) {
Log.w(TAG, "Failed to resize stack: " + e);
}
@@ -180,7 +181,7 @@ public class WindowManagerProxy {
@Override
public void run() {
try {
- ActivityManager.getService().setSplitScreenResizing(resizing);
+ ActivityTaskManager.getService().setSplitScreenResizing(resizing);
} catch (RemoteException e) {
Log.w(TAG, "Error calling setDockedStackResizing: " + e);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
index d647e21888dd..135b03791ea6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/ExpandableNotificationRow.java
@@ -63,7 +63,7 @@ import android.widget.RemoteViews;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.logging.MetricsLogger;
import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.internal.widget.CachingIconView;
import com.android.systemui.Dependency;
import com.android.systemui.Interpolators;
@@ -438,7 +438,8 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
*/
public boolean getIsNonblockable() {
boolean isNonblockable = Dependency.get(NotificationBlockingHelperManager.class)
- .isNonblockablePackage(mStatusBarNotification.getPackageName());
+ .isNonblockable(mStatusBarNotification.getPackageName(),
+ mEntry.channel.getId());
// If the SystemNotifAsyncTask hasn't finished running or retrieved a value, we'll try once
// again, but in-place on the main thread this time. This should rarely ever get called.
@@ -496,7 +497,7 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
StatusBarIconView expandedIcon = mEntry.expandedIcon;
boolean isPreL = Boolean.TRUE.equals(expandedIcon.getTag(R.id.icon_is_pre_L));
boolean colorize = !isPreL || NotificationUtils.isGrayscale(expandedIcon,
- NotificationColorUtil.getInstance(mContext));
+ ContrastColorUtil.getInstance(mContext));
int color = StatusBarIconView.NO_COLOR;
if (colorize) {
NotificationHeaderView header = getVisibleNotificationHeader();
@@ -1120,10 +1121,10 @@ public class ExpandableNotificationRow extends ActivatableNotificationView
}
private void updateNotificationColor() {
- mNotificationColor = NotificationColorUtil.resolveContrastColor(mContext,
+ mNotificationColor = ContrastColorUtil.resolveContrastColor(mContext,
getStatusBarNotification().getNotification().color,
getBackgroundColorWithoutTint());
- mNotificationColorAmbient = NotificationColorUtil.resolveAmbientColor(mContext,
+ mNotificationColorAmbient = ContrastColorUtil.resolveAmbientColor(mContext,
getStatusBarNotification().getNotification().color);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBlockingHelperManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBlockingHelperManager.java
index 6f5e8cb3e8d8..c78ab8db2ff7 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBlockingHelperManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationBlockingHelperManager.java
@@ -144,8 +144,15 @@ public class NotificationBlockingHelperManager {
/**
* Returns whether the given package name is in the list of non-blockable packages.
*/
- public boolean isNonblockablePackage(String packageName) {
- return mNonBlockablePkgs.contains(packageName);
+ public boolean isNonblockable(String packageName, String channelName) {
+ return mNonBlockablePkgs.contains(packageName)
+ || mNonBlockablePkgs.contains(makeChannelKey(packageName, channelName));
+ }
+
+ // Format must stay in sync with frameworks/base/core/res/res/values/config.xml
+ // config_nonBlockableNotificationPackages
+ private String makeChannelKey(String pkg, String channel) {
+ return pkg + ":" + channel;
}
@VisibleForTesting
@@ -157,4 +164,10 @@ public class NotificationBlockingHelperManager {
void setBlockingHelperRowForTest(ExpandableNotificationRow blockingHelperRowForTest) {
mBlockingHelperRow = blockingHelperRowForTest;
}
+
+ @VisibleForTesting
+ void setNonBlockablePkgs(String[] pkgsAndChannels) {
+ mNonBlockablePkgs = new HashSet<>();
+ Collections.addAll(mNonBlockablePkgs, pkgsAndChannels);
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
index 70dad198a5a8..a90ddf0a1b16 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationContentView.java
@@ -36,7 +36,7 @@ import android.widget.ImageView;
import android.widget.LinearLayout;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.HybridGroupManager;
@@ -1323,7 +1323,7 @@ public class NotificationContentView extends FrameLayout {
if (color == Notification.COLOR_DEFAULT) {
color = mContext.getColor(R.color.default_remote_input_background);
}
- existing.setBackgroundColor(NotificationColorUtil.ensureTextBackgroundColor(color,
+ existing.setBackgroundColor(ContrastColorUtil.ensureTextBackgroundColor(color,
mContext.getColor(R.color.remote_input_text_enabled),
mContext.getColor(R.color.remote_input_hint)));
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
index e24d65aeab78..1a645d19798a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationData.java
@@ -54,7 +54,7 @@ import android.widget.RemoteViews;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.statusbar.StatusBarIcon;
import com.android.internal.util.ArrayUtils;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.Dependency;
import com.android.systemui.ForegroundServiceController;
import com.android.systemui.statusbar.notification.InflationException;
@@ -254,7 +254,7 @@ public class NotificationData {
if (mCachedContrastColorIsFor == rawColor && mCachedContrastColor != COLOR_INVALID) {
return mCachedContrastColor;
}
- final int contrasted = NotificationColorUtil.resolveContrastColor(context, rawColor,
+ final int contrasted = ContrastColorUtil.resolveContrastColor(context, rawColor,
backgroundColor);
mCachedContrastColorIsFor = rawColor;
mCachedContrastColor = contrasted;
@@ -345,6 +345,7 @@ public class NotificationData {
private final ArrayMap<String, Entry> mEntries = new ArrayMap<>();
private final ArrayList<Entry> mSortedAndFiltered = new ArrayList<>();
+ private final ArrayList<Entry> mFilteredForUser = new ArrayList<>();
private NotificationGroupManager mGroupManager;
@@ -429,6 +430,23 @@ public class NotificationData {
return mSortedAndFiltered;
}
+ public ArrayList<Entry> getNotificationsForCurrentUser() {
+ mFilteredForUser.clear();
+
+ synchronized (mEntries) {
+ final int N = mEntries.size();
+ for (int i = 0; i < N; i++) {
+ Entry entry = mEntries.valueAt(i);
+ final StatusBarNotification sbn = entry.notification;
+ if (!mEnvironment.isNotificationForCurrentProfiles(sbn)) {
+ continue;
+ }
+ mFilteredForUser.add(entry);
+ }
+ }
+ return mFilteredForUser;
+ }
+
public Entry get(String key) {
return mEntries.get(key);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java
index 30fa0c20abfb..06f26c9cbc7c 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationEntryManager.java
@@ -681,10 +681,10 @@ public class NotificationEntryManager implements Dumpable, NotificationInflater.
}
public void updateNotificationsOnDensityOrFontScaleChanged() {
- ArrayList<NotificationData.Entry> activeNotifications =
- mNotificationData.getActiveNotifications();
- for (int i = 0; i < activeNotifications.size(); i++) {
- NotificationData.Entry entry = activeNotifications.get(i);
+ ArrayList<NotificationData.Entry> userNotifications =
+ mNotificationData.getNotificationsForCurrentUser();
+ for (int i = 0; i < userNotifications.size(); i++) {
+ NotificationData.Entry entry = userNotifications.get(i);
boolean exposedGuts = mGutsManager.getExposedGuts() != null
&& entry.row.getGuts() == mGutsManager.getExposedGuts();
entry.row.onDensityOrFontScaleChanged();
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java
index 1287ced8594c..7e397e8bdd35 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationLockscreenUserManager.java
@@ -16,6 +16,7 @@
package com.android.systemui.statusbar;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.Notification;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
@@ -111,7 +112,7 @@ public class NotificationLockscreenUserManager implements Dumpable {
} else if (Intent.ACTION_USER_PRESENT.equals(action)) {
try {
final int lastResumedActivityUserId =
- ActivityManager.getService().getLastResumedActivityUserId();
+ ActivityTaskManager.getService().getLastResumedActivityUserId();
if (mUserManager.isManagedProfile(lastResumedActivityUserId)) {
showForegroundManagedProfileActivityToast();
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
index fac77689e289..306319903ecb 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/NotificationShelf.java
@@ -482,8 +482,8 @@ public class NotificationShelf extends ActivatableNotificationView implements
iconTransformDistance = Math.min(iconTransformDistance, fullHeight);
if (isLastChild) {
fullHeight = Math.min(fullHeight, row.getMinHeight() - getIntrinsicHeight());
- iconTransformDistance = Math.min(iconTransformDistance,
- row.getMinHeight() - getIntrinsicHeight() * icon.getIconScale());
+ iconTransformDistance = Math.min(iconTransformDistance, row.getMinHeight()
+ - getIntrinsicHeight());
}
float viewEnd = viewStart + fullHeight;
if (expandingAnimated && mAmbientState.getScrollY() == 0
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
index c91e213978f9..c820e2b19366 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/StatusBarIconView.java
@@ -50,7 +50,7 @@ import android.view.accessibility.AccessibilityEvent;
import android.view.animation.Interpolator;
import com.android.internal.statusbar.StatusBarIcon;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.Interpolators;
import com.android.systemui.R;
import com.android.systemui.statusbar.notification.NotificationIconDozeHelper;
@@ -122,7 +122,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
private final boolean mBlocked;
private int mDensity;
private float mIconScale = 1.0f;
- private final Paint mDotPaint = new Paint();
+ private final Paint mDotPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private float mDotRadius;
private int mStaticDotRadius;
private int mVisibleState = STATE_ICON;
@@ -197,6 +197,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
mDarkAmount);
final int outerBounds = mStatusBarIconSize;
mIconScale = (float)imageBounds / (float)outerBounds;
+ updatePivot();
}
private void updateIconScaleForSystemIcons() {
@@ -425,13 +426,12 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
}
if (mDotAppearAmount != 0.0f) {
float radius;
- float alpha;
+ float alpha = Color.alpha(mDecorColor) / 255.f;
if (mDotAppearAmount <= 1.0f) {
radius = mDotRadius * mDotAppearAmount;
- alpha = 1.0f;
} else {
float fadeOutAmount = mDotAppearAmount - 1.0f;
- alpha = 1.0f - fadeOutAmount;
+ alpha = alpha * (1.0f - fadeOutAmount);
radius = NotificationUtils.interpolate(mDotRadius, getWidth() / 4, fadeOutAmount);
}
mDotPaint.setAlpha((int) (alpha * 255));
@@ -652,7 +652,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
}
// We'll modify the color if it doesn't pass GAR
int contrastedColor = mDrawableColor;
- if (!NotificationColorUtil.satisfiesTextContrast(mCachedContrastBackgroundColor,
+ if (!ContrastColorUtil.satisfiesTextContrast(mCachedContrastBackgroundColor,
contrastedColor)) {
float[] hsl = new float[3];
ColorUtils.colorToHSL(mDrawableColor, hsl);
@@ -661,7 +661,7 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
if (hsl[1] < 0.2f) {
contrastedColor = Notification.COLOR_DEFAULT;
}
- contrastedColor = NotificationColorUtil.resolveContrastColor(mContext,
+ contrastedColor = ContrastColorUtil.resolveContrastColor(mContext,
contrastedColor, mCachedContrastBackgroundColor);
}
mContrastedDrawableColor = contrastedColor;
@@ -860,6 +860,12 @@ public class StatusBarIconView extends AnimatedImageView implements StatusIconDi
mLayoutRunnable.run();
mLayoutRunnable = null;
}
+ updatePivot();
+ }
+
+ private void updatePivot() {
+ setPivotX((1 - mIconScale) / 2.0f * getWidth());
+ setPivotY((getHeight() - mIconScale * getWidth()) / 2.0f);
}
public void executeOnLayout(Runnable runnable) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
index 83021ca51a55..288b473461e0 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/CarStatusBar.java
@@ -17,6 +17,7 @@
package com.android.systemui.statusbar.car;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.os.SystemProperties;
@@ -452,7 +453,7 @@ public class CarStatusBar extends StatusBar implements
public void onTaskStackChanged() {
try {
mCarFacetButtonController.taskChanged(
- ActivityManager.getService().getAllStackInfos());
+ ActivityTaskManager.getService().getAllStackInfos());
} catch (Exception e) {
Log.e(TAG, "Getting StackInfo from activity manager failed", e);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java b/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
index a6bf82136039..d720aef3a138 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/car/FullscreenUserSwitcher.java
@@ -19,6 +19,8 @@ package com.android.systemui.statusbar.car;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.content.Context;
+import android.content.pm.UserInfo;
+import android.util.Log;
import android.view.View;
import android.view.ViewStub;
@@ -60,6 +62,11 @@ public class FullscreenUserSwitcher {
}
public void show() {
+ // On a switch from the system user, don't show the user switcher
+ if (mUserManagerHelper.isHeadlessSystemUser() && mUserManagerHelper
+ .userIsSystemUser(mUserManagerHelper.getForegroundUserInfo())) {
+ return;
+ }
if (mShowing) {
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java
index 535ec076aa3b..8c0d70062eb1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/MediaNotificationProcessor.java
@@ -27,7 +27,7 @@ import androidx.annotation.VisibleForTesting;
import androidx.palette.graphics.Palette;
import android.util.LayoutDirection;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.R;
import java.util.List;
@@ -155,7 +155,7 @@ public class MediaNotificationProcessor {
}
private int selectForegroundColor(int backgroundColor, Palette palette) {
- if (NotificationColorUtil.isColorLight(backgroundColor)) {
+ if (ContrastColorUtil.isColorLight(backgroundColor)) {
return selectForegroundColorForSwatches(palette.getDarkVibrantSwatch(),
palette.getVibrantSwatch(),
palette.getDarkMutedSwatch(),
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
index 91a4dda5a281..d4b0be89aedd 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationTemplateViewWrapper.java
@@ -31,7 +31,7 @@ import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.TextView;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.internal.widget.NotificationActionListLayout;
import com.android.systemui.Dependency;
import com.android.systemui.R;
@@ -210,7 +210,7 @@ public class NotificationTemplateViewWrapper extends NotificationHeaderViewWrapp
private int blendColorWithBackground(int color, float alpha) {
// alpha doesn't go well for color filters, so let's blend it manually
- return NotificationColorUtil.compositeColors(Color.argb((int) (alpha * 255),
+ return ContrastColorUtil.compositeColors(Color.argb((int) (alpha * 255),
Color.red(color), Color.green(color), Color.blue(color)), resolveBackgroundColor());
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationUtils.java b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationUtils.java
index 7e2336c4454b..66ba9e9fc928 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationUtils.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/notification/NotificationUtils.java
@@ -18,14 +18,11 @@ package com.android.systemui.statusbar.notification;
import android.content.Context;
import android.graphics.Color;
-import android.os.UserHandle;
-import android.provider.Settings;
import android.view.View;
import android.widget.ImageView;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.R;
-import com.android.systemui.statusbar.stack.NotificationChildrenContainer;
/**
* A util class for various reusable functions
@@ -33,7 +30,7 @@ import com.android.systemui.statusbar.stack.NotificationChildrenContainer;
public class NotificationUtils {
private static final int[] sLocationBase = new int[2];
private static final int[] sLocationOffset = new int[2];
- public static boolean isGrayscale(ImageView v, NotificationColorUtil colorUtil) {
+ public static boolean isGrayscale(ImageView v, ContrastColorUtil colorUtil) {
Object isGrayscale = v.getTag(R.id.icon_is_grayscale);
if (isGrayscale != null) {
return Boolean.TRUE.equals(isGrayscale);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java
index 76860e62435a..f0b1a82cfc2f 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/FingerprintUnlockController.java
@@ -403,10 +403,19 @@ public class FingerprintUnlockController extends KeyguardUpdateMonitorCallback {
pw.print(" mWakeLock="); pw.println(mWakeLock);
}
+ /**
+ * Successful authentication with fingerprint that wakes up the device.
+ */
public boolean isWakeAndUnlock() {
- return mMode == MODE_UNLOCK
- || mMode == MODE_WAKE_AND_UNLOCK
+ return mMode == MODE_WAKE_AND_UNLOCK
|| mMode == MODE_WAKE_AND_UNLOCK_PULSING
|| mMode == MODE_WAKE_AND_UNLOCK_FROM_DREAM;
}
+
+ /**
+ * Successful authentication with fingerprint when the screen was either on or off.
+ */
+ public boolean isFingerprintUnlock() {
+ return isWakeAndUnlock() || mMode == MODE_UNLOCK;
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
index a4bf6ea3b224..0a26e7345717 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/HeadsUpManagerPhone.java
@@ -22,14 +22,21 @@ import android.content.Context;
import android.content.res.Configuration;
import android.content.res.Resources;
import androidx.collection.ArraySet;
+import android.graphics.Rect;
+import android.graphics.Region;
+import android.graphics.Region.Op;
import android.util.Log;
import android.util.Pools;
+import android.view.DisplayCutout;
+import android.view.Gravity;
import android.view.View;
import android.view.ViewTreeObserver;
+import android.view.ViewTreeObserver.InternalInsetsInfo;
import com.android.internal.annotations.VisibleForTesting;
import com.android.systemui.Dumpable;
import com.android.systemui.R;
+import com.android.systemui.ScreenDecorations;
import com.android.systemui.statusbar.ExpandableNotificationRow;
import com.android.systemui.statusbar.NotificationData;
import com.android.systemui.statusbar.StatusBarState;
@@ -41,6 +48,7 @@ import com.android.systemui.statusbar.policy.OnHeadsUpChangedListener;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.HashSet;
+import java.util.List;
import java.util.Stack;
/**
@@ -60,6 +68,7 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
private int mStatusBarHeight;
private int mHeadsUpInset;
+ private int mDisplayCutoutTouchableRegionSize;
private boolean mTrackingHeadsUp;
private HashSet<String> mSwipedOutKeys = new HashSet<>();
private HashSet<NotificationData.Entry> mEntriesToRemoveAfterExpand = new HashSet<>();
@@ -120,6 +129,8 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
com.android.internal.R.dimen.status_bar_height);
mHeadsUpInset = mStatusBarHeight + resources.getDimensionPixelSize(
R.dimen.heads_up_status_bar_padding);
+ mDisplayCutoutTouchableRegionSize = resources.getDimensionPixelSize(
+ R.dimen.display_cutout_touchable_region_size);
}
@Override
@@ -128,6 +139,11 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
initResources();
}
+ @Override
+ public void onOverlayChanged() {
+ initResources();
+ }
+
///////////////////////////////////////////////////////////////////////////////////////////////
// Public methods:
@@ -301,12 +317,32 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
info.touchableRegion.set(minX, 0, maxX, mHeadsUpInset + height);
- } else if (mHeadsUpGoingAway || mWaitingOnCollapseWhenGoingAway) {
- info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
- info.touchableRegion.set(0, 0, mStatusBarWindowView.getWidth(), mStatusBarHeight);
+ } else {
+ setCollapsedTouchableInsets(info);
}
}
+ private void setCollapsedTouchableInsets(ViewTreeObserver.InternalInsetsInfo info) {
+ info.setTouchableInsets(ViewTreeObserver.InternalInsetsInfo.TOUCHABLE_INSETS_REGION);
+ info.touchableRegion.set(0, 0, mStatusBarWindowView.getWidth(), mStatusBarHeight);
+ updateRegionForNotch(info.touchableRegion);
+ }
+
+ private void updateRegionForNotch(Region region) {
+ DisplayCutout cutout = mStatusBarWindowView.getRootWindowInsets().getDisplayCutout();
+ if (cutout == null) {
+ return;
+ }
+
+ // Expand touchable region such that we also catch touches that just start below the notch
+ // area.
+ Region bounds = ScreenDecorations.DisplayCutoutView.boundsFromDirection(
+ cutout, Gravity.TOP);
+ bounds.translate(0, mDisplayCutoutTouchableRegionSize);
+ region.op(bounds, Op.UNION);
+ bounds.recycle();
+ }
+
@Override
public void onConfigChanged(Configuration newConfig) {
Resources resources = mContext.getResources();
@@ -403,7 +439,8 @@ public class HeadsUpManagerPhone extends HeadsUpManager implements Dumpable,
private void updateTouchableRegionListener() {
boolean shouldObserve = hasPinnedHeadsUp() || mHeadsUpGoingAway
- || mWaitingOnCollapseWhenGoingAway;
+ || mWaitingOnCollapseWhenGoingAway
+ || mStatusBarWindowView.getRootWindowInsets().getDisplayCutout() != null;
if (shouldObserve == mIsObserving) {
return;
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
index 0716b37ff8d9..3b120511ea1e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardBottomAreaView.java
@@ -26,6 +26,7 @@ import static com.android.systemui.tuner.LockscreenFragment.LOCKSCREEN_RIGHT_UNL
import android.app.ActivityManager;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.app.admin.DevicePolicyManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
@@ -523,7 +524,7 @@ public class KeyguardBottomAreaView extends FrameLayout implements View.OnClickL
o.setRotationAnimationHint(
WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS);
try {
- result = ActivityManager.getService().startActivityAsUser(
+ result = ActivityTaskManager.getService().startActivityAsUser(
null, getContext().getBasePackageName(),
intent,
intent.resolveTypeIfNeeded(getContext().getContentResolver()),
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
index e096f3f39487..e47dcea1006d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/KeyguardStatusBarView.java
@@ -57,6 +57,9 @@ import com.android.systemui.statusbar.policy.UserInfoController.OnUserInfoChange
import com.android.systemui.statusbar.policy.UserInfoControllerImpl;
import com.android.systemui.statusbar.policy.UserSwitcherController;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
/**
* The header group on Keyguard.
*/
@@ -458,4 +461,15 @@ public class KeyguardStatusBarView extends RelativeLayout
((DarkReceiver) v).onDarkChanged(tintArea, intensity, color);
}
}
+
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ pw.println("KeyguardStatusBarView:");
+ pw.println(" mBatteryCharging: " + mBatteryCharging);
+ pw.println(" mKeyguardUserSwitcherShowing: " + mKeyguardUserSwitcherShowing);
+ pw.println(" mBatteryListening: " + mBatteryListening);
+ pw.println(" mLayoutState: " + mLayoutState);
+ if (mBatteryView != null) {
+ mBatteryView.dump(fd, pw, args);
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
index f9a540c7b0ca..1003833f003a 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarFragment.java
@@ -35,8 +35,10 @@ import android.annotation.IdRes;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManagerNative;
+import android.app.ActivityTaskManager;
import android.app.Fragment;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.StatusBarManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
@@ -879,7 +881,7 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
private boolean onLongPressNavigationButtons(View v, @IdRes int btnId1, @IdRes int btnId2) {
try {
boolean sendBackLongPress = false;
- IActivityManager activityManager = ActivityManagerNative.getDefault();
+ IActivityTaskManager activityManager = ActivityTaskManager.getService();
boolean touchExplorationEnabled = mAccessibilityManager.isTouchExplorationEnabled();
boolean inLockTaskMode = activityManager.isInLockTaskMode();
if (inLockTaskMode && !touchExplorationEnabled) {
@@ -933,7 +935,7 @@ public class NavigationBarFragment extends Fragment implements Callbacks {
}
private boolean onLongPressRecents() {
- if (mRecents == null || !ActivityManager.supportsMultiWindow(getContext())
+ if (mRecents == null || !ActivityTaskManager.supportsMultiWindow(getContext())
|| !mDivider.getView().getSnapAlgorithm().isSplitScreenFeasible()
|| Recents.getConfiguration().isLowRamDevice
// If we are connected to the overview service, then disable the recents button
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
index 18e8775de21f..dce7537be61e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NavigationBarGestureHelper.java
@@ -16,6 +16,8 @@
package com.android.systemui.statusbar.phone;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.view.WindowManager.DOCKED_INVALID;
import static android.view.WindowManager.DOCKED_LEFT;
import static android.view.WindowManager.DOCKED_TOP;
@@ -216,7 +218,7 @@ public class NavigationBarGestureHelper implements TunerService.Tunable, Gesture
&& mDivider.getView().getWindowManagerProxy().getDockSide() == DOCKED_INVALID) {
Rect initialBounds = null;
int dragMode = calculateDragMode();
- int createMode = ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+ int createMode = SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
if (dragMode == DRAG_MODE_DIVIDER) {
initialBounds = new Rect();
mDivider.getView().calculateBoundsForPosition(mIsVertical
@@ -228,7 +230,7 @@ public class NavigationBarGestureHelper implements TunerService.Tunable, Gesture
initialBounds);
} else if (dragMode == DRAG_MODE_RECENTS && mTouchDownX
< mContext.getResources().getDisplayMetrics().widthPixels / 2) {
- createMode = ActivityManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
+ createMode = SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
}
boolean docked = mRecentsComponent.splitPrimaryTask(dragMode, createMode,
initialBounds, MetricsEvent.ACTION_WINDOW_DOCK_SWIPE);
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
index a78dd25ecab2..d859b5c77fac 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationIconAreaController.java
@@ -11,7 +11,7 @@ import android.view.View;
import android.widget.FrameLayout;
import com.android.internal.statusbar.StatusBarIcon;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.Dependency;
import com.android.systemui.R;
import com.android.systemui.statusbar.ExpandableNotificationRow;
@@ -32,7 +32,7 @@ import java.util.function.Function;
* normally reserved for notifications.
*/
public class NotificationIconAreaController implements DarkReceiver {
- private final NotificationColorUtil mNotificationColorUtil;
+ private final ContrastColorUtil mContrastColorUtil;
private final NotificationEntryManager mEntryManager;
private final Runnable mUpdateStatusBarIcons = this::updateStatusBarIcons;
@@ -50,7 +50,7 @@ public class NotificationIconAreaController implements DarkReceiver {
public NotificationIconAreaController(Context context, StatusBar statusBar) {
mStatusBar = statusBar;
- mNotificationColorUtil = NotificationColorUtil.getInstance(context);
+ mContrastColorUtil = ContrastColorUtil.getInstance(context);
mContext = context;
mEntryManager = Dependency.get(NotificationEntryManager.class);
@@ -312,7 +312,7 @@ public class NotificationIconAreaController implements DarkReceiver {
private void updateTintForIcon(StatusBarIconView v) {
boolean isPreL = Boolean.TRUE.equals(v.getTag(R.id.icon_is_pre_L));
int color = StatusBarIconView.NO_COLOR;
- boolean colorize = !isPreL || NotificationUtils.isGrayscale(v, mNotificationColorUtil);
+ boolean colorize = !isPreL || NotificationUtils.isGrayscale(v, mContrastColorUtil);
if (colorize) {
color = DarkIconDispatcher.getTint(mTintArea, v, mIconTint);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
index 2f18aad9612d..3ad207ae265e 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/NotificationPanelView.java
@@ -77,6 +77,8 @@ import com.android.systemui.statusbar.stack.AnimationProperties;
import com.android.systemui.statusbar.stack.NotificationStackScrollLayout;
import com.android.systemui.statusbar.stack.StackStateAnimator;
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Consumer;
@@ -2827,4 +2829,12 @@ public class NotificationPanelView extends PanelView implements
setKeyguardStatusViewVisibility(mStatusBarState, true /* keyguardFadingAway */,
false /* goingToFullShade */);
}
+
+ @Override
+ public void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ super.dump(fd, pw, args);
+ if (mKeyguardStatusBar != null) {
+ mKeyguardStatusBar.dump(fd, pw, args);
+ }
+ }
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
index e9c0f5d8afb1..57e01e7cd4f6 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/PhoneStatusBarPolicy.java
@@ -23,6 +23,7 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECOND
import android.app.ActivityManager;
import android.app.ActivityManager.StackInfo;
+import android.app.ActivityTaskManager;
import android.app.AlarmManager;
import android.app.AlarmManager.AlarmClockInfo;
import android.app.AppGlobals;
@@ -505,7 +506,7 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks,
mUiOffloadThread.submit(() -> {
final int userId;
try {
- userId = ActivityManager.getService().getLastResumedActivityUserId();
+ userId = ActivityTaskManager.getService().getLastResumedActivityUserId();
boolean isManagedProfile = mUserManager.isManagedProfile(userId);
mHandler.post(() -> {
final boolean showIcon;
@@ -536,7 +537,8 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks,
mCurrentNotifs.clear();
mUiOffloadThread.submit(() -> {
try {
- final StackInfo focusedStack = ActivityManager.getService().getFocusedStackInfo();
+ final StackInfo focusedStack =
+ ActivityTaskManager.getService().getFocusedStackInfo();
if (focusedStack != null) {
final int windowingMode =
focusedStack.configuration.windowConfiguration.getWindowingMode();
@@ -562,7 +564,7 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks,
ArraySet<Pair<String, Integer>> notifs, NotificationManager noMan, IPackageManager pm) {
try {
final StackInfo info =
- ActivityManager.getService().getStackInfo(windowingMode, activityType);
+ ActivityTaskManager.getService().getStackInfo(windowingMode, activityType);
checkStack(info, notifs, noMan, pm);
} catch (RemoteException e) {
e.rethrowFromSystemServer();
@@ -625,7 +627,6 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks,
.putExtra(Intent.EXTRA_PACKAGE_NAME, appInfo.packageName)
.putExtra(Intent.EXTRA_VERSION_CODE, (int) (appInfo.versionCode & 0x7fffffff))
.putExtra(Intent.EXTRA_LONG_VERSION_CODE, appInfo.versionCode)
- .putExtra(Intent.EXTRA_EPHEMERAL_FAILURE, pendingIntent)
.putExtra(Intent.EXTRA_INSTANT_APP_FAILURE, pendingIntent);
PendingIntent webPendingIntent = PendingIntent.getActivity(mContext, 0, goToWebIntent, 0);
@@ -652,7 +653,7 @@ public class PhoneStatusBarPolicy implements Callback, Callbacks,
private Intent getTaskIntent(int taskId, int userId) {
try {
final List<ActivityManager.RecentTaskInfo> tasks =
- ActivityManager.getService().getRecentTasks(
+ ActivityTaskManager.getService().getRecentTasks(
NUM_TASKS_FOR_INSTANT_APP_INFO, 0, userId).getList();
for (int i = 0; i < tasks.size(); i++) {
if (tasks.get(i).id == taskId) {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
index 08a20552f993..de499d63b91d 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/ScrimController.java
@@ -896,6 +896,7 @@ public class ScrimController implements ViewTreeObserver.OnPreDrawListener, OnCo
public void setKeyguardOccluded(boolean keyguardOccluded) {
mKeyguardOccluded = keyguardOccluded;
+ updateScrims();
}
public interface Callback {
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
index 4b97e22b797d..a80673faeb72 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBar.java
@@ -16,6 +16,8 @@
package com.android.systemui.statusbar.phone;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.app.StatusBarManager.WINDOW_STATE_HIDDEN;
import static android.app.StatusBarManager.WINDOW_STATE_SHOWING;
import static android.app.StatusBarManager.windowStateToString;
@@ -44,6 +46,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.app.AlarmManager;
import android.app.IWallpaperManager;
import android.app.KeyguardManager;
@@ -607,6 +610,12 @@ public class StatusBar extends SystemUI implements DemoMode,
maybeEscalateHeadsUp();
}
}
+
+ @Override
+ public void onStrongAuthStateChanged(int userId) {
+ super.onStrongAuthStateChanged(userId);
+ mEntryManager.updateNotifications();
+ }
};
private NavigationBarFragment mNavigationBar;
@@ -1122,6 +1131,8 @@ public class StatusBar extends SystemUI implements DemoMode,
mNotificationIconAreaController.onDensityOrFontScaleChanged(mContext);
mHeadsUpManager.onDensityOrFontScaleChanged();
+ inflateFooterView();
+ inflateEmptyShadeView();
reevaluateStyles();
}
@@ -1150,10 +1161,8 @@ public class StatusBar extends SystemUI implements DemoMode,
}
}
- protected void reevaluateStyles() {
- inflateFooterView();
+ private void reevaluateStyles() {
updateFooter();
- inflateEmptyShadeView();
updateEmptyShadeView();
}
@@ -1174,7 +1183,8 @@ public class StatusBar extends SystemUI implements DemoMode,
mStackScroller.setEmptyShadeView(mEmptyShadeView);
}
- private void inflateFooterView() {
+ @VisibleForTesting
+ protected void inflateFooterView() {
if (mStackScroller == null) {
return;
}
@@ -1352,8 +1362,8 @@ public class StatusBar extends SystemUI implements DemoMode,
return false;
}
int createMode = navbarPos == NAV_BAR_POS_LEFT
- ? ActivityManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT
- : ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+ ? SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT
+ : SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
return mRecents.splitPrimaryTask(NavigationBarGestureHelper.DRAG_MODE_NONE, createMode,
null, metricsDockAction);
} else {
@@ -1599,7 +1609,9 @@ public class StatusBar extends SystemUI implements DemoMode,
return; // called too early
}
- if (mLaunchTransitionFadingAway) {
+ boolean wakeAndUnlock = mFingerprintUnlockController != null
+ && mFingerprintUnlockController.isWakeAndUnlock();
+ if (mLaunchTransitionFadingAway || wakeAndUnlock) {
mBackdrop.setVisibility(View.INVISIBLE);
Trace.endSection();
return;
@@ -2949,7 +2961,7 @@ public class StatusBar extends SystemUI implements DemoMode,
WindowManager.LayoutParams.ROTATION_ANIMATION_SEAMLESS);
}
try {
- result = ActivityManager.getService().startActivityAsUser(
+ result = ActivityTaskManager.getService().startActivityAsUser(
null, mContext.getBasePackageName(),
intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
@@ -4715,11 +4727,11 @@ public class StatusBar extends SystemUI implements DemoMode,
// We don't want to end up in KEYGUARD state when we're unlocking with
// fingerprint from doze. We should cross fade directly from black.
- final boolean wakeAndUnlocking = mFingerprintUnlockController.getMode()
- == FingerprintUnlockController.MODE_WAKE_AND_UNLOCK;
+ boolean wakeAndUnlocking = mFingerprintUnlockController.isWakeAndUnlock();
// Do not animate the scrim expansion when triggered by the fingerprint sensor.
- mScrimController.setExpansionAffectsAlpha(!mFingerprintUnlockController.isWakeAndUnlock());
+ mScrimController.setExpansionAffectsAlpha(
+ !mFingerprintUnlockController.isFingerprintUnlock());
if (mBouncerShowing) {
// Bouncer needs the front scrim when it's on top of an activity,
@@ -5145,7 +5157,7 @@ public class StatusBar extends SystemUI implements DemoMode,
row, wasOccluded);
try {
if (adapter != null) {
- ActivityManager.getService()
+ ActivityTaskManager.getService()
.registerRemoteAnimationForNextActivityStart(
intent.getCreatorPackage(), adapter);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
index fe863789ee96..914bba28a5ae 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManager.java
@@ -174,7 +174,7 @@ public class StatusBarKeyguardViewManager implements RemoteInputController.Callb
|| mStatusBar.isFullScreenUserSwitcherState()) {
mBouncer.setExpansion(KeyguardBouncer.EXPANSION_VISIBLE);
} else if (mShowing && !mDozing) {
- if (!isWakeAndUnlocking()) {
+ if (!isWakeAndUnlocking() && !mStatusBar.isInLaunchTransition()) {
mBouncer.setExpansion(expansion);
}
if (expansion != KeyguardBouncer.EXPANSION_HIDDEN && tracking
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
index a79a41b07797..0390f60843d1 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/phone/StatusBarWindowView.java
@@ -94,6 +94,12 @@ public class StatusBarWindowView extends FrameLayout {
private boolean mExpandAnimationRunning;
private boolean mExpandAnimationPending;
+ /**
+ * If set to true, the current gesture started below the notch and we need to dispatch touch
+ * events manually as it's outside of the regular view bounds.
+ */
+ private boolean mExpandingBelowNotch;
+
public StatusBarWindowView(Context context, AttributeSet attrs) {
super(context, attrs);
setMotionEventSplittingEnabled(false);
@@ -258,7 +264,16 @@ public class StatusBarWindowView extends FrameLayout {
@Override
public boolean dispatchTouchEvent(MotionEvent ev) {
boolean isDown = ev.getActionMasked() == MotionEvent.ACTION_DOWN;
+ boolean isUp = ev.getActionMasked() == MotionEvent.ACTION_UP;
boolean isCancel = ev.getActionMasked() == MotionEvent.ACTION_CANCEL;
+
+ // Reset manual touch dispatch state here but make sure the UP/CANCEL event still gets
+ // delivered.
+ boolean expandingBelowNotch = mExpandingBelowNotch;
+ if (isUp || isCancel) {
+ mExpandingBelowNotch = false;
+ }
+
if (!isCancel && mService.shouldIgnoreTouch()) {
return false;
}
@@ -291,6 +306,17 @@ public class StatusBarWindowView extends FrameLayout {
mService.mDozeScrimController.extendPulse();
}
+ // In case we start outside of the view bounds (below the status bar), we need to dispatch
+ // the touch manually as the view system can't accomodate for touches outside of the
+ // regular view bounds.
+ if (isDown && ev.getY() >= mBottom) {
+ mExpandingBelowNotch = true;
+ expandingBelowNotch = true;
+ }
+ if (expandingBelowNotch) {
+ return mNotificationPanel.dispatchTouchEvent(ev);
+ }
+
return super.dispatchTouchEvent(ev);
}
diff --git a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
index 924aa0120c94..cda9d0416653 100644
--- a/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
+++ b/packages/SystemUI/src/com/android/systemui/statusbar/policy/SmartReplyView.java
@@ -27,7 +27,7 @@ import android.view.accessibility.AccessibilityNodeInfo.AccessibilityAction;
import android.widget.Button;
import com.android.internal.annotations.VisibleForTesting;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.keyguard.KeyguardHostView.OnDismissAction;
import com.android.systemui.Dependency;
import com.android.systemui.R;
@@ -114,7 +114,7 @@ public class SmartReplyView extends ViewGroup {
mRippleColor = mContext.getColor(R.color.notification_ripple_untinted_color);
mRippleColorDarkBg = Color.argb(Color.alpha(mRippleColor),
255 /* red */, 255 /* green */, 255 /* blue */);
- mMinStrokeContrast = NotificationColorUtil.calculateContrast(mDefaultStrokeColor,
+ mMinStrokeContrast = ContrastColorUtil.calculateContrast(mDefaultStrokeColor,
mDefaultBackgroundColor);
int spacing = 0;
@@ -574,12 +574,12 @@ public class SmartReplyView extends ViewGroup {
}
mCurrentBackgroundColor = backgroundColor;
- final boolean dark = !NotificationColorUtil.isColorLight(backgroundColor);
+ final boolean dark = !ContrastColorUtil.isColorLight(backgroundColor);
- int textColor = NotificationColorUtil.ensureTextContrast(
+ int textColor = ContrastColorUtil.ensureTextContrast(
dark ? mDefaultTextColorDarkBg : mDefaultTextColor,
backgroundColor | 0xff000000, dark);
- int strokeColor = NotificationColorUtil.ensureContrast(
+ int strokeColor = ContrastColorUtil.ensureContrast(
mDefaultStrokeColor, backgroundColor | 0xff000000, dark, mMinStrokeContrast);
int rippleColor = dark ? mRippleColorDarkBg : mRippleColor;
diff --git a/packages/SystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java b/packages/SystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
index bf962b818997..d7fad67c7f09 100644
--- a/packages/SystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
+++ b/packages/SystemUI/src/com/android/systemui/volume/CarVolumeDialogImpl.java
@@ -38,6 +38,7 @@ import android.graphics.drawable.ColorDrawable;
import android.graphics.PixelFormat;
import android.graphics.drawable.Drawable;
import android.media.AudioAttributes;
+import android.media.AudioManager;
import android.os.Debug;
import android.os.Handler;
import android.os.IBinder;
@@ -527,7 +528,7 @@ public class CarVolumeDialogImpl implements VolumeDialog {
private final ICarVolumeCallback mVolumeChangeCallback = new ICarVolumeCallback.Stub() {
@Override
- public void onGroupVolumeChanged(int groupId) {
+ public void onGroupVolumeChanged(int groupId, int flags) {
VolumeItem volumeItem = mAvailableVolumeItems.get(groupId);
int value = getSeekbarValue(mCarAudioManager, groupId);
// Do not update the progress if it is the same as before. When car audio manager sets its
@@ -536,12 +537,14 @@ public class CarVolumeDialogImpl implements VolumeDialog {
if (value != volumeItem.progress) {
volumeItem.listItem.setProgress(value);
volumeItem.progress = value;
- show(Events.SHOW_REASON_VOLUME_CHANGED);
+ if ((flags & AudioManager.FLAG_SHOW_UI) != 0) {
+ show(Events.SHOW_REASON_VOLUME_CHANGED);
+ }
}
}
@Override
- public void onMasterMuteChanged() {
+ public void onMasterMuteChanged(int flags) {
// ignored
}
};
diff --git a/packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java
index cf32760dc803..f8aa28dbb945 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/keyguard/WorkLockActivityControllerTest.java
@@ -27,7 +27,7 @@ import static org.mockito.Matchers.argThat;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityOptions;
-import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.IApplicationThread;
import android.app.ProfilerInfo;
import android.content.ComponentName;
@@ -62,7 +62,7 @@ public class WorkLockActivityControllerTest extends SysuiTestCase {
private @Mock Context mContext;
private @Mock ActivityManagerWrapper mActivityManager;
- private @Mock IActivityManager mIActivityManager;
+ private @Mock IActivityTaskManager mIActivityTaskManager;
private WorkLockActivityController mController;
private SysUiTaskStackChangeListener mTaskStackListener;
@@ -77,7 +77,8 @@ public class WorkLockActivityControllerTest extends SysuiTestCase {
// Construct controller. Save the TaskStackListener for injecting events.
final ArgumentCaptor<SysUiTaskStackChangeListener> listenerCaptor =
ArgumentCaptor.forClass(SysUiTaskStackChangeListener.class);
- mController = new WorkLockActivityController(mContext, mActivityManager, mIActivityManager);
+ mController = new WorkLockActivityController(mContext, mActivityManager,
+ mIActivityTaskManager);
verify(mActivityManager).registerTaskStackListener(listenerCaptor.capture());
mTaskStackListener = listenerCaptor.getValue();
@@ -93,7 +94,7 @@ public class WorkLockActivityControllerTest extends SysuiTestCase {
// The overlay should start and the task the activity started in should not be removed.
verifyStartActivity(TASK_ID, true /*taskOverlay*/);
- verify(mIActivityManager, never()).removeTask(anyInt() /*taskId*/);
+ verify(mIActivityTaskManager, never()).removeTask(anyInt() /*taskId*/);
}
@Test
@@ -107,14 +108,14 @@ public class WorkLockActivityControllerTest extends SysuiTestCase {
// The task the activity started in should be removed to prevent the locked task from
// being shown.
verifyStartActivity(TASK_ID, true /*taskOverlay*/);
- verify(mIActivityManager).removeTask(TASK_ID);
+ verify(mIActivityTaskManager).removeTask(TASK_ID);
}
// End of tests, start of helpers
// ------------------------------
private void setActivityStartCode(int taskId, boolean taskOverlay, int code) throws Exception {
- doReturn(code).when(mIActivityManager).startActivityAsUser(
+ doReturn(code).when(mIActivityTaskManager).startActivityAsUser(
eq((IApplicationThread) null),
eq((String) null),
any(Intent.class),
@@ -129,7 +130,7 @@ public class WorkLockActivityControllerTest extends SysuiTestCase {
}
private void verifyStartActivity(int taskId, boolean taskOverlay) throws Exception {
- verify(mIActivityManager).startActivityAsUser(
+ verify(mIActivityTaskManager).startActivityAsUser(
eq((IApplicationThread) null),
eq((String) null),
any(Intent.class),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/recents/RecentsTest.java b/packages/SystemUI/tests/src/com/android/systemui/recents/RecentsTest.java
index bdbd24418d3f..2160f9a2ac0f 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/recents/RecentsTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/recents/RecentsTest.java
@@ -23,9 +23,9 @@ import static com.android.systemui.recents.RecentsImpl.RECENTS_PACKAGE;
import static org.junit.Assert.fail;
-import android.app.ActivityManager;
import android.app.ActivityManager.RunningTaskInfo;
-import android.app.IActivityManager;
+import android.app.ActivityTaskManager;
+import android.app.IActivityTaskManager;
import android.os.SystemClock;
import android.support.test.filters.MediumTest;
import android.support.test.runner.AndroidJUnit4;
@@ -44,8 +44,8 @@ public class RecentsTest extends SysuiTestCase {
@Test
public void testRecentsActivityType() throws Exception {
// Clear the state
- final IActivityManager am = ActivityManager.getService();
- am.removeStacksWithActivityTypes(new int[] { ACTIVITY_TYPE_RECENTS });
+ final IActivityTaskManager atm = ActivityTaskManager.getService();
+ atm.removeStacksWithActivityTypes(new int[] { ACTIVITY_TYPE_RECENTS });
// Toggle recents, use a shell command because it is not exported
runShellCommand("am start -n " + RECENTS_PACKAGE + "/" + RECENTS_ACTIVITY);
@@ -53,7 +53,7 @@ public class RecentsTest extends SysuiTestCase {
// Verify that an activity was launched with the right activity type
int retryCount = 0;
while (retryCount < 10) {
- List<RunningTaskInfo> tasks = am.getTasks(Integer.MAX_VALUE);
+ List<RunningTaskInfo> tasks = atm.getTasks(Integer.MAX_VALUE);
for (RunningTaskInfo info : tasks) {
if (info.configuration.windowConfiguration.getActivityType()
== ACTIVITY_TYPE_RECENTS) {
@@ -66,4 +66,4 @@ public class RecentsTest extends SysuiTestCase {
}
fail("Expected Recents activity with ACTIVITY_TYPE_RECENTS");
}
-} \ No newline at end of file
+}
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationBlockingHelperManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationBlockingHelperManagerTest.java
index 9638541ead42..43660328e783 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationBlockingHelperManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationBlockingHelperManagerTest.java
@@ -147,6 +147,7 @@ public class NotificationBlockingHelperManagerTest extends SysuiTestCase {
// of the child row.
ExpandableNotificationRow childRow = groupRow.getChildrenContainer().getViewAtPosition(0);
childRow.getEntry().userSentiment = USER_SENTIMENT_NEGATIVE;
+ assertFalse(childRow.getIsNonblockable());
assertTrue(mBlockingHelperManager.perhapsShowBlockingHelper(childRow, mMenuRow));
@@ -220,6 +221,24 @@ public class NotificationBlockingHelperManagerTest extends SysuiTestCase {
verify(mEntryManager).updateNotifications();
}
+ @Test
+ public void testNonBlockable_package() {
+ mBlockingHelperManager.setNonBlockablePkgs(new String[] {"banana", "strawberry:pie"});
+
+ assertFalse(mBlockingHelperManager.isNonblockable("orange", "pie"));
+
+ assertTrue(mBlockingHelperManager.isNonblockable("banana", "pie"));
+ }
+
+ @Test
+ public void testNonBlockable_channel() {
+ mBlockingHelperManager.setNonBlockablePkgs(new String[] {"banana", "strawberry:pie"});
+
+ assertFalse(mBlockingHelperManager.isNonblockable("strawberry", "shortcake"));
+
+ assertTrue(mBlockingHelperManager.isNonblockable("strawberry", "pie"));
+ }
+
private ExpandableNotificationRow createBlockableRowSpy() throws Exception {
ExpandableNotificationRow row = spy(mHelper.createRow());
when(row.getIsNonblockable()).thenReturn(false);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java
index 609e032c10d6..77522e44b183 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationDataTest.java
@@ -46,7 +46,6 @@ import android.service.notification.NotificationListenerService;
import android.service.notification.StatusBarNotification;
import android.support.test.annotation.UiThreadTest;
import android.support.test.filters.SmallTest;
-import android.support.test.runner.AndroidJUnit4;
import android.testing.AndroidTestingRunner;
import android.testing.TestableLooper.RunWithLooper;
import android.util.ArraySet;
@@ -62,6 +61,8 @@ import org.junit.runner.RunWith;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
+import java.util.ArrayList;
+
@SmallTest
@RunWith(AndroidTestingRunner.class)
@RunWithLooper(setAsMainLooper = true)
@@ -280,6 +281,24 @@ public class NotificationDataTest extends SysuiTestCase {
}
@Test
+ public void testGetNotificationsForCurrentUser_shouldFilterNonCurrentUserNotifications()
+ throws Exception {
+ mNotificationData.add(mRow.getEntry());
+ ExpandableNotificationRow row2 = new NotificationTestHelper(getContext()).createRow();
+ mNotificationData.add(row2.getEntry());
+
+ when(mEnvironment.isNotificationForCurrentProfiles(
+ mRow.getEntry().notification)).thenReturn(false);
+ when(mEnvironment.isNotificationForCurrentProfiles(
+ row2.getEntry().notification)).thenReturn(true);
+ ArrayList<NotificationData.Entry> reuslt =
+ mNotificationData.getNotificationsForCurrentUser();
+
+ assertEquals(reuslt.size(), 1);
+ assertEquals(reuslt.get(0), row2.getEntry());
+ }
+
+ @Test
public void testIsExemptFromDndVisualSuppression_foreground() {
initStatusBarNotification(false);
when(mMockStatusBarNotification.getKey()).thenReturn(
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsManagerTest.java
index cba1b548611b..72255f3c8fa4 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationGutsManagerTest.java
@@ -280,7 +280,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
any(PackageManager.class),
any(INotificationManager.class),
eq(statusBarNotification.getPackageName()),
- isNull(),
+ any(NotificationChannel.class),
anyInt(),
eq(statusBarNotification),
any(NotificationInfo.CheckSaveListener.class),
@@ -306,7 +306,7 @@ public class NotificationGutsManagerTest extends SysuiTestCase {
any(PackageManager.class),
any(INotificationManager.class),
eq(statusBarNotification.getPackageName()),
- isNull(),
+ any(NotificationChannel.class),
anyInt(),
eq(statusBarNotification),
any(NotificationInfo.CheckSaveListener.class),
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
index 2b0c6bfac988..c6bcd36c1abf 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/NotificationTestHelper.java
@@ -16,10 +16,13 @@
package com.android.systemui.statusbar;
+import static android.app.NotificationManager.IMPORTANCE_DEFAULT;
+
import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.Instrumentation;
import android.app.Notification;
+import android.app.NotificationChannel;
import android.content.Context;
import android.os.UserHandle;
import android.service.notification.StatusBarNotification;
@@ -118,7 +121,7 @@ public class NotificationTestHelper {
R.layout.custom_view_dark))
.build();
Notification.Builder notificationBuilder =
- new Notification.Builder(mContext)
+ new Notification.Builder(mContext, "channelId")
.setSmallIcon(R.drawable.ic_person)
.setContentTitle("Title")
.setContentText("Text")
@@ -166,6 +169,9 @@ public class NotificationTestHelper {
NotificationData.Entry entry = new NotificationData.Entry(sbn);
entry.row = row;
entry.createIcons(mContext, sbn);
+ entry.channel = new NotificationChannel(
+ notification.getChannelId(), notification.getChannelId(), IMPORTANCE_DEFAULT);
+ entry.channel.setBlockableSystem(true);
NotificationInflaterTest.runThenWaitForInflation(
() -> row.updateNotification(entry),
row.getNotificationInflater());
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java
index 7b2071ca14fd..8fee1071ba87 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/StatusBarIconViewTest.java
@@ -42,7 +42,7 @@ import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
import com.android.internal.statusbar.StatusBarIcon;
-import com.android.internal.util.NotificationColorUtil;
+import com.android.internal.util.ContrastColorUtil;
import com.android.systemui.R;
import com.android.systemui.SysuiTestCase;
@@ -115,7 +115,7 @@ public class StatusBarIconViewTest extends SysuiTestCase {
mIconView.setStaticDrawableColor(Color.WHITE);
color = mIconView.getContrastedStaticDrawableColor(Color.WHITE);
assertTrue("Similar colors should be shifted to satisfy contrast",
- NotificationColorUtil.satisfiesTextContrast(Color.WHITE, color));
+ ContrastColorUtil.satisfiesTextContrast(Color.WHITE, color));
mIconView.setStaticDrawableColor(Color.GREEN);
color = mIconView.getContrastedStaticDrawableColor(0xcc000000);
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
index 40337b89c18e..e95702c5ab91 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/ScrimControllerTest.java
@@ -542,6 +542,18 @@ public class ScrimControllerTest extends SysuiTestCase {
}
@Test
+ public void testHidesShowWhenLockedActivity_whenAlreadyInAod() {
+ mScrimController.setWallpaperSupportsAmbientMode(true);
+ mScrimController.transitionTo(ScrimState.AOD);
+ mScrimController.finishAnimationsImmediately();
+ assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_TRANSPARENT);
+
+ mScrimController.setKeyguardOccluded(true);
+ mScrimController.finishAnimationsImmediately();
+ assertScrimVisibility(VISIBILITY_FULLY_TRANSPARENT, VISIBILITY_FULLY_OPAQUE);
+ }
+
+ @Test
public void testEatsTouchEvent() {
HashSet<ScrimState> eatsTouches =
new HashSet<>(Arrays.asList(ScrimState.AOD, ScrimState.PULSING));
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
index 85135ac77b3c..94ab9d2a7d04 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarKeyguardViewManagerTest.java
@@ -177,6 +177,14 @@ public class StatusBarKeyguardViewManagerTest extends SysuiTestCase {
verify(mBouncer, never()).setExpansion(anyFloat());
}
+ @Test
+ public void onPanelExpansionChanged_neverTranslatesBouncerWhenLaunchingApp() {
+ when(mStatusBar.isInLaunchTransition()).thenReturn(true);
+ mStatusBarKeyguardViewManager.onPanelExpansionChanged(KeyguardBouncer.EXPANSION_VISIBLE,
+ false /* tracking */);
+ verify(mBouncer, never()).setExpansion(anyFloat());
+ }
+
private class TestableStatusBarKeyguardViewManager extends StatusBarKeyguardViewManager {
public TestableStatusBarKeyguardViewManager(Context context,
diff --git a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
index 0a412b96ed54..cf23bfc06107 100644
--- a/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
+++ b/packages/SystemUI/tests/src/com/android/systemui/statusbar/phone/StatusBarTest.java
@@ -597,7 +597,7 @@ public class StatusBarTest extends SysuiTestCase {
@Test
public void testInflateFooterView() {
- mStatusBar.reevaluateStyles();
+ mStatusBar.inflateFooterView();
ArgumentCaptor<FooterView> captor = ArgumentCaptor.forClass(FooterView.class);
verify(mStackScroller).setFooterView(captor.capture());
@@ -661,7 +661,7 @@ public class StatusBarTest extends SysuiTestCase {
@Test
public void testUpdateFooter_atEnd() {
// add footer
- mStatusBar.reevaluateStyles();
+ mStatusBar.inflateFooterView();
// add notification
ExpandableNotificationRow row = mock(ExpandableNotificationRow.class);
@@ -700,6 +700,13 @@ public class StatusBarTest extends SysuiTestCase {
assertTrue(mStatusBar.mState == StatusBarState.FULLSCREEN_USER_SWITCHER);
}
+ @Test
+ public void testOnDensityOrFontScaleChanged_reInflatesFooterViews() {
+ mStatusBar.onDensityOrFontScaleChanged();
+ verify(mStackScroller).setFooterView(any());
+ verify(mStackScroller).setEmptyShadeView(any());
+ }
+
static class TestableStatusBar extends StatusBar {
public TestableStatusBar(StatusBarKeyguardViewManager man,
UnlockMethodCache unlock, KeyguardIndicationController key,
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
index 7798cf7af3cb..b2c1beddec46 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityManagerService.java
@@ -3743,6 +3743,8 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
/**
* Removes a service.
+ * There are three states to a service here: off, bound, and binding.
+ * This stops tracking the service as bound.
*
* @param serviceConnection The service.
*/
@@ -3759,6 +3761,19 @@ public class AccessibilityManagerService extends IAccessibilityManager.Stub
scheduleNotifyClientsOfServicesStateChange(this);
}
+ /**
+ * Make sure a services disconnected but still 'on' state is reflected in UserState
+ * There are three states to a service here: off, bound, and binding.
+ * This drops a service from a bound state, to the binding state.
+ * The binding state describes the situation where a service is on, but not bound.
+ *
+ * @param serviceConnection The service.
+ */
+ public void serviceDisconnectedLocked(AccessibilityServiceConnection serviceConnection) {
+ removeServiceLocked(serviceConnection);
+ mBindingServices.add(serviceConnection.getComponentName());
+ }
+
public Set<ComponentName> getBindingServicesLocked() {
return mBindingServices;
}
diff --git a/services/accessibility/java/com/android/server/accessibility/AccessibilityServiceConnection.java b/services/accessibility/java/com/android/server/accessibility/AccessibilityServiceConnection.java
index eb18f06baae0..105df9238f8d 100644
--- a/services/accessibility/java/com/android/server/accessibility/AccessibilityServiceConnection.java
+++ b/services/accessibility/java/com/android/server/accessibility/AccessibilityServiceConnection.java
@@ -258,7 +258,10 @@ class AccessibilityServiceConnection extends AbstractAccessibilityServiceConnect
return;
}
mWasConnectedAndDied = true;
- resetLocked();
+ UserState userState = mUserStateWeakReference.get();
+ if (userState != null) {
+ userState.serviceDisconnectedLocked(this);
+ }
if (mId == mSystemSupport.getMagnificationController().getIdOfLastServiceToMagnify()) {
mSystemSupport.getMagnificationController().resetIfNeeded(true);
}
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
index 21398e37e6c5..41e9d2bf49de 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerService.java
@@ -1064,30 +1064,6 @@ public final class AutofillManagerService extends SystemService {
}
@Override
- public int updateOrRestartSession(IBinder activityToken, IBinder appCallback,
- AutofillId autoFillId, Rect bounds, AutofillValue value, int userId,
- boolean hasCallback, int flags, ComponentName componentName, int sessionId,
- int action, boolean compatMode) {
- boolean restart = false;
- synchronized (mLock) {
- final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
- if (service != null) {
- restart = service.updateSessionLocked(sessionId, getCallingUid(), autoFillId,
- bounds, value, action, flags);
- } else if (sVerbose) {
- Slog.v(TAG, "updateOrRestartSession(): no service for " + userId);
- }
- }
- if (restart) {
- return startSession(activityToken, appCallback, autoFillId, bounds, value, userId,
- hasCallback, flags, componentName, compatMode);
- }
-
- // Nothing changed...
- return sessionId;
- }
-
- @Override
public void setAutofillFailure(int sessionId, @NonNull List<AutofillId> ids, int userId) {
synchronized (mLock) {
final AutofillManagerServiceImpl service = peekServiceForUserLocked(userId);
diff --git a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
index 1ccce177bca8..6c359fe0df2e 100644
--- a/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
+++ b/services/autofill/java/com/android/server/autofill/AutofillManagerServiceImpl.java
@@ -26,9 +26,11 @@ import static com.android.server.autofill.Helper.sVerbose;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.ActivityManagerInternal;
import android.app.AppGlobals;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.ApplicationInfo;
@@ -1296,13 +1298,13 @@ final class AutofillManagerServiceImpl {
}
}
- IActivityManager am = ActivityManager.getService();
+ final IActivityTaskManager atm = ActivityTaskManager.getService();
// Only remove sessions which's activities are not known to the activity manager anymore
for (int i = 0; i < numSessionsToRemove; i++) {
try {
// The activity manager cannot resolve activities that have been removed
- if (am.getActivityClassForToken(sessionsToRemove.valueAt(i)) != null) {
+ if (atm.getActivityClassForToken(sessionsToRemove.valueAt(i)) != null) {
sessionsToRemove.removeAt(i);
i--;
numSessionsToRemove--;
diff --git a/services/autofill/java/com/android/server/autofill/FieldClassificationStrategy.java b/services/autofill/java/com/android/server/autofill/FieldClassificationStrategy.java
index ba544f17c06c..293f908e2708 100644
--- a/services/autofill/java/com/android/server/autofill/FieldClassificationStrategy.java
+++ b/services/autofill/java/com/android/server/autofill/FieldClassificationStrategy.java
@@ -282,9 +282,13 @@ final class FieldClassificationStrategy {
}
pw.println(impl.flattenToShortString());
- pw.print(prefix); pw.print("Available algorithms: ");
- pw.println(Arrays.toString(getAvailableAlgorithms()));
- pw.print(prefix); pw.print("Default algorithm: "); pw.println(getDefaultAlgorithm());
+ try {
+ pw.print(prefix); pw.print("Available algorithms: ");
+ pw.println(Arrays.toString(getAvailableAlgorithms()));
+ pw.print(prefix); pw.print("Default algorithm: "); pw.println(getDefaultAlgorithm());
+ } catch (Exception e) {
+ pw.print("ERROR CALLING SERVICE: " ); pw.println(e);
+ }
}
private static interface Command {
diff --git a/services/autofill/java/com/android/server/autofill/Helper.java b/services/autofill/java/com/android/server/autofill/Helper.java
index f14c8f1aa7f6..4f45a7770311 100644
--- a/services/autofill/java/com/android/server/autofill/Helper.java
+++ b/services/autofill/java/com/android/server/autofill/Helper.java
@@ -61,11 +61,12 @@ public final class Helper {
static int sPartitionMaxCount = 10;
/**
- * Maximum number of visible datasets in the dataset picker UI.
+ * Maximum number of visible datasets in the dataset picker UI, or {@code 0} to use default
+ * value from resources.
*
* <p>Can be modified using {@code cmd autofill set max_visible_datasets}.
*/
- public static int sVisibleDatasetsMaxCount = 3;
+ public static int sVisibleDatasetsMaxCount = 0;
/**
* When non-null, overrides whether the UI should be shown on full-screen mode.
diff --git a/services/autofill/java/com/android/server/autofill/RemoteFillService.java b/services/autofill/java/com/android/server/autofill/RemoteFillService.java
index 3e932e8d6daf..65ad5960ea9c 100644
--- a/services/autofill/java/com/android/server/autofill/RemoteFillService.java
+++ b/services/autofill/java/com/android/server/autofill/RemoteFillService.java
@@ -101,9 +101,8 @@ final class RemoteFillService implements DeathRecipient {
public interface FillServiceCallbacks {
void onFillRequestSuccess(int requestId, @Nullable FillResponse response,
@NonNull String servicePackageName, int requestFlags);
- void onFillRequestFailure(int requestId, @Nullable CharSequence message,
- @NonNull String servicePackageName);
- void onFillRequestTimeout(int requestId, @NonNull String servicePackageName);
+ void onFillRequestFailure(int requestId, @Nullable CharSequence message);
+ void onFillRequestTimeout(int requestId);
void onSaveRequestSuccess(@NonNull String servicePackageName,
@Nullable IntentSender intentSender);
// TODO(b/80093094): add timeout here too?
@@ -317,8 +316,7 @@ final class RemoteFillService implements DeathRecipient {
@Nullable CharSequence message) {
mHandler.post(() -> {
if (handleResponseCallbackCommon(pendingRequest)) {
- mCallbacks.onFillRequestFailure(pendingRequest.mRequest.getId(), message,
- mComponentName.getPackageName());
+ mCallbacks.onFillRequestFailure(pendingRequest.mRequest.getId(), message);
}
});
}
@@ -326,8 +324,7 @@ final class RemoteFillService implements DeathRecipient {
private void dispatchOnFillRequestTimeout(@NonNull PendingFillRequest pendingRequest) {
mHandler.post(() -> {
if (handleResponseCallbackCommon(pendingRequest)) {
- mCallbacks.onFillRequestTimeout(pendingRequest.mRequest.getId(),
- mComponentName.getPackageName());
+ mCallbacks.onFillRequestTimeout(pendingRequest.mRequest.getId());
}
});
}
diff --git a/services/autofill/java/com/android/server/autofill/Session.java b/services/autofill/java/com/android/server/autofill/Session.java
index 09f41353be08..d9dcf4019a2f 100644
--- a/services/autofill/java/com/android/server/autofill/Session.java
+++ b/services/autofill/java/com/android/server/autofill/Session.java
@@ -38,6 +38,7 @@ import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.Activity;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.IAssistDataReceiver;
import android.app.assist.AssistStructure;
import android.app.assist.AssistStructure.AutofillOverlay;
@@ -94,13 +95,11 @@ import com.android.server.autofill.ui.AutoFillUI;
import com.android.server.autofill.ui.PendingUi;
import java.io.PrintWriter;
-import java.io.StringWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
-import java.util.Map;
import java.util.Objects;
import java.util.concurrent.atomic.AtomicInteger;
@@ -517,7 +516,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
receiverExtras.putInt(EXTRA_REQUEST_ID, requestId);
final long identity = Binder.clearCallingIdentity();
try {
- if (!ActivityManager.getService().requestAutofillData(mAssistReceiver,
+ if (!ActivityTaskManager.getService().requestAutofillData(mAssistReceiver,
receiverExtras, mActivityToken, flags)) {
Slog.w(TAG, "failed to request autofill data for " + mActivityToken);
}
@@ -705,19 +704,18 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
// FillServiceCallbacks
@Override
- public void onFillRequestFailure(int requestId, @Nullable CharSequence message,
- @NonNull String servicePackageName) {
- onFillRequestFailureOrTimeout(requestId, false, message, servicePackageName);
+ public void onFillRequestFailure(int requestId, @Nullable CharSequence message) {
+ onFillRequestFailureOrTimeout(requestId, false, message);
}
// FillServiceCallbacks
@Override
- public void onFillRequestTimeout(int requestId, @NonNull String servicePackageName) {
- onFillRequestFailureOrTimeout(requestId, true, null, servicePackageName);
+ public void onFillRequestTimeout(int requestId) {
+ onFillRequestFailureOrTimeout(requestId, true, null);
}
private void onFillRequestFailureOrTimeout(int requestId, boolean timedOut,
- @Nullable CharSequence message, @NonNull String servicePackageName) {
+ @Nullable CharSequence message) {
synchronized (mLock) {
if (mDestroyed) {
Slog.w(TAG, "Call to Session#onFillRequestFailureOrTimeout(req=" + requestId
@@ -2538,13 +2536,14 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
}
}
pw.print(prefix); pw.print("mCurrentViewId: "); pw.println(mCurrentViewId);
- pw.print(prefix); pw.print("mViewStates size: "); pw.println(mViewStates.size());
pw.print(prefix); pw.print("mDestroyed: "); pw.println(mDestroyed);
pw.print(prefix); pw.print("mIsSaving: "); pw.println(mIsSaving);
pw.print(prefix); pw.print("mPendingSaveUi: "); pw.println(mPendingSaveUi);
- for (Map.Entry<AutofillId, ViewState> entry : mViewStates.entrySet()) {
- pw.print(prefix); pw.print("State for id "); pw.println(entry.getKey());
- entry.getValue().dump(prefix2, pw);
+ final int numberViews = mViewStates.size();
+ pw.print(prefix); pw.print("mViewStates size: "); pw.println(mViewStates.size());
+ for (int i = 0; i < numberViews; i++) {
+ pw.print(prefix); pw.print("ViewState at #"); pw.println(i);
+ mViewStates.valueAt(i).dump(prefix2, pw);
}
pw.print(prefix); pw.print("mContexts: " );
@@ -2555,7 +2554,7 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
pw.print(prefix2); pw.print(context);
if (sVerbose) {
- pw.println(context.getStructure() + " (look at logcat)");
+ pw.println("AssistStructure dumped at logcat)");
// TODO: add method on AssistStructure to dump on pw
context.getStructure().dump(false);
@@ -2856,14 +2855,6 @@ final class Session implements RemoteFillService.FillServiceCallbacks, ViewState
requestLog.addTaggedData(tag, value);
}
- private static String requestLogToString(@NonNull LogMaker log) {
- final StringWriter sw = new StringWriter();
- final PrintWriter pw = new PrintWriter(sw);
- dumpRequestLog(pw, log);
- pw.flush();
- return sw.toString();
- }
-
private void wtf(@Nullable Exception e, String fmt, Object...args) {
final String message = String.format(fmt, args);
mWtfHistory.log(message);
diff --git a/services/autofill/java/com/android/server/autofill/ui/FillUi.java b/services/autofill/java/com/android/server/autofill/ui/FillUi.java
index 8119054f4196..68a495fe9a2f 100644
--- a/services/autofill/java/com/android/server/autofill/ui/FillUi.java
+++ b/services/autofill/java/com/android/server/autofill/ui/FillUi.java
@@ -21,7 +21,6 @@ import static com.android.server.autofill.Helper.sFullScreenMode;
import static com.android.server.autofill.Helper.sVerbose;
import static com.android.server.autofill.Helper.sVisibleDatasetsMaxCount;
-import android.annotation.AttrRes;
import android.annotation.NonNull;
import android.annotation.Nullable;
import android.app.PendingIntent;
@@ -37,7 +36,6 @@ import android.service.autofill.Dataset;
import android.service.autofill.Dataset.DatasetFieldFilter;
import android.service.autofill.FillResponse;
import android.text.TextUtils;
-import android.util.AttributeSet;
import android.util.Slog;
import android.util.TypedValue;
import android.view.KeyEvent;
@@ -54,7 +52,6 @@ import android.view.autofill.IAutofillWindowPresenter;
import android.widget.BaseAdapter;
import android.widget.Filter;
import android.widget.Filterable;
-import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
@@ -679,7 +676,7 @@ final class FillUi {
// WM throws an ISE if mContentView was added twice; this should never happen -
// since show() and hide() are always called in the UIThread - but when it does,
// it should not crash the system.
- Slog.e(TAG, "Exception showing window " + params, e);
+ Slog.wtf(TAG, "Exception showing window " + params, e);
mCallback.onDestroy();
}
}
diff --git a/services/backup/java/com/android/server/backup/internal/PerformInitializeTask.java b/services/backup/java/com/android/server/backup/internal/PerformInitializeTask.java
index 88e0b7fc3045..1ef740db614f 100644
--- a/services/backup/java/com/android/server/backup/internal/PerformInitializeTask.java
+++ b/services/backup/java/com/android/server/backup/internal/PerformInitializeTask.java
@@ -130,9 +130,13 @@ public class PerformInitializeTask implements Runnable {
IBackupTransport transport = transportClient.connectOrThrow(callerLogString);
int status = transport.initializeDevice();
-
- if (status == BackupTransport.TRANSPORT_OK) {
+ if (status != BackupTransport.TRANSPORT_OK) {
+ Slog.e(TAG, "Transport error in initializeDevice()");
+ } else {
status = transport.finishBackup();
+ if (status != BackupTransport.TRANSPORT_OK) {
+ Slog.e(TAG, "Transport error in finishBackup()");
+ }
}
// Okay, the wipe really happened. Clean up our local bookkeeping.
@@ -148,7 +152,6 @@ public class PerformInitializeTask implements Runnable {
} else {
// If this didn't work, requeue this one and try again
// after a suitable interval
- Slog.e(TAG, "Transport error in initializeDevice()");
EventLog.writeEvent(EventLogTags.BACKUP_TRANSPORT_FAILURE, "(initialize)");
mBackupManagerService.recordInitPending(true, transportName, transportDirName);
notifyResult(transportName, status);
diff --git a/services/core/java/com/android/server/AlarmManagerService.java b/services/core/java/com/android/server/AlarmManagerService.java
index 99912d9c490c..6ca81c2889ab 100644
--- a/services/core/java/com/android/server/AlarmManagerService.java
+++ b/services/core/java/com/android/server/AlarmManagerService.java
@@ -1953,6 +1953,14 @@ class AlarmManagerService extends SystemService {
pw.print(" = "); pw.println(sdf.format(new Date(nextWakeupRTC)));
pw.print(" set at "); TimeUtils.formatDuration(mLastWakeupSet, nowELAPSED, pw);
pw.println();
+
+ pw.print(" Next kernel non-wakeup alarm: ");
+ TimeUtils.formatDuration(getNextAlarm(mNativeData, ELAPSED_REALTIME), pw);
+ pw.println();
+ pw.print(" Next kernel wakeup alarm: ");
+ TimeUtils.formatDuration(getNextAlarm(mNativeData, ELAPSED_REALTIME_WAKEUP), pw);
+ pw.println();
+
pw.print(" Last wakeup: "); TimeUtils.formatDuration(mLastWakeup, nowELAPSED, pw);
pw.print(" = "); pw.println(mLastWakeup);
pw.print(" Last trigger: "); TimeUtils.formatDuration(mLastTrigger, nowELAPSED, pw);
@@ -3063,6 +3071,7 @@ class AlarmManagerService extends SystemService {
private native int waitForAlarm(long nativeData);
private native int setKernelTime(long nativeData, long millis);
private native int setKernelTimezone(long nativeData, int minuteswest);
+ private native long getNextAlarm(long nativeData, int type);
private long getWhileIdleMinIntervalLocked(int uid) {
final boolean dozing = mPendingIdleUntil != null;
diff --git a/services/core/java/com/android/server/ConnectivityService.java b/services/core/java/com/android/server/ConnectivityService.java
index 063352d0518a..f14b877aa0b5 100644
--- a/services/core/java/com/android/server/ConnectivityService.java
+++ b/services/core/java/com/android/server/ConnectivityService.java
@@ -128,7 +128,6 @@ import com.android.internal.annotations.GuardedBy;
import com.android.internal.annotations.VisibleForTesting;
import com.android.internal.app.IBatteryStats;
import com.android.internal.net.LegacyVpnInfo;
-import com.android.internal.net.NetworkStatsFactory;
import com.android.internal.net.VpnConfig;
import com.android.internal.net.VpnInfo;
import com.android.internal.net.VpnProfile;
@@ -156,6 +155,7 @@ import com.android.server.connectivity.NetworkNotificationManager;
import com.android.server.connectivity.NetworkNotificationManager.NotificationType;
import com.android.server.connectivity.PacManager;
import com.android.server.connectivity.PermissionMonitor;
+import com.android.server.connectivity.ProxyTracker;
import com.android.server.connectivity.Tethering;
import com.android.server.connectivity.Vpn;
import com.android.server.connectivity.tethering.TetheringDependencies;
@@ -199,14 +199,13 @@ public class ConnectivityService extends IConnectivityManager.Stub
implements PendingIntent.OnFinished {
private static final String TAG = ConnectivityService.class.getSimpleName();
- public static final String DIAG_ARG = "--diag";
+ private static final String DIAG_ARG = "--diag";
public static final String SHORT_ARG = "--short";
- public static final String TETHERING_ARG = "tethering";
+ private static final String TETHERING_ARG = "tethering";
private static final boolean DBG = true;
private static final boolean VDBG = false;
- private static final boolean LOGD_RULES = false;
private static final boolean LOGD_BLOCKED_NETWORKINFO = true;
// TODO: create better separation between radio types and network types
@@ -241,7 +240,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
@VisibleForTesting
@GuardedBy("mVpns")
- protected final SparseArray<Vpn> mVpns = new SparseArray<Vpn>();
+ protected final SparseArray<Vpn> mVpns = new SparseArray<>();
// TODO: investigate if mLockdownEnabled can be removed and replaced everywhere by
// a direct call to LockdownVpnTracker.isEnabled().
@@ -251,24 +250,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
private LockdownVpnTracker mLockdownTracker;
final private Context mContext;
- private int mNetworkPreference;
// 0 is full bad, 100 is full good
private int mDefaultInetConditionPublished = 0;
- private boolean mTestMode;
- private static ConnectivityService sServiceInstance;
-
private INetworkManagementService mNetd;
private INetworkStatsService mStatsService;
private INetworkPolicyManager mPolicyManager;
private NetworkPolicyManagerInternal mPolicyManagerInternal;
- private IIpConnectivityMetrics mIpConnectivityMetrics;
private String mCurrentTcpBufferSizes;
- private static final int ENABLED = 1;
- private static final int DISABLED = 0;
-
private static final SparseArray<String> sMagicDecoderRing = MessageUtils.findMessageNames(
new Class[] { AsyncChannel.class, ConnectivityService.class, NetworkAgent.class,
NetworkAgentInfo.class });
@@ -281,7 +272,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// Don't reap networks. This should be passed when some networks have not yet been
// rematched against all NetworkRequests.
DONT_REAP
- };
+ }
private enum UnneededFor {
LINGER, // Determine whether this network is unneeded and should be lingered.
@@ -289,11 +280,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
/**
- * used internally to change our mobile data enabled flag
- */
- private static final int EVENT_CHANGE_MOBILE_DATA_ENABLED = 2;
-
- /**
* used internally to clear a wakelock when transitioning
* from one net to another. Clear happens when we get a new
* network - EVENT_EXPIRE_NET_TRANSITION_WAKELOCK happens
@@ -444,29 +430,21 @@ public class ConnectivityService extends IConnectivityManager.Stub
private int mNetTransitionWakeLockTimeout;
private final PowerManager.WakeLock mPendingIntentWakeLock;
- // track the current default http proxy - tell the world if we get a new one (real change)
- private volatile ProxyInfo mDefaultProxy = null;
- private Object mProxyLock = new Object();
- private boolean mDefaultProxyDisabled = false;
-
- // track the global proxy.
- private ProxyInfo mGlobalProxy = null;
-
- private PacManager mPacManager = null;
+ // A helper object to track the current default HTTP proxy. ConnectivityService needs to tell
+ // the world when it changes.
+ private final ProxyTracker mProxyTracker;
final private SettingsObserver mSettingsObserver;
private UserManager mUserManager;
- NetworkConfig[] mNetConfigs;
- int mNetworksDefined;
+ private NetworkConfig[] mNetConfigs;
+ private int mNetworksDefined;
// the set of network types that can only be enabled by system/sig apps
- List mProtectedNetworks;
-
- private DataConnectionStats mDataConnectionStats;
+ private List mProtectedNetworks;
- TelephonyManager mTelephonyManager;
+ private TelephonyManager mTelephonyManager;
private KeepaliveTracker mKeepaliveTracker;
private NetworkNotificationManager mNotifier;
@@ -509,8 +487,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
mLog = log;
}
}
- private final ArrayDeque<ValidationLog> mValidationLogs =
- new ArrayDeque<ValidationLog>(MAX_VALIDATION_LOGS);
+ private final ArrayDeque<ValidationLog> mValidationLogs = new ArrayDeque<>(MAX_VALIDATION_LOGS);
private void addValidationLogs(ReadOnlyLocalLog log, Network network, String name) {
synchronized (mValidationLogs) {
@@ -583,7 +560,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
throw new IllegalStateException(
"legacy list for type " + type + "already initialized");
}
- mTypeLists[type] = new ArrayList<NetworkAgentInfo>();
+ mTypeLists[type] = new ArrayList<>();
}
public boolean isTypeSupported(int type) {
@@ -686,7 +663,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
private String naiToString(NetworkAgentInfo nai) {
- String name = (nai != null) ? nai.name() : "null";
+ String name = nai.name();
String state = (nai.networkInfo != null) ?
nai.networkInfo.getState() + "/" + nai.networkInfo.getDetailedState() :
"???/???";
@@ -779,6 +756,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
mPolicyManagerInternal = checkNotNull(
LocalServices.getService(NetworkPolicyManagerInternal.class),
"missing NetworkPolicyManagerInternal");
+ mProxyTracker = new ProxyTracker(context, mHandler, EVENT_PROXY_HAS_CHANGED);
mKeyStore = KeyStore.getInstance();
mTelephonyManager = (TelephonyManager) mContext.getSystemService(Context.TELEPHONY_SERVICE);
@@ -860,9 +838,6 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
- mTestMode = mSystemProperties.get("cm.test.mode").equals("true")
- && mSystemProperties.get("ro.build.type").equals("eng");
-
mTethering = makeTethering();
mPermissionMonitor = new PermissionMonitor(mContext, mNetd);
@@ -889,10 +864,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
mSettingsObserver = new SettingsObserver(mContext, mHandler);
registerSettingsCallbacks();
- mDataConnectionStats = new DataConnectionStats(mContext);
- mDataConnectionStats.startMonitoring();
-
- mPacManager = new PacManager(mContext, mHandler, EVENT_PROXY_HAS_CHANGED);
+ final DataConnectionStats dataConnectionStats = new DataConnectionStats(mContext);
+ dataConnectionStats.startMonitoring();
mUserManager = (UserManager) context.getSystemService(Context.USER_SERVICE);
@@ -1022,7 +995,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
throw new IllegalStateException("No free netIds");
}
- private NetworkState getFilteredNetworkState(int networkType, int uid, boolean ignoreBlocked) {
+ private NetworkState getFilteredNetworkState(int networkType, int uid) {
if (mLegacyTypeTracker.isTypeSupported(networkType)) {
final NetworkAgentInfo nai = mLegacyTypeTracker.getNetworkForType(networkType);
final NetworkState state;
@@ -1040,7 +1013,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
state = new NetworkState(info, new LinkProperties(), capabilities,
null, null, null);
}
- filterNetworkStateForUid(state, uid, ignoreBlocked);
+ filterNetworkStateForUid(state, uid, false);
return state;
} else {
return NetworkState.EMPTY;
@@ -1245,7 +1218,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
return state.networkInfo;
}
}
- final NetworkState state = getFilteredNetworkState(networkType, uid, false);
+ final NetworkState state = getFilteredNetworkState(networkType, uid);
return state.networkInfo;
}
@@ -1280,7 +1253,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
public Network getNetworkForType(int networkType) {
enforceAccessPermission();
final int uid = Binder.getCallingUid();
- NetworkState state = getFilteredNetworkState(networkType, uid, false);
+ NetworkState state = getFilteredNetworkState(networkType, uid);
if (!isNetworkWithLinkPropertiesBlocked(state.linkProperties, uid, false)) {
return state.network;
}
@@ -1317,7 +1290,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// default.
enforceAccessPermission();
- HashMap<Network, NetworkCapabilities> result = new HashMap<Network, NetworkCapabilities>();
+ HashMap<Network, NetworkCapabilities> result = new HashMap<>();
NetworkAgentInfo nai = getDefaultNetwork();
NetworkCapabilities nc = getNetworkCapabilitiesInternal(nai);
@@ -1604,15 +1577,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
@VisibleForTesting
protected void registerNetdEventCallback() {
- mIpConnectivityMetrics =
- (IIpConnectivityMetrics) IIpConnectivityMetrics.Stub.asInterface(
- ServiceManager.getService(IpConnectivityLog.SERVICE_NAME));
- if (mIpConnectivityMetrics == null) {
+ final IIpConnectivityMetrics ipConnectivityMetrics =
+ IIpConnectivityMetrics.Stub.asInterface(
+ ServiceManager.getService(IpConnectivityLog.SERVICE_NAME));
+ if (ipConnectivityMetrics == null) {
Slog.wtf(TAG, "Missing IIpConnectivityMetrics");
+ return;
}
try {
- mIpConnectivityMetrics.addNetdEventCallback(
+ ipConnectivityMetrics.addNetdEventCallback(
INetdEventCallback.CALLBACK_CALLER_CONNECTIVITY_SERVICE,
mNetdEventCallback);
} catch (Exception e) {
@@ -1790,7 +1764,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
try {
bs.noteConnectivityChanged(intent.getIntExtra(
ConnectivityManager.EXTRA_NETWORK_TYPE, ConnectivityManager.TYPE_NONE),
- ni != null ? ni.getState().toString() : "?");
+ ni.getState().toString());
} catch (RemoteException e) {
}
intent.addFlags(Intent.FLAG_RECEIVER_VISIBLE_TO_INSTANT_APPS);
@@ -1878,7 +1852,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (iface != null && (caps.hasTransport(NetworkCapabilities.TRANSPORT_CELLULAR) ||
caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI))) {
try {
- // the call fails silently if no idletimer setup for this interface
+ // the call fails silently if no idle timer setup for this interface
mNetd.removeIdleTimer(iface);
} catch (Exception e) {
loge("Exception in removeDataActivityTracking " + e);
@@ -1887,7 +1861,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
/**
- * Reads the network specific MTU size from reources.
+ * Reads the network specific MTU size from resources.
* and set it on it's iface.
*/
private void updateMtu(LinkProperties newLp, LinkProperties oldLp) {
@@ -2833,7 +2807,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (!accept) {
// Tell the NetworkAgent to not automatically reconnect to the network.
nai.asyncChannel.sendMessage(NetworkAgent.CMD_PREVENT_AUTOMATIC_RECONNECT);
- // Teardown the nework.
+ // Teardown the network.
teardownUnneededNetwork(nai);
}
@@ -3101,8 +3075,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
public int tether(String iface, String callerPkg) {
ConnectivityManager.enforceTetherChangePermission(mContext, callerPkg);
if (isTetheringSupported()) {
- final int status = mTethering.tether(iface);
- return status;
+ return mTethering.tether(iface);
} else {
return ConnectivityManager.TETHER_ERROR_UNSUPPORTED;
}
@@ -3114,8 +3087,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
ConnectivityManager.enforceTetherChangePermission(mContext, callerPkg);
if (isTetheringSupported()) {
- final int status = mTethering.untether(iface);
- return status;
+ return mTethering.untether(iface);
} else {
return ConnectivityManager.TETHER_ERROR_UNSUPPORTED;
}
@@ -3347,22 +3319,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
nai.networkMonitor.forceReevaluation(uid);
}
- private ProxyInfo getDefaultProxy() {
- // this information is already available as a world read/writable jvm property
- // so this API change wouldn't have a benifit. It also breaks the passing
- // of proxy info to all the JVMs.
- // enforceAccessPermission();
- synchronized (mProxyLock) {
- ProxyInfo ret = mGlobalProxy;
- if ((ret == null) && !mDefaultProxyDisabled) ret = mDefaultProxy;
- return ret;
- }
- }
-
@Override
public ProxyInfo getProxyForNetwork(Network network) {
- if (network == null) return getDefaultProxy();
- final ProxyInfo globalProxy = getGlobalProxy();
+ if (network == null) return mProxyTracker.getDefaultProxy();
+ final ProxyInfo globalProxy = mProxyTracker.getGlobalProxy();
if (globalProxy != null) return globalProxy;
if (!NetworkUtils.queryUserAccess(Binder.getCallingUid(), network.netId)) return null;
// Don't call getLinkProperties() as it requires ACCESS_NETWORK_STATE permission, which
@@ -3376,80 +3336,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
- // Convert empty ProxyInfo's to null as null-checks are used to determine if proxies are present
- // (e.g. if mGlobalProxy==null fall back to network-specific proxy, if network-specific
- // proxy is null then there is no proxy in place).
- private ProxyInfo canonicalizeProxyInfo(ProxyInfo proxy) {
- if (proxy != null && TextUtils.isEmpty(proxy.getHost())
- && (proxy.getPacFileUrl() == null || Uri.EMPTY.equals(proxy.getPacFileUrl()))) {
- proxy = null;
- }
- return proxy;
- }
-
- // ProxyInfo equality function with a couple modifications over ProxyInfo.equals() to make it
- // better for determining if a new proxy broadcast is necessary:
- // 1. Canonicalize empty ProxyInfos to null so an empty proxy compares equal to null so as to
- // avoid unnecessary broadcasts.
- // 2. Make sure all parts of the ProxyInfo's compare true, including the host when a PAC URL
- // is in place. This is important so legacy PAC resolver (see com.android.proxyhandler)
- // changes aren't missed. The legacy PAC resolver pretends to be a simple HTTP proxy but
- // actually uses the PAC to resolve; this results in ProxyInfo's with PAC URL, host and port
- // all set.
- private boolean proxyInfoEqual(ProxyInfo a, ProxyInfo b) {
- a = canonicalizeProxyInfo(a);
- b = canonicalizeProxyInfo(b);
- // ProxyInfo.equals() doesn't check hosts when PAC URLs are present, but we need to check
- // hosts even when PAC URLs are present to account for the legacy PAC resolver.
- return Objects.equals(a, b) && (a == null || Objects.equals(a.getHost(), b.getHost()));
- }
-
- public void setGlobalProxy(ProxyInfo proxyProperties) {
+ @Override
+ public void setGlobalProxy(final ProxyInfo proxyProperties) {
enforceConnectivityInternalPermission();
-
- synchronized (mProxyLock) {
- if (proxyProperties == mGlobalProxy) return;
- if (proxyProperties != null && proxyProperties.equals(mGlobalProxy)) return;
- if (mGlobalProxy != null && mGlobalProxy.equals(proxyProperties)) return;
-
- String host = "";
- int port = 0;
- String exclList = "";
- String pacFileUrl = "";
- if (proxyProperties != null && (!TextUtils.isEmpty(proxyProperties.getHost()) ||
- !Uri.EMPTY.equals(proxyProperties.getPacFileUrl()))) {
- if (!proxyProperties.isValid()) {
- if (DBG)
- log("Invalid proxy properties, ignoring: " + proxyProperties.toString());
- return;
- }
- mGlobalProxy = new ProxyInfo(proxyProperties);
- host = mGlobalProxy.getHost();
- port = mGlobalProxy.getPort();
- exclList = mGlobalProxy.getExclusionListAsString();
- if (!Uri.EMPTY.equals(proxyProperties.getPacFileUrl())) {
- pacFileUrl = proxyProperties.getPacFileUrl().toString();
- }
- } else {
- mGlobalProxy = null;
- }
- ContentResolver res = mContext.getContentResolver();
- final long token = Binder.clearCallingIdentity();
- try {
- Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_HOST, host);
- Settings.Global.putInt(res, Settings.Global.GLOBAL_HTTP_PROXY_PORT, port);
- Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST,
- exclList);
- Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_PAC, pacFileUrl);
- } finally {
- Binder.restoreCallingIdentity(token);
- }
-
- if (mGlobalProxy == null) {
- proxyProperties = mDefaultProxy;
- }
- sendProxyBroadcast(proxyProperties);
- }
+ mProxyTracker.setGlobalProxy(proxyProperties);
}
private void loadGlobalProxy() {
@@ -3471,20 +3361,16 @@ public class ConnectivityService extends IConnectivityManager.Stub
return;
}
- synchronized (mProxyLock) {
- mGlobalProxy = proxyProperties;
+ synchronized (mProxyTracker.mProxyLock) {
+ mProxyTracker.mGlobalProxy = proxyProperties;
}
}
}
+ @Override
+ @Nullable
public ProxyInfo getGlobalProxy() {
- // this information is already available as a world read/writable jvm property
- // so this API change wouldn't have a benifit. It also breaks the passing
- // of proxy info to all the JVMs.
- // enforceAccessPermission();
- synchronized (mProxyLock) {
- return mGlobalProxy;
- }
+ return mProxyTracker.getGlobalProxy();
}
private void handleApplyDefaultProxy(ProxyInfo proxy) {
@@ -3492,9 +3378,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
&& Uri.EMPTY.equals(proxy.getPacFileUrl())) {
proxy = null;
}
- synchronized (mProxyLock) {
- if (mDefaultProxy != null && mDefaultProxy.equals(proxy)) return;
- if (mDefaultProxy == proxy) return; // catches repeated nulls
+ synchronized (mProxyTracker.mProxyLock) {
+ if (mProxyTracker.mDefaultProxy != null && mProxyTracker.mDefaultProxy.equals(proxy)) {
+ return;
+ }
+ if (mProxyTracker.mDefaultProxy == proxy) return; // catches repeated nulls
if (proxy != null && !proxy.isValid()) {
if (DBG) log("Invalid proxy properties, ignoring: " + proxy.toString());
return;
@@ -3505,18 +3393,18 @@ public class ConnectivityService extends IConnectivityManager.Stub
// global (to get the correct local port), and send a broadcast.
// TODO: Switch PacManager to have its own message to send back rather than
// reusing EVENT_HAS_CHANGED_PROXY and this call to handleApplyDefaultProxy.
- if ((mGlobalProxy != null) && (proxy != null)
+ if ((mProxyTracker.mGlobalProxy != null) && (proxy != null)
&& (!Uri.EMPTY.equals(proxy.getPacFileUrl()))
- && proxy.getPacFileUrl().equals(mGlobalProxy.getPacFileUrl())) {
- mGlobalProxy = proxy;
- sendProxyBroadcast(mGlobalProxy);
+ && proxy.getPacFileUrl().equals(mProxyTracker.mGlobalProxy.getPacFileUrl())) {
+ mProxyTracker.mGlobalProxy = proxy;
+ mProxyTracker.sendProxyBroadcast(mProxyTracker.mGlobalProxy);
return;
}
- mDefaultProxy = proxy;
+ mProxyTracker.mDefaultProxy = proxy;
- if (mGlobalProxy != null) return;
- if (!mDefaultProxyDisabled) {
- sendProxyBroadcast(proxy);
+ if (mProxyTracker.mGlobalProxy != null) return;
+ if (!mProxyTracker.mDefaultProxyDisabled) {
+ mProxyTracker.sendProxyBroadcast(proxy);
}
}
}
@@ -3526,17 +3414,17 @@ public class ConnectivityService extends IConnectivityManager.Stub
// the default proxy (even if it hasn't changed).
// TODO: Deprecate the broadcast extras as they aren't necessarily applicable in a multi-network
// world where an app might be bound to a non-default network.
- private void updateProxy(LinkProperties newLp, LinkProperties oldLp, NetworkAgentInfo nai) {
+ private void updateProxy(LinkProperties newLp, LinkProperties oldLp) {
ProxyInfo newProxyInfo = newLp == null ? null : newLp.getHttpProxy();
ProxyInfo oldProxyInfo = oldLp == null ? null : oldLp.getHttpProxy();
- if (!proxyInfoEqual(newProxyInfo, oldProxyInfo)) {
- sendProxyBroadcast(getDefaultProxy());
+ if (!ProxyTracker.proxyInfoEqual(newProxyInfo, oldProxyInfo)) {
+ mProxyTracker.sendProxyBroadcast(mProxyTracker.getDefaultProxy());
}
}
private void handleDeprecatedGlobalHttpProxy() {
- String proxy = Settings.Global.getString(mContext.getContentResolver(),
+ final String proxy = Settings.Global.getString(mContext.getContentResolver(),
Settings.Global.HTTP_PROXY);
if (!TextUtils.isEmpty(proxy)) {
String data[] = proxy.split(":");
@@ -3544,7 +3432,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
return;
}
- String proxyHost = data[0];
+ final String proxyHost = data[0];
int proxyPort = 8080;
if (data.length > 1) {
try {
@@ -3553,27 +3441,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
return;
}
}
- ProxyInfo p = new ProxyInfo(data[0], proxyPort, "");
+ final ProxyInfo p = new ProxyInfo(proxyHost, proxyPort, "");
setGlobalProxy(p);
}
}
- private void sendProxyBroadcast(ProxyInfo proxy) {
- if (proxy == null) proxy = new ProxyInfo("", 0, "");
- if (mPacManager.setCurrentProxyScriptUrl(proxy)) return;
- if (DBG) log("sending Proxy Broadcast for " + proxy);
- Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
- intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING |
- Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
- intent.putExtra(Proxy.EXTRA_PROXY_INFO, proxy);
- final long ident = Binder.clearCallingIdentity();
- try {
- mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
private static class SettingsObserver extends ContentObserver {
final private HashMap<Uri, Integer> mUriEventMap;
final private Context mContext;
@@ -3581,7 +3453,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
SettingsObserver(Context context, Handler handler) {
super(null);
- mUriEventMap = new HashMap<Uri, Integer>();
+ mUriEventMap = new HashMap<>();
mContext = context;
mHandler = handler;
}
@@ -3887,7 +3759,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
synchronized (mVpns) {
Vpn vpn = mVpns.get(userId);
if (vpn == null) {
- // Shouldn't happen as all codepaths that point here should have checked the Vpn
+ // Shouldn't happen as all code paths that point here should have checked the Vpn
// exists already.
Slog.wtf(TAG, "User " + userId + " has no Vpn configuration");
return false;
@@ -4051,7 +3923,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
url = String.format(url,
mTelephonyManager.getSimSerialNumber() /* ICCID */,
mTelephonyManager.getDeviceId() /* IMEI */,
- phoneNumber /* Phone numer */);
+ phoneNumber /* Phone number */);
}
return url;
@@ -4178,10 +4050,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
};
- private final HashMap<Messenger, NetworkFactoryInfo> mNetworkFactoryInfos =
- new HashMap<Messenger, NetworkFactoryInfo>();
- private final HashMap<NetworkRequest, NetworkRequestInfo> mNetworkRequests =
- new HashMap<NetworkRequest, NetworkRequestInfo>();
+ private final HashMap<Messenger, NetworkFactoryInfo> mNetworkFactoryInfos = new HashMap<>();
+ private final HashMap<NetworkRequest, NetworkRequestInfo> mNetworkRequests = new HashMap<>();
private static final int MAX_NETWORK_REQUESTS_PER_UID = 100;
// Map from UID to number of NetworkRequests that UID has filed.
@@ -4295,7 +4165,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
private ArrayList<Integer> getSignalStrengthThresholds(NetworkAgentInfo nai) {
- final SortedSet<Integer> thresholds = new TreeSet();
+ final SortedSet<Integer> thresholds = new TreeSet<>();
synchronized (nai) {
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
if (nri.request.networkCapabilities.hasSignalStrength() &&
@@ -4304,7 +4174,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
}
}
- return new ArrayList<Integer>(thresholds);
+ return new ArrayList<>(thresholds);
}
private void updateSignalStrengthThresholds(
@@ -4584,13 +4454,11 @@ public class ConnectivityService extends IConnectivityManager.Stub
*/
// NOTE: Accessed on multiple threads, must be synchronized on itself.
@GuardedBy("mNetworkForRequestId")
- private final SparseArray<NetworkAgentInfo> mNetworkForRequestId =
- new SparseArray<NetworkAgentInfo>();
+ private final SparseArray<NetworkAgentInfo> mNetworkForRequestId = new SparseArray<>();
// NOTE: Accessed on multiple threads, must be synchronized on itself.
@GuardedBy("mNetworkForNetId")
- private final SparseArray<NetworkAgentInfo> mNetworkForNetId =
- new SparseArray<NetworkAgentInfo>();
+ private final SparseArray<NetworkAgentInfo> mNetworkForNetId = new SparseArray<>();
// NOTE: Accessed on multiple threads, synchronized with mNetworkForNetId.
// An entry is first added to mNetIdInUse, prior to mNetworkForNetId, so
// there may not be a strict 1:1 correlation between the two.
@@ -4600,11 +4468,10 @@ public class ConnectivityService extends IConnectivityManager.Stub
// NetworkAgentInfo keyed off its connecting messenger
// TODO - eval if we can reduce the number of lists/hashmaps/sparsearrays
// NOTE: Only should be accessed on ConnectivityServiceThread, except dump().
- private final HashMap<Messenger, NetworkAgentInfo> mNetworkAgentInfos =
- new HashMap<Messenger, NetworkAgentInfo>();
+ private final HashMap<Messenger, NetworkAgentInfo> mNetworkAgentInfos = new HashMap<>();
@GuardedBy("mBlockedAppUids")
- private final HashSet<Integer> mBlockedAppUids = new HashSet();
+ private final HashSet<Integer> mBlockedAppUids = new HashSet<>();
// Note: if mDefaultRequest is changed, NetworkMonitor needs to be updated.
private final NetworkRequest mDefaultRequest;
@@ -4714,7 +4581,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (isDefaultNetwork(networkAgent)) {
handleApplyDefaultProxy(newLp.getHttpProxy());
} else {
- updateProxy(newLp, oldLp, networkAgent);
+ updateProxy(newLp, oldLp);
}
// TODO - move this check to cover the whole function
if (!Objects.equals(newLp, oldLp)) {
@@ -4729,7 +4596,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
}
private void wakeupModifyInterface(String iface, NetworkCapabilities caps, boolean add) {
- // Marks are only available on WiFi interaces. Checking for
+ // Marks are only available on WiFi interfaces. Checking for
// marks on unsupported interfaces is harmless.
if (!caps.hasTransport(NetworkCapabilities.TRANSPORT_WIFI)) {
return;
@@ -4761,7 +4628,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
private void updateInterfaces(LinkProperties newLp, LinkProperties oldLp, int netId,
NetworkCapabilities caps) {
- CompareResult<String> interfaceDiff = new CompareResult<String>(
+ CompareResult<String> interfaceDiff = new CompareResult<>(
oldLp != null ? oldLp.getAllInterfaceNames() : null,
newLp != null ? newLp.getAllInterfaceNames() : null);
for (String iface : interfaceDiff.added) {
@@ -4796,7 +4663,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// add routes before removing old in case it helps with continuous connectivity
- // do this twice, adding non-nexthop routes first, then routes they are dependent on
+ // do this twice, adding non-next-hop routes first, then routes they are dependent on
for (RouteInfo route : routeDiff.added) {
if (route.hasGateway()) continue;
if (VDBG) log("Adding Route [" + route + "] to network " + netId);
@@ -5249,8 +5116,8 @@ public class ConnectivityService extends IConnectivityManager.Stub
// Find and migrate to this Network any NetworkRequests for
// which this network is now the best.
- ArrayList<NetworkAgentInfo> affectedNetworks = new ArrayList<NetworkAgentInfo>();
- ArrayList<NetworkRequestInfo> addedRequests = new ArrayList<NetworkRequestInfo>();
+ ArrayList<NetworkAgentInfo> affectedNetworks = new ArrayList<>();
+ ArrayList<NetworkRequestInfo> addedRequests = new ArrayList<>();
NetworkCapabilities nc = newNetwork.networkCapabilities;
if (VDBG) log(" network has: " + nc);
for (NetworkRequestInfo nri : mNetworkRequests.values()) {
@@ -5300,7 +5167,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
keep = true;
// Tell NetworkFactories about the new score, so they can stop
// trying to connect if they know they cannot match it.
- // TODO - this could get expensive if we have alot of requests for this
+ // TODO - this could get expensive if we have a lot of requests for this
// network. Think about if there is a way to reduce this. Push
// netid->request mapping to each factory?
sendUpdatedScoreToFactories(nri.request, score);
@@ -5421,7 +5288,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// This has to happen after the notifyNetworkCallbacks as that tickles each
// ConnectivityManager instance so that legacy requests correctly bind dns
- // requests to this network. The legacy users are listening for this bcast
+ // requests to this network. The legacy users are listening for this broadcast
// and will generally do a dns request so they can ensureRouteToHost and if
// they do that before the callbacks happen they'll use the default network.
//
@@ -5486,7 +5353,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
// TODO: This may get slow. The "changed" parameter is provided for future optimization
// to avoid the slowness. It is not simply enough to process just "changed", for
// example in the case where "changed"'s score decreases and another network should begin
- // satifying a NetworkRequest that "changed" currently satisfies.
+ // satisfying a NetworkRequest that "changed" currently satisfies.
// Optimization: Only reprocess "changed" if its score improved. This is safe because it
// can only add more NetworkRequests satisfied by "changed", and this is exactly what
@@ -5597,11 +5464,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
if (networkAgent.isVPN()) {
// Temporarily disable the default proxy (not global).
- synchronized (mProxyLock) {
- if (!mDefaultProxyDisabled) {
- mDefaultProxyDisabled = true;
- if (mGlobalProxy == null && mDefaultProxy != null) {
- sendProxyBroadcast(null);
+ synchronized (mProxyTracker.mProxyLock) {
+ if (!mProxyTracker.mDefaultProxyDisabled) {
+ mProxyTracker.mDefaultProxyDisabled = true;
+ if (mProxyTracker.mGlobalProxy == null
+ && mProxyTracker.mDefaultProxy != null) {
+ mProxyTracker.sendProxyBroadcast(null);
}
}
}
@@ -5626,11 +5494,12 @@ public class ConnectivityService extends IConnectivityManager.Stub
} else if (state == NetworkInfo.State.DISCONNECTED) {
networkAgent.asyncChannel.disconnect();
if (networkAgent.isVPN()) {
- synchronized (mProxyLock) {
- if (mDefaultProxyDisabled) {
- mDefaultProxyDisabled = false;
- if (mGlobalProxy == null && mDefaultProxy != null) {
- sendProxyBroadcast(mDefaultProxy);
+ synchronized (mProxyTracker.mProxyLock) {
+ if (mProxyTracker.mDefaultProxyDisabled) {
+ mProxyTracker.mDefaultProxyDisabled = false;
+ if (mProxyTracker.mGlobalProxy == null
+ && mProxyTracker.mDefaultProxy != null) {
+ mProxyTracker.sendProxyBroadcast(mProxyTracker.mDefaultProxy);
}
}
}
@@ -5639,7 +5508,7 @@ public class ConnectivityService extends IConnectivityManager.Stub
disconnectAndDestroyNetwork(networkAgent);
} else if ((oldInfo != null && oldInfo.getState() == NetworkInfo.State.SUSPENDED) ||
state == NetworkInfo.State.SUSPENDED) {
- // going into or coming out of SUSPEND: rescore and notify
+ // going into or coming out of SUSPEND: re-score and notify
if (networkAgent.getCurrentScore() != oldScore) {
rematchAllNetworksAndRequests(networkAgent, oldScore);
}
diff --git a/services/core/java/com/android/server/IpSecService.java b/services/core/java/com/android/server/IpSecService.java
index 60f1877d3739..744ed25f160f 100644
--- a/services/core/java/com/android/server/IpSecService.java
+++ b/services/core/java/com/android/server/IpSecService.java
@@ -1481,19 +1481,23 @@ public class IpSecService extends IIpSecService.Stub {
}
}
+ private static final String TUNNEL_OP = "STOPSHIP"; // = AppOpsManager.OP_MANAGE_IPSEC_TUNNELS;
+
private void enforceTunnelPermissions(String callingPackage) {
checkNotNull(callingPackage, "Null calling package cannot create IpSec tunnels");
- switch (getAppOpsManager().noteOp(
- AppOpsManager.OP_MANAGE_IPSEC_TUNNELS,
- Binder.getCallingUid(), callingPackage)) {
- case AppOpsManager.MODE_DEFAULT:
- mContext.enforceCallingOrSelfPermission(
- android.Manifest.permission.MANAGE_IPSEC_TUNNELS, "IpSecService");
- break;
- case AppOpsManager.MODE_ALLOWED:
- return;
- default:
- throw new SecurityException("Request to ignore AppOps for non-legacy API");
+ if (false) { // STOPSHIP if this line is present
+ switch (getAppOpsManager().noteOp(
+ TUNNEL_OP,
+ Binder.getCallingUid(), callingPackage)) {
+ case AppOpsManager.MODE_DEFAULT:
+ mContext.enforceCallingOrSelfPermission(
+ android.Manifest.permission.MANAGE_IPSEC_TUNNELS, "IpSecService");
+ break;
+ case AppOpsManager.MODE_ALLOWED:
+ return;
+ default:
+ throw new SecurityException("Request to ignore AppOps for non-legacy API");
+ }
}
}
diff --git a/services/core/java/com/android/server/StorageManagerService.java b/services/core/java/com/android/server/StorageManagerService.java
index 183be9b98750..2deb759e5746 100644
--- a/services/core/java/com/android/server/StorageManagerService.java
+++ b/services/core/java/com/android/server/StorageManagerService.java
@@ -220,8 +220,12 @@ class StorageManagerService extends IStorageManager.Stub
private static final boolean DEBUG_EVENTS = false;
private static final boolean DEBUG_OBB = false;
- // Disable this since it messes up long-running cryptfs operations.
- private static final boolean WATCHDOG_ENABLE = false;
+ /**
+ * We now talk to vold over Binder, and it has its own internal lock to
+ * serialize certain calls. All long-running operations have been migrated
+ * to be async with callbacks, so we want watchdog to fire if vold wedges.
+ */
+ private static final boolean WATCHDOG_ENABLE = true;
/**
* Our goal is for all Android devices to be usable as development devices,
diff --git a/services/core/java/com/android/server/UiModeManagerService.java b/services/core/java/com/android/server/UiModeManagerService.java
index 6b5366a39a43..c29fc7f753a1 100644
--- a/services/core/java/com/android/server/UiModeManagerService.java
+++ b/services/core/java/com/android/server/UiModeManagerService.java
@@ -19,6 +19,7 @@ package com.android.server;
import android.annotation.Nullable;
import android.app.Activity;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.IUiModeManager;
import android.app.Notification;
import android.app.NotificationManager;
@@ -475,7 +476,7 @@ final class UiModeManagerService extends SystemService {
mSetUiMode = mConfiguration.uiMode;
try {
- ActivityManager.getService().updateConfiguration(mConfiguration);
+ ActivityTaskManager.getService().updateConfiguration(mConfiguration);
} catch (RemoteException e) {
Slog.w(TAG, "Failure communicating with activity manager", e);
}
@@ -637,7 +638,7 @@ final class UiModeManagerService extends SystemService {
Intent homeIntent = buildHomeIntent(category);
if (Sandman.shouldStartDockApp(getContext(), homeIntent)) {
try {
- int result = ActivityManager.getService().startActivityWithConfig(
+ int result = ActivityTaskManager.getService().startActivityWithConfig(
null, null, homeIntent, null, null, null, 0, 0,
mConfiguration, null, UserHandle.USER_CURRENT);
if (ActivityManager.isStartResultSuccessful(result)) {
diff --git a/services/core/java/com/android/server/am/ActivityManagerService.java b/services/core/java/com/android/server/am/ActivityManagerService.java
index 10639736847f..97c3fe4e48f4 100644
--- a/services/core/java/com/android/server/am/ActivityManagerService.java
+++ b/services/core/java/com/android/server/am/ActivityManagerService.java
@@ -29,9 +29,8 @@ import static android.Manifest.permission.REMOVE_TASKS;
import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.Manifest.permission.STOP_APP_SWITCHES;
import static android.app.ActivityManager.LOCK_TASK_MODE_NONE;
-import static android.app.ActivityManager.RESIZE_MODE_PRESERVE_WINDOW;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
-import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
+import static android.app.ActivityTaskManager.RESIZE_MODE_PRESERVE_WINDOW;
+import static android.app.ActivityTaskManager.INVALID_STACK_ID;
import static android.app.ActivityManagerInternal.ASSIST_KEY_CONTENT;
import static android.app.ActivityManagerInternal.ASSIST_KEY_DATA;
import static android.app.ActivityManagerInternal.ASSIST_KEY_RECEIVER_EXTRAS;
@@ -44,7 +43,6 @@ import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
-import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.content.Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS;
@@ -227,6 +225,7 @@ import android.app.ActivityManagerInternal.ScreenObserver;
import android.app.ActivityManagerInternal.SleepToken;
import android.app.ActivityManagerProto;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.app.ActivityThread;
import android.app.AlertDialog;
import android.app.AppGlobals;
@@ -342,6 +341,7 @@ import android.os.PowerManager;
import android.os.PowerManager.ServiceType;
import android.os.PowerManagerInternal;
import android.os.Process;
+import android.os.RemoteCallback;
import android.os.RemoteCallbackList;
import android.os.RemoteException;
import android.os.ResultReceiver;
@@ -601,17 +601,6 @@ public class ActivityManagerService extends IActivityManager.Stub
// Must be kept in sync with Am.
private static final int INSTRUMENTATION_FLAG_DISABLE_HIDDEN_API_CHECKS = 1 << 0;
- // How long to wait in getAssistContextExtras for the activity and foreground services
- // to respond with the result.
- static final int PENDING_ASSIST_EXTRAS_TIMEOUT = 500;
-
- // How long top wait when going through the modern assist (which doesn't need to block
- // on getting this result before starting to launch its UI).
- static final int PENDING_ASSIST_EXTRAS_LONG_TIMEOUT = 2000;
-
- // How long to wait in getAutofillAssistStructure() for the activity to respond with the result.
- static final int PENDING_AUTOFILL_ASSIST_STRUCTURE_TIMEOUT = 2000;
-
// Maximum number of persisted Uri grants a package is allowed
static final int MAX_PERSISTED_URI_GRANTS = 128;
@@ -679,9 +668,6 @@ public class ActivityManagerService extends IActivityManager.Stub
/** All system services */
SystemServiceManager mSystemServiceManager;
- // Wrapper around VoiceInteractionServiceManager
- private AssistUtils mAssistUtils;
-
// Keeps track of the active voice interaction service component, notified from
// VoiceInteractionManagerService
ComponentName mActiveVoiceInteractionServiceComponent;
@@ -690,7 +676,7 @@ public class ActivityManagerService extends IActivityManager.Stub
/** Run all ActivityStacks through this */
final ActivityStackSupervisor mStackSupervisor;
- private final KeyguardController mKeyguardController;
+ final KeyguardController mKeyguardController;
private final ActivityStartController mActivityStartController;
@@ -741,7 +727,7 @@ public class ActivityManagerService extends IActivityManager.Stub
* of the time but could be different when we're pausing one activity before we resume
* another activity.
*/
- private ActivityRecord mLastResumedActivity;
+ ActivityRecord mLastResumedActivity;
/**
* The activity that is currently being traced as the active resumed activity.
@@ -844,45 +830,6 @@ public class ActivityManagerService extends IActivityManager.Stub
sThreadPriorityBooster.reset();
}
- public class PendingAssistExtras extends Binder implements Runnable {
- public final ActivityRecord activity;
- public boolean isHome;
- public final Bundle extras;
- public final Intent intent;
- public final String hint;
- public final IAssistDataReceiver receiver;
- public final int userHandle;
- public boolean haveResult = false;
- public Bundle result = null;
- public AssistStructure structure = null;
- public AssistContent content = null;
- public Bundle receiverExtras;
-
- public PendingAssistExtras(ActivityRecord _activity, Bundle _extras, Intent _intent,
- String _hint, IAssistDataReceiver _receiver, Bundle _receiverExtras,
- int _userHandle) {
- activity = _activity;
- extras = _extras;
- intent = _intent;
- hint = _hint;
- receiver = _receiver;
- receiverExtras = _receiverExtras;
- userHandle = _userHandle;
- }
-
- @Override
- public void run() {
- Slog.w(TAG, "getAssistContextExtras failed: timeout retrieving from " + activity);
- synchronized (this) {
- haveResult = true;
- notifyAll();
- }
- pendingAssistExtrasTimedOut(this);
- }
- }
-
- final ArrayList<PendingAssistExtras> mPendingAssistExtras = new ArrayList<>();
-
/**
* Process management.
*/
@@ -1427,22 +1374,6 @@ public class ActivityManagerService extends IActivityManager.Stub
*/
private Configuration mTempConfig = new Configuration();
- private final UpdateConfigurationResult mTmpUpdateConfigurationResult =
- new UpdateConfigurationResult();
- private static final class UpdateConfigurationResult {
- // Configuration changes that were updated.
- int changes;
- // If the activity was relaunched to match the new configuration.
- boolean activityRelaunched;
-
- void reset() {
- changes = 0;
- activityRelaunched = false;
- }
- }
-
- boolean mSuppressResizeConfigChanges;
-
/**
* Hardware-reported OpenGLES version.
*/
@@ -1548,11 +1479,6 @@ public class ActivityManagerService extends IActivityManager.Stub
private int mWakefulness = PowerManagerInternal.WAKEFULNESS_AWAKE;
/**
- * State of external calls telling us if the device is awake or asleep.
- */
- private boolean mKeyguardShown = false;
-
- /**
* Set if we are shutting down the system, similar to sleeping.
*/
boolean mShuttingDown = false;
@@ -1859,6 +1785,7 @@ public class ActivityManagerService extends IActivityManager.Stub
int mBootPhase;
WindowManagerService mWindowManager;
+ ActivityTaskManagerService mActivityTaskManager;
final ActivityThread mSystemThread;
private final class AppDeathRecipient implements IBinder.DeathRecipient {
@@ -1973,10 +1900,6 @@ public class ActivityManagerService extends IActivityManager.Stub
PackageManagerInternal mPackageManagerInt;
- // VoiceInteraction session ID that changes for each new request except when
- // being called for multiwindow assist in a single session.
- private int mViSessionId = 1000;
-
final boolean mPermissionReviewRequired;
boolean mHasHeavyWeightFeature;
@@ -2776,6 +2699,14 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
+ public void setActivityTaskManager(ActivityTaskManagerService atm) {
+ synchronized (this) {
+ mActivityTaskManager = atm;
+ mStackSupervisor.setActivityTaskManager(atm);
+ mActivityTaskManager.setActivityManagerService(this);
+ }
+ }
+
public void setUsageStatsManager(UsageStatsManagerInternal usageStatsManager) {
mUsageStatsService = usageStatsManager;
}
@@ -3546,7 +3477,7 @@ public class ActivityManagerService extends IActivityManager.Stub
// move to something different. Just finish the session, we can't
// return to it and retain the proper state and synchronization with
// the voice interaction service.
- finishVoiceTask(session);
+ mActivityTaskManager.finishVoiceTask(session);
}
}
}
@@ -3586,74 +3517,21 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public void setFocusedStack(int stackId) {
- enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "setFocusedStack()");
- if (DEBUG_FOCUS) Slog.d(TAG_FOCUS, "setFocusedStack: stackId=" + stackId);
- final long callingId = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- final ActivityStack stack = mStackSupervisor.getStack(stackId);
- if (stack == null) {
- Slog.w(TAG, "setFocusedStack: No stack with id=" + stackId);
- return;
- }
- final ActivityRecord r = stack.topRunningActivityLocked();
- if (mStackSupervisor.moveFocusableActivityStackToFrontLocked(r, "setFocusedStack")) {
- mStackSupervisor.resumeFocusedStackTopActivityLocked();
- }
- }
- } finally {
- Binder.restoreCallingIdentity(callingId);
- }
- }
-
- @Override
- public void setFocusedTask(int taskId) {
- enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "setFocusedTask()");
- if (DEBUG_FOCUS) Slog.d(TAG_FOCUS, "setFocusedTask: taskId=" + taskId);
- final long callingId = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
- if (task == null) {
- return;
- }
- final ActivityRecord r = task.topRunningActivityLocked();
- if (mStackSupervisor.moveFocusableActivityStackToFrontLocked(r, "setFocusedTask")) {
- mStackSupervisor.resumeFocusedStackTopActivityLocked();
- }
- }
- } finally {
- Binder.restoreCallingIdentity(callingId);
- }
+ mActivityTaskManager.setFocusedStack(stackId);
}
/** Sets the task stack listener that gets callbacks when a task stack changes. */
@Override
- public void registerTaskStackListener(ITaskStackListener listener) throws RemoteException {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
- "registerTaskStackListener()");
- mTaskChangeNotificationController.registerTaskStackListener(listener);
+ public void registerTaskStackListener(ITaskStackListener listener) {
+ mActivityTaskManager.registerTaskStackListener(listener);
}
/**
* Unregister a task stack listener so that it stops receiving callbacks.
*/
@Override
- public void unregisterTaskStackListener(ITaskStackListener listener) throws RemoteException {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
- "unregisterTaskStackListener()");
- mTaskChangeNotificationController.unregisterTaskStackListener(listener);
- }
-
- @Override
- public void notifyActivityDrawn(IBinder token) {
- if (DEBUG_VISIBILITY) Slog.d(TAG_VISIBILITY, "notifyActivityDrawn: token=" + token);
- synchronized (this) {
- ActivityRecord r = mStackSupervisor.isInAnyStackLocked(token);
- if (r != null) {
- r.getStack().notifyActivityDrawnLocked(r);
- }
- }
+ public void unregisterTaskStackListener(ITaskStackListener listener) {
+ mActivityTaskManager.unregisterTaskStackListener(listener);
}
final void applyUpdateLockStateLocked(ActivityRecord r) {
@@ -3679,7 +3557,8 @@ public class ActivityManagerService extends IActivityManager.Stub
+ " to main stack for VR");
final ActivityStack stack = mStackSupervisor.getDefaultDisplay().getOrCreateStack(
WINDOWING_MODE_FULLSCREEN, r.getActivityType(), true /* toTop */);
- moveTaskToStack(r.getTask().taskId, stack.mStackId, true /* toTop */);
+ mActivityTaskManager.moveTaskToStack(r.getTask().taskId, stack.mStackId,
+ true /* toTop */);
}
mHandler.sendMessage(
mHandler.obtainMessage(VR_MODE_CHANGE_MSG, 0, 0, r));
@@ -4723,23 +4602,6 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public int getFrontActivityScreenCompatMode() {
- enforceNotIsolatedCaller("getFrontActivityScreenCompatMode");
- synchronized (this) {
- return mCompatModePackages.getFrontActivityScreenCompatModeLocked();
- }
- }
-
- @Override
- public void setFrontActivityScreenCompatMode(int mode) {
- enforceCallingPermission(android.Manifest.permission.SET_SCREEN_COMPATIBILITY,
- "setFrontActivityScreenCompatMode");
- synchronized (this) {
- mCompatModePackages.setFrontActivityScreenCompatModeLocked(mode);
- }
- }
-
- @Override
public int getPackageScreenCompatMode(String packageName) {
enforceNotIsolatedCaller("getPackageScreenCompatMode");
synchronized (this) {
@@ -5076,329 +4938,37 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public final int startActivity(IApplicationThread caller, String callingPackage,
+ public int startActivity(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
int startFlags, ProfilerInfo profilerInfo, Bundle bOptions) {
- return startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo,
- resultWho, requestCode, startFlags, profilerInfo, bOptions,
- UserHandle.getCallingUserId());
+ return mActivityTaskManager.startActivity(caller, callingPackage, intent, resolvedType,
+ resultTo, resultWho, requestCode, startFlags, profilerInfo, bOptions);
}
@Override
public final int startActivityAsUser(IApplicationThread caller, String callingPackage,
Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId) {
- return startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo,
- resultWho, requestCode, startFlags, profilerInfo, bOptions, userId,
- true /*validateIncomingUser*/);
- }
-
- public final int startActivityAsUser(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId,
- boolean validateIncomingUser) {
- enforceNotIsolatedCaller("startActivity");
-
- userId = mActivityStartController.checkTargetUser(userId, validateIncomingUser,
- Binder.getCallingPid(), Binder.getCallingUid(), "startActivityAsUser");
-
- // TODO: Switch to user app stacks here.
- return mActivityStartController.obtainStarter(intent, "startActivityAsUser")
- .setCaller(caller)
- .setCallingPackage(callingPackage)
- .setResolvedType(resolvedType)
- .setResultTo(resultTo)
- .setResultWho(resultWho)
- .setRequestCode(requestCode)
- .setStartFlags(startFlags)
- .setProfilerInfo(profilerInfo)
- .setActivityOptions(bOptions)
- .setMayWait(userId)
- .execute();
-
+ return mActivityTaskManager.startActivityAsUser(caller, callingPackage, intent,
+ resolvedType, resultTo, resultWho, requestCode, startFlags, profilerInfo, bOptions,
+ userId);
}
@Override
- public final int startActivityAsCaller(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, boolean ignoreTargetSecurity,
- int userId) {
-
- // This is very dangerous -- it allows you to perform a start activity (including
- // permission grants) as any app that may launch one of your own activities. So
- // we will only allow this to be done from activities that are part of the core framework,
- // and then only when they are running as the system.
- final ActivityRecord sourceRecord;
- final int targetUid;
- final String targetPackage;
- final boolean isResolver;
- synchronized (this) {
- if (resultTo == null) {
- throw new SecurityException("Must be called from an activity");
- }
- sourceRecord = mStackSupervisor.isInAnyStackLocked(resultTo);
- if (sourceRecord == null) {
- throw new SecurityException("Called with bad activity token: " + resultTo);
- }
- if (!sourceRecord.info.packageName.equals("android")) {
- throw new SecurityException(
- "Must be called from an activity that is declared in the android package");
- }
- if (sourceRecord.app == null) {
- throw new SecurityException("Called without a process attached to activity");
- }
- if (UserHandle.getAppId(sourceRecord.app.uid) != SYSTEM_UID) {
- // This is still okay, as long as this activity is running under the
- // uid of the original calling activity.
- if (sourceRecord.app.uid != sourceRecord.launchedFromUid) {
- throw new SecurityException(
- "Calling activity in uid " + sourceRecord.app.uid
- + " must be system uid or original calling uid "
- + sourceRecord.launchedFromUid);
- }
- }
- if (ignoreTargetSecurity) {
- if (intent.getComponent() == null) {
- throw new SecurityException(
- "Component must be specified with ignoreTargetSecurity");
- }
- if (intent.getSelector() != null) {
- throw new SecurityException(
- "Selector not allowed with ignoreTargetSecurity");
- }
- }
- targetUid = sourceRecord.launchedFromUid;
- targetPackage = sourceRecord.launchedFromPackage;
- isResolver = sourceRecord.isResolverOrChildActivity();
- }
-
- if (userId == UserHandle.USER_NULL) {
- userId = UserHandle.getUserId(sourceRecord.app.uid);
- }
-
- // TODO: Switch to user app stacks here.
- try {
- return mActivityStartController.obtainStarter(intent, "startActivityAsCaller")
- .setCallingUid(targetUid)
- .setCallingPackage(targetPackage)
- .setResolvedType(resolvedType)
- .setResultTo(resultTo)
- .setResultWho(resultWho)
- .setRequestCode(requestCode)
- .setStartFlags(startFlags)
- .setActivityOptions(bOptions)
- .setMayWait(userId)
- .setIgnoreTargetSecurity(ignoreTargetSecurity)
- .setFilterCallingUid(isResolver ? 0 /* system */ : targetUid)
- .execute();
- } catch (SecurityException e) {
- // XXX need to figure out how to propagate to original app.
- // A SecurityException here is generally actually a fault of the original
- // calling activity (such as a fairly granting permissions), so propagate it
- // back to them.
- /*
- StringBuilder msg = new StringBuilder();
- msg.append("While launching");
- msg.append(intent.toString());
- msg.append(": ");
- msg.append(e.getMessage());
- */
- throw e;
- }
- }
-
- @Override
- public final WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId) {
- enforceNotIsolatedCaller("startActivityAndWait");
- userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
- userId, false, ALLOW_FULL_ONLY, "startActivityAndWait", null);
- WaitResult res = new WaitResult();
- // TODO: Switch to user app stacks here.
- mActivityStartController.obtainStarter(intent, "startActivityAndWait")
- .setCaller(caller)
- .setCallingPackage(callingPackage)
- .setResolvedType(resolvedType)
- .setResultTo(resultTo)
- .setResultWho(resultWho)
- .setRequestCode(requestCode)
- .setStartFlags(startFlags)
- .setActivityOptions(bOptions)
- .setMayWait(userId)
- .setProfilerInfo(profilerInfo)
- .setWaitResult(res)
- .execute();
- return res;
- }
-
- @Override
- public final int startActivityWithConfig(IApplicationThread caller, String callingPackage,
- Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
- int startFlags, Configuration config, Bundle bOptions, int userId) {
- enforceNotIsolatedCaller("startActivityWithConfig");
- userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
- userId, false, ALLOW_FULL_ONLY, "startActivityWithConfig", null);
- // TODO: Switch to user app stacks here.
- return mActivityStartController.obtainStarter(intent, "startActivityWithConfig")
- .setCaller(caller)
- .setCallingPackage(callingPackage)
- .setResolvedType(resolvedType)
- .setResultTo(resultTo)
- .setResultWho(resultWho)
- .setRequestCode(requestCode)
- .setStartFlags(startFlags)
- .setGlobalConfiguration(config)
- .setActivityOptions(bOptions)
- .setMayWait(userId)
- .execute();
- }
-
- @Override
- public int startActivityIntentSender(IApplicationThread caller, IIntentSender target,
- IBinder whitelistToken, Intent fillInIntent, String resolvedType, IBinder resultTo,
- String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle bOptions)
- throws TransactionTooLargeException {
- enforceNotIsolatedCaller("startActivityIntentSender");
- // Refuse possible leaked file descriptors
- if (fillInIntent != null && fillInIntent.hasFileDescriptors()) {
- throw new IllegalArgumentException("File descriptors passed in Intent");
- }
-
- if (!(target instanceof PendingIntentRecord)) {
- throw new IllegalArgumentException("Bad PendingIntent object");
- }
-
- PendingIntentRecord pir = (PendingIntentRecord)target;
-
- synchronized (this) {
- // If this is coming from the currently resumed activity, it is
- // effectively saying that app switches are allowed at this point.
- final ActivityStack stack = getFocusedStack();
- if (stack.mResumedActivity != null &&
- stack.mResumedActivity.info.applicationInfo.uid == Binder.getCallingUid()) {
- mAppSwitchesAllowedTime = 0;
- }
- }
- int ret = pir.sendInner(0, fillInIntent, resolvedType, whitelistToken, null, null,
- resultTo, resultWho, requestCode, flagsMask, flagsValues, bOptions);
- return ret;
- }
-
- @Override
- public int startVoiceActivity(String callingPackage, int callingPid, int callingUid,
- Intent intent, String resolvedType, IVoiceInteractionSession session,
- IVoiceInteractor interactor, int startFlags, ProfilerInfo profilerInfo,
- Bundle bOptions, int userId) {
- enforceCallingPermission(BIND_VOICE_INTERACTION, "startVoiceActivity()");
- if (session == null || interactor == null) {
- throw new NullPointerException("null session or interactor");
- }
- userId = mUserController.handleIncomingUser(callingPid, callingUid, userId, false,
- ALLOW_FULL_ONLY, "startVoiceActivity", null);
- // TODO: Switch to user app stacks here.
- return mActivityStartController.obtainStarter(intent, "startVoiceActivity")
- .setCallingUid(callingUid)
- .setCallingPackage(callingPackage)
- .setResolvedType(resolvedType)
- .setVoiceSession(session)
- .setVoiceInteractor(interactor)
- .setStartFlags(startFlags)
- .setProfilerInfo(profilerInfo)
- .setActivityOptions(bOptions)
- .setMayWait(userId)
- .execute();
- }
-
- @Override
- public int startAssistantActivity(String callingPackage, int callingPid, int callingUid,
- Intent intent, String resolvedType, Bundle bOptions, int userId) {
- enforceCallingPermission(BIND_VOICE_INTERACTION, "startAssistantActivity()");
- userId = mUserController.handleIncomingUser(callingPid, callingUid, userId, false,
- ALLOW_FULL_ONLY, "startAssistantActivity", null);
-
- return mActivityStartController.obtainStarter(intent, "startAssistantActivity")
- .setCallingUid(callingUid)
- .setCallingPackage(callingPackage)
- .setResolvedType(resolvedType)
- .setActivityOptions(bOptions)
- .setMayWait(userId)
- .execute();
+ public final int startActivityFromRecents(int taskId, Bundle bOptions) {
+ return mActivityTaskManager.startActivityFromRecents(taskId, bOptions);
}
@Override
public void startRecentsActivity(Intent intent, IAssistDataReceiver assistDataReceiver,
- IRecentsAnimationRunner recentsAnimationRunner) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "startRecentsActivity()");
- final int callingPid = Binder.getCallingPid();
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- final ComponentName recentsComponent = mRecentTasks.getRecentsComponent();
- final int recentsUid = mRecentTasks.getRecentsComponentUid();
-
- // Start a new recents animation
- final RecentsAnimation anim = new RecentsAnimation(this, mStackSupervisor,
- mActivityStartController, mWindowManager, mUserController, callingPid);
- anim.startRecentsActivity(intent, recentsAnimationRunner, recentsComponent,
- recentsUid, assistDataReceiver);
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
+ IRecentsAnimationRunner recentsAnimationRunner) {
+ mActivityTaskManager.startRecentsActivity(
+ intent, assistDataReceiver, recentsAnimationRunner);
}
@Override
public void cancelRecentsAnimation(boolean restoreHomeStackPosition) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "cancelRecentsAnimation()");
- final long callingUid = Binder.getCallingUid();
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- // Cancel the recents animation synchronously (do not hold the WM lock)
- mWindowManager.cancelRecentsAnimationSynchronously(restoreHomeStackPosition
- ? REORDER_MOVE_TO_ORIGINAL_POSITION
- : REORDER_KEEP_IN_PLACE, "cancelRecentsAnimation/uid=" + callingUid);
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- @Override
- public void startLocalVoiceInteraction(IBinder callingActivity, Bundle options)
- throws RemoteException {
- Slog.i(TAG, "Activity tried to startVoiceInteraction");
- synchronized (this) {
- ActivityRecord activity = getFocusedStack().getTopActivity();
- if (ActivityRecord.forTokenLocked(callingActivity) != activity) {
- throw new SecurityException("Only focused activity can call startVoiceInteraction");
- }
- if (mRunningVoice != null || activity.getTask().voiceSession != null
- || activity.voiceSession != null) {
- Slog.w(TAG, "Already in a voice interaction, cannot start new voice interaction");
- return;
- }
- if (activity.pendingVoiceInteractionStart) {
- Slog.w(TAG, "Pending start of voice interaction already.");
- return;
- }
- activity.pendingVoiceInteractionStart = true;
- }
- LocalServices.getService(VoiceInteractionManagerInternal.class)
- .startLocalVoiceInteraction(callingActivity, options);
- }
-
- @Override
- public void stopLocalVoiceInteraction(IBinder callingActivity) throws RemoteException {
- LocalServices.getService(VoiceInteractionManagerInternal.class)
- .stopLocalVoiceInteraction(callingActivity);
- }
-
- @Override
- public boolean supportsLocalVoiceInteraction() throws RemoteException {
- return LocalServices.getService(VoiceInteractionManagerInternal.class)
- .supportsLocalVoiceInteraction();
+ mActivityTaskManager.cancelRecentsAnimation(restoreHomeStackPosition);
}
@GuardedBy("this")
@@ -5439,197 +5009,6 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
- @Override
- public boolean startNextMatchingActivity(IBinder callingActivity,
- Intent intent, Bundle bOptions) {
- // Refuse possible leaked file descriptors
- if (intent != null && intent.hasFileDescriptors() == true) {
- throw new IllegalArgumentException("File descriptors passed in Intent");
- }
- SafeActivityOptions options = SafeActivityOptions.fromBundle(bOptions);
-
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(callingActivity);
- if (r == null) {
- SafeActivityOptions.abort(options);
- return false;
- }
- if (r.app == null || r.app.thread == null) {
- // The caller is not running... d'oh!
- SafeActivityOptions.abort(options);
- return false;
- }
- intent = new Intent(intent);
- // The caller is not allowed to change the data.
- intent.setDataAndType(r.intent.getData(), r.intent.getType());
- // And we are resetting to find the next component...
- intent.setComponent(null);
-
- final boolean debug = ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
-
- ActivityInfo aInfo = null;
- try {
- List<ResolveInfo> resolves =
- AppGlobals.getPackageManager().queryIntentActivities(
- intent, r.resolvedType,
- PackageManager.MATCH_DEFAULT_ONLY | STOCK_PM_FLAGS,
- UserHandle.getCallingUserId()).getList();
-
- // Look for the original activity in the list...
- final int N = resolves != null ? resolves.size() : 0;
- for (int i=0; i<N; i++) {
- ResolveInfo rInfo = resolves.get(i);
- if (rInfo.activityInfo.packageName.equals(r.packageName)
- && rInfo.activityInfo.name.equals(r.info.name)) {
- // We found the current one... the next matching is
- // after it.
- i++;
- if (i<N) {
- aInfo = resolves.get(i).activityInfo;
- }
- if (debug) {
- Slog.v(TAG, "Next matching activity: found current " + r.packageName
- + "/" + r.info.name);
- Slog.v(TAG, "Next matching activity: next is " + ((aInfo == null)
- ? "null" : aInfo.packageName + "/" + aInfo.name));
- }
- break;
- }
- }
- } catch (RemoteException e) {
- }
-
- if (aInfo == null) {
- // Nobody who is next!
- SafeActivityOptions.abort(options);
- if (debug) Slog.d(TAG, "Next matching activity: nothing found");
- return false;
- }
-
- intent.setComponent(new ComponentName(
- aInfo.applicationInfo.packageName, aInfo.name));
- intent.setFlags(intent.getFlags()&~(
- Intent.FLAG_ACTIVITY_FORWARD_RESULT|
- Intent.FLAG_ACTIVITY_CLEAR_TOP|
- Intent.FLAG_ACTIVITY_MULTIPLE_TASK|
- FLAG_ACTIVITY_NEW_TASK));
-
- // Okay now we need to start the new activity, replacing the
- // currently running activity. This is a little tricky because
- // we want to start the new one as if the current one is finished,
- // but not finish the current one first so that there is no flicker.
- // And thus...
- final boolean wasFinishing = r.finishing;
- r.finishing = true;
-
- // Propagate reply information over to the new activity.
- final ActivityRecord resultTo = r.resultTo;
- final String resultWho = r.resultWho;
- final int requestCode = r.requestCode;
- r.resultTo = null;
- if (resultTo != null) {
- resultTo.removeResultsLocked(r, resultWho, requestCode);
- }
-
- final long origId = Binder.clearCallingIdentity();
- // TODO(b/64750076): Check if calling pid should really be -1.
- final int res = mActivityStartController
- .obtainStarter(intent, "startNextMatchingActivity")
- .setCaller(r.app.thread)
- .setResolvedType(r.resolvedType)
- .setActivityInfo(aInfo)
- .setResultTo(resultTo != null ? resultTo.appToken : null)
- .setResultWho(resultWho)
- .setRequestCode(requestCode)
- .setCallingPid(-1)
- .setCallingUid(r.launchedFromUid)
- .setCallingPackage(r.launchedFromPackage)
- .setRealCallingPid(-1)
- .setRealCallingUid(r.launchedFromUid)
- .setActivityOptions(options)
- .execute();
- Binder.restoreCallingIdentity(origId);
-
- r.finishing = wasFinishing;
- if (res != ActivityManager.START_SUCCESS) {
- return false;
- }
- return true;
- }
- }
-
- @Override
- public final int startActivityFromRecents(int taskId, Bundle bOptions) {
- enforceCallerIsRecentsOrHasPermission(START_TASKS_FROM_RECENTS,
- "startActivityFromRecents()");
-
- final int callingPid = Binder.getCallingPid();
- final int callingUid = Binder.getCallingUid();
- final SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle(bOptions);
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- return mStackSupervisor.startActivityFromRecents(callingPid, callingUid, taskId,
- safeOptions);
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- @Override
- public final int startActivities(IApplicationThread caller, String callingPackage,
- Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle bOptions,
- int userId) {
- final String reason = "startActivities";
- enforceNotIsolatedCaller(reason);
- userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
- userId, false, ALLOW_FULL_ONLY, reason, null);
- // TODO: Switch to user app stacks here.
- int ret = mActivityStartController.startActivities(caller, -1, callingPackage,
- intents, resolvedTypes, resultTo, SafeActivityOptions.fromBundle(bOptions), userId,
- reason);
- return ret;
- }
-
- @Override
- public void reportActivityFullyDrawn(IBinder token, boolean restoredFromBundle) {
- synchronized (this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return;
- }
- r.reportFullyDrawnLocked(restoredFromBundle);
- }
- }
-
- @Override
- public void setRequestedOrientation(IBinder token, int requestedOrientation) {
- synchronized (this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return;
- }
- final long origId = Binder.clearCallingIdentity();
- try {
- r.setRequestedOrientation(requestedOrientation);
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- }
-
- @Override
- public int getRequestedOrientation(IBinder token) {
- synchronized (this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
- }
- return r.getRequestedOrientation();
- }
- }
-
/**
* This is the internal entry point for handling Activity.finish().
*
@@ -5643,76 +5022,12 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public final boolean finishActivity(IBinder token, int resultCode, Intent resultData,
int finishTask) {
- // Refuse possible leaked file descriptors
- if (resultData != null && resultData.hasFileDescriptors() == true) {
- throw new IllegalArgumentException("File descriptors passed in Intent");
- }
-
- synchronized(this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return true;
- }
- // Keep track of the root activity of the task before we finish it
- TaskRecord tr = r.getTask();
- ActivityRecord rootR = tr.getRootActivity();
- if (rootR == null) {
- Slog.w(TAG, "Finishing task with all activities already finished");
- }
- // Do not allow task to finish if last task in lockTask mode. Launchable priv-apps can
- // finish.
- if (mLockTaskController.activityBlockedFromFinish(r)) {
- return false;
- }
-
- if (mController != null) {
- // Find the first activity that is not finishing.
- ActivityRecord next = r.getStack().topRunningActivityLocked(token, 0);
- if (next != null) {
- // ask watcher if this is allowed
- boolean resumeOK = true;
- try {
- resumeOK = mController.activityResuming(next.packageName);
- } catch (RemoteException e) {
- mController = null;
- Watchdog.getInstance().setActivityController(null);
- }
+ return mActivityTaskManager.finishActivity(token, resultCode, resultData, finishTask);
+ }
- if (!resumeOK) {
- Slog.i(TAG, "Not finishing activity because controller resumed");
- return false;
- }
- }
- }
- final long origId = Binder.clearCallingIdentity();
- try {
- boolean res;
- final boolean finishWithRootActivity =
- finishTask == Activity.FINISH_TASK_WITH_ROOT_ACTIVITY;
- if (finishTask == Activity.FINISH_TASK_WITH_ACTIVITY
- || (finishWithRootActivity && r == rootR)) {
- // If requested, remove the task that is associated to this activity only if it
- // was the root activity in the task. The result code and data is ignored
- // because we don't support returning them across task boundaries. Also, to
- // keep backwards compatibility we remove the task from recents when finishing
- // task with root activity.
- res = mStackSupervisor.removeTaskByIdLocked(tr.taskId, false,
- finishWithRootActivity, "finish-activity");
- if (!res) {
- Slog.i(TAG, "Removing task failed to finish activity");
- }
- } else {
- res = tr.getStack().requestFinishActivityLocked(token, resultCode,
- resultData, "app-request", true);
- if (!res) {
- Slog.i(TAG, "Failed to finish by app-request");
- }
- }
- return res;
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
+ @Override
+ public void setRequestedOrientation(IBinder token, int requestedOrientation) {
+ mActivityTaskManager.setRequestedOrientation(token, requestedOrientation);
}
@Override
@@ -5766,117 +5081,6 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
- @Override
- public final void finishSubActivity(IBinder token, String resultWho,
- int requestCode) {
- synchronized(this) {
- final long origId = Binder.clearCallingIdentity();
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r != null) {
- r.getStack().finishSubActivityLocked(r, resultWho, requestCode);
- }
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- @Override
- public boolean finishActivityAffinity(IBinder token) {
- synchronized(this) {
- final long origId = Binder.clearCallingIdentity();
- try {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return false;
- }
-
- // Do not allow task to finish if last task in lockTask mode. Launchable priv-apps
- // can finish.
- final TaskRecord task = r.getTask();
- if (mLockTaskController.activityBlockedFromFinish(r)) {
- return false;
- }
- return task.getStack().finishActivityAffinityLocked(r);
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- }
-
- @Override
- public void finishVoiceTask(IVoiceInteractionSession session) {
- synchronized (this) {
- final long origId = Binder.clearCallingIdentity();
- try {
- // TODO: VI Consider treating local voice interactions and voice tasks
- // differently here
- mStackSupervisor.finishVoiceTask(session);
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- }
-
- @Override
- public boolean releaseActivityInstance(IBinder token) {
- synchronized(this) {
- final long origId = Binder.clearCallingIdentity();
- try {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return false;
- }
- return r.getStack().safelyDestroyActivityLocked(r, "app-req");
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- }
-
- @Override
- public void releaseSomeActivities(IApplicationThread appInt) {
- synchronized(this) {
- final long origId = Binder.clearCallingIdentity();
- try {
- ProcessRecord app = getRecordForAppLocked(appInt);
- mStackSupervisor.releaseSomeActivitiesLocked(app, "low-mem");
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- }
-
- @Override
- public boolean willActivityBeVisible(IBinder token) {
- synchronized(this) {
- ActivityStack stack = ActivityRecord.getStackLocked(token);
- if (stack != null) {
- return stack.willActivityBeVisibleLocked(token);
- }
- return false;
- }
- }
-
- @Override
- public void overridePendingTransition(IBinder token, String packageName,
- int enterAnim, int exitAnim) {
- synchronized(this) {
- ActivityRecord self = ActivityRecord.isInStackLocked(token);
- if (self == null) {
- return;
- }
-
- final long origId = Binder.clearCallingIdentity();
-
- if (self.isState(ActivityState.RESUMED, ActivityState.PAUSING)) {
- mWindowManager.overridePendingAppTransition(packageName,
- enterAnim, exitAnim, null);
- }
-
- Binder.restoreCallingIdentity(origId);
- }
- }
-
/**
* Main function for removing an existing process from the activity manager
* as a result of that process going away. Clears out all connections
@@ -7803,25 +7007,6 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
- @Override
- public final void activityIdle(IBinder token, Configuration config, boolean stopProfiling) {
- final long origId = Binder.clearCallingIdentity();
- synchronized (this) {
- ActivityStack stack = ActivityRecord.getStackLocked(token);
- if (stack != null) {
- ActivityRecord r =
- mStackSupervisor.activityIdleInternalLocked(token, false /* fromTimeout */,
- false /* processPausingActivities */, config);
- if (stopProfiling) {
- if ((mProfileProc == r.app) && mProfilerInfo != null) {
- clearProfilerLocked();
- }
- }
- }
- }
- Binder.restoreCallingIdentity(origId);
- }
-
void postFinishBooting(boolean finishBooting, boolean enableScreen) {
mHandler.sendMessage(mHandler.obtainMessage(FINISH_BOOTING_MSG,
finishBooting ? 1 : 0, enableScreen ? 1 : 0));
@@ -7845,19 +7030,6 @@ public class ActivityManagerService extends IActivityManager.Stub
mWindowManager.showBootMessage(msg, always);
}
- @Override
- public void keyguardGoingAway(int flags) {
- enforceNotIsolatedCaller("keyguardGoingAway");
- final long token = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- mKeyguardController.keyguardGoingAway(flags);
- }
- } finally {
- Binder.restoreCallingIdentity(token);
- }
- }
-
/**
* @return whther the keyguard is currently locked.
*/
@@ -8009,155 +7181,6 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public final void activityResumed(IBinder token) {
- final long origId = Binder.clearCallingIdentity();
- synchronized(this) {
- ActivityRecord.activityResumedLocked(token);
- mWindowManager.notifyAppResumedFinished(token);
- }
- Binder.restoreCallingIdentity(origId);
- }
-
- @Override
- public final void activityPaused(IBinder token) {
- final long origId = Binder.clearCallingIdentity();
- synchronized(this) {
- ActivityStack stack = ActivityRecord.getStackLocked(token);
- if (stack != null) {
- stack.activityPausedLocked(token, false);
- }
- }
- Binder.restoreCallingIdentity(origId);
- }
-
- @Override
- public final void activityStopped(IBinder token, Bundle icicle,
- PersistableBundle persistentState, CharSequence description) {
- if (DEBUG_ALL) Slog.v(TAG, "Activity stopped: token=" + token);
-
- // Refuse possible leaked file descriptors
- if (icicle != null && icicle.hasFileDescriptors()) {
- throw new IllegalArgumentException("File descriptors passed in Bundle");
- }
-
- final long origId = Binder.clearCallingIdentity();
-
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r != null) {
- r.activityStoppedLocked(icicle, persistentState, description);
- }
- }
-
- trimApplications();
-
- Binder.restoreCallingIdentity(origId);
- }
-
- @Override
- public final void activityDestroyed(IBinder token) {
- if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "ACTIVITY DESTROYED: " + token);
- synchronized (this) {
- ActivityStack stack = ActivityRecord.getStackLocked(token);
- if (stack != null) {
- stack.activityDestroyedLocked(token, "activityDestroyed");
- }
- }
- }
-
- @Override
- public final void activityRelaunched(IBinder token) {
- final long origId = Binder.clearCallingIdentity();
- synchronized (this) {
- mStackSupervisor.activityRelaunchedLocked(token);
- }
- Binder.restoreCallingIdentity(origId);
- }
-
- @Override
- public void reportSizeConfigurations(IBinder token, int[] horizontalSizeConfiguration,
- int[] verticalSizeConfigurations, int[] smallestSizeConfigurations) {
- if (DEBUG_CONFIGURATION) Slog.v(TAG, "Report configuration: " + token + " "
- + horizontalSizeConfiguration + " " + verticalSizeConfigurations);
- synchronized (this) {
- ActivityRecord record = ActivityRecord.isInStackLocked(token);
- if (record == null) {
- throw new IllegalArgumentException("reportSizeConfigurations: ActivityRecord not "
- + "found for: " + token);
- }
- record.setSizeConfigurations(horizontalSizeConfiguration,
- verticalSizeConfigurations, smallestSizeConfigurations);
- }
- }
-
- @Override
- public final void notifyLaunchTaskBehindComplete(IBinder token) {
- mStackSupervisor.scheduleLaunchTaskBehindComplete(token);
- }
-
- @Override
- public final void notifyEnterAnimationComplete(IBinder token) {
- mHandler.sendMessage(mHandler.obtainMessage(ENTER_ANIMATION_COMPLETE_MSG, token));
- }
-
- @Override
- public String getCallingPackage(IBinder token) {
- synchronized (this) {
- ActivityRecord r = getCallingRecordLocked(token);
- return r != null ? r.info.packageName : null;
- }
- }
-
- @Override
- public ComponentName getCallingActivity(IBinder token) {
- synchronized (this) {
- ActivityRecord r = getCallingRecordLocked(token);
- return r != null ? r.intent.getComponent() : null;
- }
- }
-
- private ActivityRecord getCallingRecordLocked(IBinder token) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return null;
- }
- return r.resultTo;
- }
-
- @Override
- public ComponentName getActivityClassForToken(IBinder token) {
- synchronized(this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return null;
- }
- return r.intent.getComponent();
- }
- }
-
- @Override
- public String getPackageForToken(IBinder token) {
- synchronized(this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return null;
- }
- return r.packageName;
- }
- }
-
- @Override
- public boolean isRootVoiceInteraction(IBinder token) {
- synchronized(this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return false;
- }
- return r.rootVoiceInteraction;
- }
- }
-
- @Override
public IIntentSender getIntentSender(int type,
String packageName, IBinder token, String resultWho,
int requestCode, Intent[] intents, String[] resolvedTypes,
@@ -8649,199 +7672,6 @@ public class ActivityManagerService extends IActivityManager.Stub
return uidRec == null ? ActivityManager.PROCESS_STATE_NONEXISTENT : uidRec.curProcState;
}
- @Override
- public boolean isInMultiWindowMode(IBinder token) {
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized(this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return false;
- }
- // An activity is consider to be in multi-window mode if its task isn't fullscreen.
- return r.inMultiWindowMode();
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- @Override
- public boolean isInPictureInPictureMode(IBinder token) {
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized(this) {
- return isInPictureInPictureMode(ActivityRecord.forTokenLocked(token));
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- private boolean isInPictureInPictureMode(ActivityRecord r) {
- if (r == null || r.getStack() == null || !r.inPinnedWindowingMode()
- || r.getStack().isInStackLocked(r) == null) {
- return false;
- }
-
- // If we are animating to fullscreen then we have already dispatched the PIP mode
- // changed, so we should reflect that check here as well.
- final PinnedActivityStack stack = r.getStack();
- final PinnedStackWindowController windowController = stack.getWindowContainerController();
- return !windowController.isAnimatingBoundsToFullscreen();
- }
-
- @Override
- public boolean enterPictureInPictureMode(IBinder token, final PictureInPictureParams params) {
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized(this) {
- final ActivityRecord r = ensureValidPictureInPictureActivityParamsLocked(
- "enterPictureInPictureMode", token, params);
-
- // If the activity is already in picture in picture mode, then just return early
- if (isInPictureInPictureMode(r)) {
- return true;
- }
-
- // Activity supports picture-in-picture, now check that we can enter PiP at this
- // point, if it is
- if (!r.checkEnterPictureInPictureState("enterPictureInPictureMode",
- false /* beforeStopping */)) {
- return false;
- }
-
- final Runnable enterPipRunnable = () -> {
- // Only update the saved args from the args that are set
- r.pictureInPictureArgs.copyOnlySet(params);
- final float aspectRatio = r.pictureInPictureArgs.getAspectRatio();
- final List<RemoteAction> actions = r.pictureInPictureArgs.getActions();
- // Adjust the source bounds by the insets for the transition down
- final Rect sourceBounds = new Rect(r.pictureInPictureArgs.getSourceRectHint());
- mStackSupervisor.moveActivityToPinnedStackLocked(r, sourceBounds, aspectRatio,
- "enterPictureInPictureMode");
- final PinnedActivityStack stack = r.getStack();
- stack.setPictureInPictureAspectRatio(aspectRatio);
- stack.setPictureInPictureActions(actions);
- MetricsLoggerWrapper.logPictureInPictureEnter(mContext, r.appInfo.uid,
- r.shortComponentName, r.supportsEnterPipOnTaskSwitch);
- logPictureInPictureArgs(params);
- };
-
- if (isKeyguardLocked()) {
- // If the keyguard is showing or occluded, then try and dismiss it before
- // entering picture-in-picture (this will prompt the user to authenticate if the
- // device is currently locked).
- try {
- dismissKeyguard(token, new KeyguardDismissCallback() {
- @Override
- public void onDismissSucceeded() throws RemoteException {
- mHandler.post(enterPipRunnable);
- }
- }, null /* message */);
- } catch (RemoteException e) {
- // Local call
- }
- } else {
- // Enter picture in picture immediately otherwise
- enterPipRunnable.run();
- }
- return true;
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- @Override
- public void setPictureInPictureParams(IBinder token, final PictureInPictureParams params) {
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized(this) {
- final ActivityRecord r = ensureValidPictureInPictureActivityParamsLocked(
- "setPictureInPictureParams", token, params);
-
- // Only update the saved args from the args that are set
- r.pictureInPictureArgs.copyOnlySet(params);
- if (r.inPinnedWindowingMode()) {
- // If the activity is already in picture-in-picture, update the pinned stack now
- // if it is not already expanding to fullscreen. Otherwise, the arguments will
- // be used the next time the activity enters PiP
- final PinnedActivityStack stack = r.getStack();
- if (!stack.isAnimatingBoundsToFullscreen()) {
- stack.setPictureInPictureAspectRatio(
- r.pictureInPictureArgs.getAspectRatio());
- stack.setPictureInPictureActions(r.pictureInPictureArgs.getActions());
- }
- }
- logPictureInPictureArgs(params);
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- @Override
- public int getMaxNumPictureInPictureActions(IBinder token) {
- // Currently, this is a static constant, but later, we may change this to be dependent on
- // the context of the activity
- return 3;
- }
-
- private void logPictureInPictureArgs(PictureInPictureParams params) {
- if (params.hasSetActions()) {
- MetricsLogger.histogram(mContext, "tron_varz_picture_in_picture_actions_count",
- params.getActions().size());
- }
- if (params.hasSetAspectRatio()) {
- LogMaker lm = new LogMaker(MetricsEvent.ACTION_PICTURE_IN_PICTURE_ASPECT_RATIO_CHANGED);
- lm.addTaggedData(MetricsEvent.PICTURE_IN_PICTURE_ASPECT_RATIO, params.getAspectRatio());
- MetricsLogger.action(lm);
- }
- }
-
- /**
- * Checks the state of the system and the activity associated with the given {@param token} to
- * verify that picture-in-picture is supported for that activity.
- *
- * @return the activity record for the given {@param token} if all the checks pass.
- */
- private ActivityRecord ensureValidPictureInPictureActivityParamsLocked(String caller,
- IBinder token, PictureInPictureParams params) {
- if (!mSupportsPictureInPicture) {
- throw new IllegalStateException(caller
- + ": Device doesn't support picture-in-picture mode.");
- }
-
- final ActivityRecord r = ActivityRecord.forTokenLocked(token);
- if (r == null) {
- throw new IllegalStateException(caller
- + ": Can't find activity for token=" + token);
- }
-
- if (!r.supportsPictureInPicture()) {
- throw new IllegalStateException(caller
- + ": Current activity does not support picture-in-picture.");
- }
-
- if (params.hasSetAspectRatio()
- && !mWindowManager.isValidPictureInPictureAspectRatio(r.getStack().mDisplayId,
- params.getAspectRatio())) {
- final float minAspectRatio = mContext.getResources().getFloat(
- com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio);
- final float maxAspectRatio = mContext.getResources().getFloat(
- com.android.internal.R.dimen.config_pictureInPictureMaxAspectRatio);
- throw new IllegalArgumentException(String.format(caller
- + ": Aspect ratio is too extreme (must be between %f and %f).",
- minAspectRatio, maxAspectRatio));
- }
-
- // Truncate the number of actions if necessary
- params.truncateActions(getMaxNumPictureInPictureActions(token));
-
- return r;
- }
-
// =========================================================
// PROCESS INFO
// =========================================================
@@ -10056,18 +8886,6 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
- @Override
- public IBinder getUriPermissionOwnerForActivity(IBinder activityToken) {
- enforceNotIsolatedCaller("getUriPermissionOwnerForActivity");
- synchronized(this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(activityToken);
- if (r == null) {
- throw new IllegalArgumentException("Activity does not exist; token="
- + activityToken);
- }
- return r.getUriPermissionsLocked().getExternalTokenLocked();
- }
- }
/**
* @param uri This uri must NOT contain an embedded userId.
* @param sourceUserId The userId in which the uri is to be resolved.
@@ -10517,42 +9335,23 @@ public class ActivityManagerService extends IActivityManager.Stub
// =========================================================
@Override
- public List<IBinder> getAppTasks(String callingPackage) {
- int callingUid = Binder.getCallingUid();
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized(this) {
- return mRecentTasks.getAppTasksList(callingUid, callingPackage);
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- @Override
public List<RunningTaskInfo> getTasks(int maxNum) {
- return getFilteredTasks(maxNum, ACTIVITY_TYPE_UNDEFINED, WINDOWING_MODE_UNDEFINED);
+ return mActivityTaskManager.getTasks(maxNum);
}
@Override
public List<RunningTaskInfo> getFilteredTasks(int maxNum, @ActivityType int ignoreActivityType,
@WindowingMode int ignoreWindowingMode) {
- final int callingUid = Binder.getCallingUid();
- ArrayList<RunningTaskInfo> list = new ArrayList<>();
-
- synchronized(this) {
- if (DEBUG_ALL) Slog.v(TAG, "getTasks: max=" + maxNum);
-
- final boolean allowed = isGetTasksAllowed("getTasks", Binder.getCallingPid(),
- callingUid);
- mStackSupervisor.getRunningTasks(maxNum, list, ignoreActivityType,
- ignoreWindowingMode, callingUid, allowed);
- }
+ return mActivityTaskManager.getFilteredTasks(
+ maxNum, ignoreActivityType, ignoreWindowingMode);
+ }
- return list;
+ @Override
+ public void cancelTaskWindowTransition(int taskId) {
+ mActivityTaskManager.cancelTaskWindowTransition(taskId);
}
- private boolean isGetTasksAllowed(String caller, int callingPid, int callingUid) {
+ boolean isGetTasksAllowed(String caller, int callingPid, int callingUid) {
if (mRecentTasks.isCallerRecents(callingUid)) {
// Always allow the recents component to get tasks
return true;
@@ -10585,426 +9384,38 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags,
- int userId) {
- final int callingUid = Binder.getCallingUid();
- userId = mUserController.handleIncomingUser(Binder.getCallingPid(), callingUid, userId,
- false, ALLOW_FULL_ONLY, "getRecentTasks", null);
- final boolean allowed = isGetTasksAllowed("getRecentTasks", Binder.getCallingPid(),
- callingUid);
- final boolean detailed = checkCallingPermission(
- android.Manifest.permission.GET_DETAILED_TASKS)
- == PackageManager.PERMISSION_GRANTED;
-
- synchronized (this) {
- return mRecentTasks.getRecentTasks(maxNum, flags, allowed, detailed, userId,
- callingUid);
- }
- }
-
- @Override
- public ActivityManager.TaskDescription getTaskDescription(int id) {
- synchronized (this) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "getTaskDescription()");
- final TaskRecord tr = mStackSupervisor.anyTaskForIdLocked(id,
- MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
- if (tr != null) {
- return tr.lastTaskDescription;
- }
- }
- return null;
- }
-
- @Override
- public int addAppTask(IBinder activityToken, Intent intent,
- ActivityManager.TaskDescription description, Bitmap thumbnail) throws RemoteException {
- final int callingUid = Binder.getCallingUid();
- final long callingIdent = Binder.clearCallingIdentity();
-
- try {
- synchronized (this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(activityToken);
- if (r == null) {
- throw new IllegalArgumentException("Activity does not exist; token="
- + activityToken);
- }
- ComponentName comp = intent.getComponent();
- if (comp == null) {
- throw new IllegalArgumentException("Intent " + intent
- + " must specify explicit component");
- }
- if (thumbnail.getWidth() != mThumbnailWidth
- || thumbnail.getHeight() != mThumbnailHeight) {
- throw new IllegalArgumentException("Bad thumbnail size: got "
- + thumbnail.getWidth() + "x" + thumbnail.getHeight() + ", require "
- + mThumbnailWidth + "x" + mThumbnailHeight);
- }
- if (intent.getSelector() != null) {
- intent.setSelector(null);
- }
- if (intent.getSourceBounds() != null) {
- intent.setSourceBounds(null);
- }
- if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0) {
- if ((intent.getFlags()&Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS) == 0) {
- // The caller has added this as an auto-remove task... that makes no
- // sense, so turn off auto-remove.
- intent.addFlags(Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS);
- }
- }
- final ActivityInfo ainfo = AppGlobals.getPackageManager().getActivityInfo(comp,
- STOCK_PM_FLAGS, UserHandle.getUserId(callingUid));
- if (ainfo.applicationInfo.uid != callingUid) {
- throw new SecurityException(
- "Can't add task for another application: target uid="
- + ainfo.applicationInfo.uid + ", calling uid=" + callingUid);
- }
-
- final ActivityStack stack = r.getStack();
- final TaskRecord task = stack.createTaskRecord(
- mStackSupervisor.getNextTaskIdForUserLocked(r.userId), ainfo, intent,
- null /* voiceSession */, null /* voiceInteractor */, !ON_TOP);
- if (!mRecentTasks.addToBottom(task)) {
- // The app has too many tasks already and we can't add any more
- stack.removeTask(task, "addAppTask", REMOVE_TASK_MODE_DESTROYING);
- return INVALID_TASK_ID;
- }
- task.lastTaskDescription.copyFrom(description);
-
- // TODO: Send the thumbnail to WM to store it.
-
- return task.taskId;
- }
- } finally {
- Binder.restoreCallingIdentity(callingIdent);
- }
- }
-
- @Override
- public Point getAppTaskThumbnailSize() {
- synchronized (this) {
- return new Point(mThumbnailWidth, mThumbnailHeight);
- }
- }
-
- @Override
- public void setTaskDescription(IBinder token, ActivityManager.TaskDescription td) {
- synchronized (this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r != null) {
- r.setTaskDescription(td);
- final TaskRecord task = r.getTask();
- task.updateTaskDescription();
- mTaskChangeNotificationController.notifyTaskDescriptionChanged(task.taskId, td);
- }
- }
+ public void setTaskResizeable(int taskId, int resizeableMode) {
+ mActivityTaskManager.setTaskResizeable(taskId, resizeableMode);
}
@Override
- public void setTaskResizeable(int taskId, int resizeableMode) {
- synchronized (this) {
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(
- taskId, MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
- if (task == null) {
- Slog.w(TAG, "setTaskResizeable: taskId=" + taskId + " not found");
- return;
- }
- task.setResizeMode(resizeableMode);
- }
+ public ActivityManager.TaskSnapshot getTaskSnapshot(int taskId, boolean reducedResolution) {
+ return mActivityTaskManager.getTaskSnapshot(taskId, reducedResolution);
}
@Override
public void resizeTask(int taskId, Rect bounds, int resizeMode) {
- enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "resizeTask()");
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
- if (task == null) {
- Slog.w(TAG, "resizeTask: taskId=" + taskId + " not found");
- return;
- }
- // Place the task in the right stack if it isn't there already based on
- // the requested bounds.
- // The stack transition logic is:
- // - a null bounds on a freeform task moves that task to fullscreen
- // - a non-null bounds on a non-freeform (fullscreen OR docked) task moves
- // that task to freeform
- // - otherwise the task is not moved
- ActivityStack stack = task.getStack();
- if (!task.getWindowConfiguration().canResizeTask()) {
- throw new IllegalArgumentException("resizeTask not allowed on task=" + task);
- }
- if (bounds == null && stack.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
- stack = stack.getDisplay().getOrCreateStack(
- WINDOWING_MODE_FULLSCREEN, stack.getActivityType(), ON_TOP);
- } else if (bounds != null && stack.getWindowingMode() != WINDOWING_MODE_FREEFORM) {
- stack = stack.getDisplay().getOrCreateStack(
- WINDOWING_MODE_FREEFORM, stack.getActivityType(), ON_TOP);
- }
-
- // Reparent the task to the right stack if necessary
- boolean preserveWindow = (resizeMode & RESIZE_MODE_PRESERVE_WINDOW) != 0;
- if (stack != task.getStack()) {
- // Defer resume until the task is resized below
- task.reparent(stack, ON_TOP, REPARENT_KEEP_STACK_AT_FRONT, ANIMATE,
- DEFER_RESUME, "resizeTask");
- preserveWindow = false;
- }
-
- // After reparenting (which only resizes the task to the stack bounds), resize the
- // task to the actual bounds provided
- task.resize(bounds, resizeMode, preserveWindow, !DEFER_RESUME);
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ mActivityTaskManager.resizeTask(taskId, bounds, resizeMode);
}
@Override
public Rect getTaskBounds(int taskId) {
- enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "getTaskBounds()");
- long ident = Binder.clearCallingIdentity();
- Rect rect = new Rect();
- try {
- synchronized (this) {
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId,
- MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
- if (task == null) {
- Slog.w(TAG, "getTaskBounds: taskId=" + taskId + " not found");
- return rect;
- }
- if (task.getStack() != null) {
- // Return the bounds from window manager since it will be adjusted for various
- // things like the presense of a docked stack for tasks that aren't resizeable.
- task.getWindowContainerBounds(rect);
- } else {
- // Task isn't in window manager yet since it isn't associated with a stack.
- // Return the persist value from activity manager
- if (!task.matchParentBounds()) {
- rect.set(task.getBounds());
- } else if (task.mLastNonFullscreenBounds != null) {
- rect.set(task.mLastNonFullscreenBounds);
- }
- }
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- return rect;
- }
-
- @Override
- public void cancelTaskWindowTransition(int taskId) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
- "cancelTaskWindowTransition()");
- final long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId,
- MATCH_TASK_IN_STACKS_ONLY);
- if (task == null) {
- Slog.w(TAG, "cancelTaskWindowTransition: taskId=" + taskId + " not found");
- return;
- }
- task.cancelWindowTransition();
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- @Override
- public TaskSnapshot getTaskSnapshot(int taskId, boolean reducedResolution) {
- enforceCallerIsRecentsOrHasPermission(READ_FRAME_BUFFER, "getTaskSnapshot()");
- final long ident = Binder.clearCallingIdentity();
- try {
- final TaskRecord task;
- synchronized (this) {
- task = mStackSupervisor.anyTaskForIdLocked(taskId,
- MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
- if (task == null) {
- Slog.w(TAG, "getTaskSnapshot: taskId=" + taskId + " not found");
- return null;
- }
- }
- // Don't call this while holding the lock as this operation might hit the disk.
- return task.getSnapshot(reducedResolution);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- @Override
- public Bitmap getTaskDescriptionIcon(String filePath, int userId) {
- userId = mUserController.handleIncomingUser(Binder.getCallingPid(), Binder.getCallingUid(),
- userId, false, ALLOW_FULL_ONLY, "getTaskDescriptionIcon", null);
-
- final File passedIconFile = new File(filePath);
- final File legitIconFile = new File(TaskPersister.getUserImagesDir(userId),
- passedIconFile.getName());
- if (!legitIconFile.getPath().equals(filePath)
- || !filePath.contains(ActivityRecord.ACTIVITY_ICON_SUFFIX)) {
- throw new IllegalArgumentException("Bad file path: " + filePath
- + " passed for userId " + userId);
- }
- return mRecentTasks.getTaskDescriptionIcon(filePath);
- }
-
- @Override
- public void startInPlaceAnimationOnFrontMostApplication(Bundle opts)
- throws RemoteException {
- final SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle(opts);
- final ActivityOptions activityOptions = safeOptions != null
- ? safeOptions.getOptions(mStackSupervisor)
- : null;
- if (activityOptions == null
- || activityOptions.getAnimationType() != ActivityOptions.ANIM_CUSTOM_IN_PLACE
- || activityOptions.getCustomInPlaceResId() == 0) {
- throw new IllegalArgumentException("Expected in-place ActivityOption " +
- "with valid animation");
- }
- mWindowManager.prepareAppTransition(TRANSIT_TASK_IN_PLACE, false);
- mWindowManager.overridePendingAppTransitionInPlace(activityOptions.getPackageName(),
- activityOptions.getCustomInPlaceResId());
- mWindowManager.executeAppTransition();
+ return mActivityTaskManager.getTaskBounds(taskId);
}
@Override
public void removeStack(int stackId) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "removeStack()");
- synchronized (this) {
- final long ident = Binder.clearCallingIdentity();
- try {
- final ActivityStack stack = mStackSupervisor.getStack(stackId);
- if (stack == null) {
- Slog.w(TAG, "removeStack: No stack with id=" + stackId);
- return;
- }
- if (!stack.isActivityTypeStandardOrUndefined()) {
- throw new IllegalArgumentException(
- "Removing non-standard stack is not allowed.");
- }
- mStackSupervisor.removeStack(stack);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
- }
-
- /**
- * Removes stacks in the input windowing modes from the system if they are of activity type
- * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
- */
- @Override
- public void removeStacksInWindowingModes(int[] windowingModes) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
- "removeStacksInWindowingModes()");
- synchronized (this) {
- final long ident = Binder.clearCallingIdentity();
- try {
- mStackSupervisor.removeStacksInWindowingModes(windowingModes);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
- }
-
- @Override
- public void removeStacksWithActivityTypes(int[] activityTypes) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
- "removeStacksWithActivityTypes()");
- synchronized (this) {
- final long ident = Binder.clearCallingIdentity();
- try {
- mStackSupervisor.removeStacksWithActivityTypes(activityTypes);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
- }
-
- @Override
- public void moveStackToDisplay(int stackId, int displayId) {
- enforceCallingPermission(INTERNAL_SYSTEM_WINDOW, "moveStackToDisplay()");
-
- synchronized (this) {
- final long ident = Binder.clearCallingIdentity();
- try {
- if (DEBUG_STACK) Slog.d(TAG_STACK, "moveStackToDisplay: moving stackId=" + stackId
- + " to displayId=" + displayId);
- mStackSupervisor.moveStackToDisplayLocked(stackId, displayId, ON_TOP);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ mActivityTaskManager.removeStack(stackId);
}
@Override
public boolean removeTask(int taskId) {
- enforceCallerIsRecentsOrHasPermission(REMOVE_TASKS, "removeTask()");
- synchronized (this) {
- final long ident = Binder.clearCallingIdentity();
- try {
- return mStackSupervisor.removeTaskByIdLocked(taskId, true, REMOVE_FROM_RECENTS,
- "remove-task");
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ return mActivityTaskManager.removeTask(taskId);
}
- /**
- * TODO: Add mController hook
- */
@Override
public void moveTaskToFront(int taskId, int flags, Bundle bOptions) {
- enforceCallingPermission(android.Manifest.permission.REORDER_TASKS, "moveTaskToFront()");
-
- if (DEBUG_STACK) Slog.d(TAG_STACK, "moveTaskToFront: moving taskId=" + taskId);
- synchronized(this) {
- moveTaskToFrontLocked(taskId, flags, SafeActivityOptions.fromBundle(bOptions),
- false /* fromRecents */);
- }
- }
-
- void moveTaskToFrontLocked(int taskId, int flags, SafeActivityOptions options,
- boolean fromRecents) {
-
- if (!checkAppSwitchAllowedLocked(Binder.getCallingPid(),
- Binder.getCallingUid(), -1, -1, "Task to front")) {
- SafeActivityOptions.abort(options);
- return;
- }
- final long origId = Binder.clearCallingIdentity();
- try {
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
- if (task == null) {
- Slog.d(TAG, "Could not find task for id: "+ taskId);
- return;
- }
- if (mLockTaskController.isLockTaskModeViolation(task)) {
- Slog.e(TAG, "moveTaskToFront: Attempt to violate Lock Task Mode");
- return;
- }
- ActivityOptions realOptions = options != null
- ? options.getOptions(mStackSupervisor)
- : null;
- mStackSupervisor.findTaskToMoveToFront(task, flags, realOptions, "moveTaskToFront",
- false /* forceNonResizable */);
-
- final ActivityRecord topActivity = task.getTopActivity();
- if (topActivity != null) {
-
- // We are reshowing a task, use a starting window to hide the initial draw delay
- // so the transition can start earlier.
- topActivity.showStartingWindow(null /* prev */, false /* newTask */,
- true /* taskSwitch */, fromRecents);
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- SafeActivityOptions.abort(options);
+ mActivityTaskManager.moveTaskToFront(taskId, flags, bOptions);
}
/**
@@ -11028,290 +9439,25 @@ public class ActivityManagerService extends IActivityManager.Stub
*/
@Override
public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot) {
- enforceNotIsolatedCaller("moveActivityTaskToBack");
- synchronized(this) {
- final long origId = Binder.clearCallingIdentity();
- try {
- int taskId = ActivityRecord.getTaskForActivityLocked(token, !nonRoot);
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
- if (task != null) {
- return ActivityRecord.getStackLocked(token).moveTaskToBackLocked(taskId);
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- return false;
- }
-
- @Override
- public void moveTaskBackwards(int task) {
- enforceCallingPermission(android.Manifest.permission.REORDER_TASKS,
- "moveTaskBackwards()");
-
- synchronized(this) {
- if (!checkAppSwitchAllowedLocked(Binder.getCallingPid(),
- Binder.getCallingUid(), -1, -1, "Task backwards")) {
- return;
- }
- final long origId = Binder.clearCallingIdentity();
- moveTaskBackwardsLocked(task);
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- private final void moveTaskBackwardsLocked(int task) {
- Slog.e(TAG, "moveTaskBackwards not yet implemented!");
- }
-
- @Override
- public int createStackOnDisplay(int displayId) throws RemoteException {
- enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "createStackOnDisplay()");
- synchronized (this) {
- final ActivityDisplay display =
- mStackSupervisor.getActivityDisplayOrCreateLocked(displayId);
- if (display == null) {
- return INVALID_STACK_ID;
- }
- // TODO(multi-display): Have the caller pass in the windowing mode and activity type.
- final ActivityStack stack = display.createStack(
- WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY, ACTIVITY_TYPE_STANDARD,
- ON_TOP);
- return (stack != null) ? stack.mStackId : INVALID_STACK_ID;
- }
- }
-
- @Override
- public int getActivityDisplayId(IBinder activityToken) throws RemoteException {
- synchronized (this) {
- final ActivityStack stack = ActivityRecord.getStackLocked(activityToken);
- if (stack != null && stack.mDisplayId != INVALID_DISPLAY) {
- return stack.mDisplayId;
- }
- return DEFAULT_DISPLAY;
- }
- }
-
- @Override
- public void exitFreeformMode(IBinder token) throws RemoteException {
- synchronized (this) {
- long ident = Binder.clearCallingIdentity();
- try {
- final ActivityRecord r = ActivityRecord.forTokenLocked(token);
- if (r == null) {
- throw new IllegalArgumentException(
- "exitFreeformMode: No activity record matching token=" + token);
- }
-
- final ActivityStack stack = r.getStack();
- if (stack == null || !stack.inFreeformWindowingMode()) {
- throw new IllegalStateException(
- "exitFreeformMode: You can only go fullscreen from freeform.");
- }
-
- stack.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
- }
-
- @Override
- public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) {
- if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
- setTaskWindowingModeSplitScreenPrimary(taskId, SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT,
- toTop, ANIMATE, null /* initialBounds */, true /* showRecents */);
- return;
- }
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "setTaskWindowingMode()");
- synchronized (this) {
- final long ident = Binder.clearCallingIdentity();
- try {
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
- if (task == null) {
- Slog.w(TAG, "setTaskWindowingMode: No task for id=" + taskId);
- return;
- }
-
- if (DEBUG_STACK) Slog.d(TAG_STACK, "setTaskWindowingMode: moving task=" + taskId
- + " to windowingMode=" + windowingMode + " toTop=" + toTop);
-
- if (!task.isActivityTypeStandardOrUndefined()) {
- throw new IllegalArgumentException("setTaskWindowingMode: Attempt to move"
- + " non-standard task " + taskId + " to windowing mode="
- + windowingMode);
- }
-
- final ActivityStack stack = task.getStack();
- if (toTop) {
- stack.moveToFront("setTaskWindowingMode", task);
- }
- stack.setWindowingMode(windowingMode);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
- }
-
- /**
- * Moves the specified task to the primary-split-screen stack.
- *
- * @param taskId Id of task to move.
- * @param createMode The mode the primary split screen stack should be created in if it doesn't
- * exist already. See
- * {@link android.app.ActivityManager#SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT}
- * and
- * {@link android.app.ActivityManager#SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT}
- * @param toTop If the task and stack should be moved to the top.
- * @param animate Whether we should play an animation for the moving the task.
- * @param initialBounds If the primary stack gets created, it will use these bounds for the
- * stack. Pass {@code null} to use default bounds.
- * @param showRecents If the recents activity should be shown on the other side of the task
- * going into split-screen mode.
- */
- @Override
- public boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode, boolean toTop,
- boolean animate, Rect initialBounds, boolean showRecents) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
- "setTaskWindowingModeSplitScreenPrimary()");
- synchronized (this) {
- long ident = Binder.clearCallingIdentity();
- try {
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
- if (task == null) {
- Slog.w(TAG, "setTaskWindowingModeSplitScreenPrimary: No task for id=" + taskId);
- return false;
- }
- if (DEBUG_STACK) Slog.d(TAG_STACK,
- "setTaskWindowingModeSplitScreenPrimary: moving task=" + taskId
- + " to createMode=" + createMode + " toTop=" + toTop);
- if (!task.isActivityTypeStandardOrUndefined()) {
- throw new IllegalArgumentException("setTaskWindowingMode: Attempt to move"
- + " non-standard task " + taskId + " to split-screen windowing mode");
- }
-
- mWindowManager.setDockedStackCreateState(createMode, initialBounds);
- final int windowingMode = task.getWindowingMode();
- final ActivityStack stack = task.getStack();
- if (toTop) {
- stack.moveToFront("setTaskWindowingModeSplitScreenPrimary", task);
- }
- stack.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, animate, showRecents,
- false /* enteringSplitScreenMode */, false /* deferEnsuringVisibility */);
- return windowingMode != task.getWindowingMode();
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ return mActivityTaskManager.moveActivityTaskToBack(token, nonRoot);
}
@Override
public void moveTaskToStack(int taskId, int stackId, boolean toTop) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "moveTaskToStack()");
- synchronized (this) {
- long ident = Binder.clearCallingIdentity();
- try {
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
- if (task == null) {
- Slog.w(TAG, "moveTaskToStack: No task for id=" + taskId);
- return;
- }
-
- if (DEBUG_STACK) Slog.d(TAG_STACK, "moveTaskToStack: moving task=" + taskId
- + " to stackId=" + stackId + " toTop=" + toTop);
-
- final ActivityStack stack = mStackSupervisor.getStack(stackId);
- if (stack == null) {
- throw new IllegalStateException(
- "moveTaskToStack: No stack for stackId=" + stackId);
- }
- if (!stack.isActivityTypeStandardOrUndefined()) {
- throw new IllegalArgumentException("moveTaskToStack: Attempt to move task "
- + taskId + " to stack " + stackId);
- }
- if (stack.inSplitScreenPrimaryWindowingMode()) {
- mWindowManager.setDockedStackCreateState(
- SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, null /* initialBounds */);
- }
- task.reparent(stack, toTop, REPARENT_KEEP_STACK_AT_FRONT, ANIMATE, !DEFER_RESUME,
- "moveTaskToStack");
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ mActivityTaskManager.moveTaskToStack(taskId, stackId, toTop);
}
- /**
- * Dismisses split-screen multi-window mode.
- * @param toTop If true the current primary split-screen stack will be placed or left on top.
- */
@Override
- public void dismissSplitScreenMode(boolean toTop) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "dismissSplitScreenMode()");
- final long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- final ActivityStack stack =
- mStackSupervisor.getDefaultDisplay().getSplitScreenPrimaryStack();
- if (stack == null) {
- Slog.w(TAG, "dismissSplitScreenMode: primary split-screen stack not found.");
- return;
- }
-
- if (toTop) {
- // Caller wants the current split-screen primary stack to be the top stack after
- // it goes fullscreen, so move it to the front.
- stack.moveToFront("dismissSplitScreenMode");
- } else if (mStackSupervisor.isFocusedStack(stack)) {
- // In this case the current split-screen primary stack shouldn't be the top
- // stack after it goes fullscreen, but it current has focus, so we move the
- // focus to the top-most split-screen secondary stack next to it.
- final ActivityStack otherStack = stack.getDisplay().getTopStackInWindowingMode(
- WINDOWING_MODE_SPLIT_SCREEN_SECONDARY);
- if (otherStack != null) {
- otherStack.moveToFront("dismissSplitScreenMode_other");
- }
- }
-
- stack.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ public void resizeStack(int stackId, Rect destBounds, boolean allowResizeInDockedMode,
+ boolean preserveWindows, boolean animate, int animationDuration) {
+ mActivityTaskManager.resizeStack(stackId, destBounds, allowResizeInDockedMode,
+ preserveWindows, animate, animationDuration);
}
- /**
- * Dismisses Pip
- * @param animate True if the dismissal should be animated.
- * @param animationDuration The duration of the resize animation in milliseconds or -1 if the
- * default animation duration should be used.
- */
@Override
- public void dismissPip(boolean animate, int animationDuration) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "dismissPip()");
- final long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- final PinnedActivityStack stack =
- mStackSupervisor.getDefaultDisplay().getPinnedStack();
- if (stack == null) {
- Slog.w(TAG, "dismissPip: pinned stack not found.");
- return;
- }
- if (stack.getWindowingMode() != WINDOWING_MODE_PINNED) {
- throw new IllegalArgumentException("Stack: " + stack
- + " doesn't support animated resize.");
- }
- if (animate) {
- stack.animateResizePinnedStack(null /* sourceHintBounds */,
- null /* destBounds */, animationDuration, false /* fromFullscreen */);
- } else {
- mStackSupervisor.moveTasksToFullscreenStackLocked(stack, true /* onTop */);
- }
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ public ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags,
+ int userId) {
+ return mActivityTaskManager.getRecentTasks(maxNum, flags, userId);
}
/**
@@ -11325,178 +9471,30 @@ public class ActivityManagerService extends IActivityManager.Stub
*/
@Override
public boolean moveTopActivityToPinnedStack(int stackId, Rect bounds) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
- "moveTopActivityToPinnedStack()");
- synchronized (this) {
- if (!mSupportsPictureInPicture) {
- throw new IllegalStateException("moveTopActivityToPinnedStack:"
- + "Device doesn't support picture-in-picture mode");
- }
-
- long ident = Binder.clearCallingIdentity();
- try {
- return mStackSupervisor.moveTopStackActivityToPinnedStackLocked(stackId, bounds);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
- }
-
- @Override
- public void resizeStack(int stackId, Rect destBounds, boolean allowResizeInDockedMode,
- boolean preserveWindows, boolean animate, int animationDuration) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "resizeStack()");
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- if (animate) {
- final PinnedActivityStack stack = mStackSupervisor.getStack(stackId);
- if (stack == null) {
- Slog.w(TAG, "resizeStack: stackId " + stackId + " not found.");
- return;
- }
- if (stack.getWindowingMode() != WINDOWING_MODE_PINNED) {
- throw new IllegalArgumentException("Stack: " + stackId
- + " doesn't support animated resize.");
- }
- stack.animateResizePinnedStack(null /* sourceHintBounds */, destBounds,
- animationDuration, false /* fromFullscreen */);
- } else {
- final ActivityStack stack = mStackSupervisor.getStack(stackId);
- if (stack == null) {
- Slog.w(TAG, "resizeStack: stackId " + stackId + " not found.");
- return;
- }
- mStackSupervisor.resizeStackLocked(stack, destBounds, null /* tempTaskBounds */,
- null /* tempTaskInsetBounds */, preserveWindows,
- allowResizeInDockedMode, !DEFER_RESUME);
- }
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ return mActivityTaskManager.moveTopActivityToPinnedStack(stackId, bounds);
}
@Override
public void resizeDockedStack(Rect dockedBounds, Rect tempDockedTaskBounds,
Rect tempDockedTaskInsetBounds,
Rect tempOtherTaskBounds, Rect tempOtherTaskInsetBounds) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "resizeDockedStack()");
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- mStackSupervisor.resizeDockedStackLocked(dockedBounds, tempDockedTaskBounds,
- tempDockedTaskInsetBounds, tempOtherTaskBounds, tempOtherTaskInsetBounds,
- PRESERVE_WINDOWS);
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- @Override
- public void setSplitScreenResizing(boolean resizing) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "setSplitScreenResizing()");
- final long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- mStackSupervisor.setSplitScreenResizing(resizing);
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- @Override
- public void resizePinnedStack(Rect pinnedBounds, Rect tempPinnedTaskBounds) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "resizePinnedStack()");
- final long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- mStackSupervisor.resizePinnedStackLocked(pinnedBounds, tempPinnedTaskBounds);
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ mActivityTaskManager.resizeDockedStack(dockedBounds, tempDockedTaskBounds,
+ tempDockedTaskInsetBounds, tempOtherTaskBounds, tempOtherTaskInsetBounds);
}
- /**
- * Try to place task to provided position. The final position might be different depending on
- * current user and stacks state. The task will be moved to target stack if it's currently in
- * different stack.
- */
@Override
public void positionTaskInStack(int taskId, int stackId, int position) {
- enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "positionTaskInStack()");
- synchronized (this) {
- long ident = Binder.clearCallingIdentity();
- try {
- if (DEBUG_STACK) Slog.d(TAG_STACK, "positionTaskInStack: positioning task="
- + taskId + " in stackId=" + stackId + " at position=" + position);
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
- if (task == null) {
- throw new IllegalArgumentException("positionTaskInStack: no task for id="
- + taskId);
- }
-
- final ActivityStack stack = mStackSupervisor.getStack(stackId);
-
- if (stack == null) {
- throw new IllegalArgumentException("positionTaskInStack: no stack for id="
- + stackId);
- }
- if (!stack.isActivityTypeStandardOrUndefined()) {
- throw new IllegalArgumentException("positionTaskInStack: Attempt to change"
- + " the position of task " + taskId + " in/to non-standard stack");
- }
-
- // TODO: Have the callers of this API call a separate reparent method if that is
- // what they intended to do vs. having this method also do reparenting.
- if (task.getStack() == stack) {
- // Change position in current stack.
- stack.positionChildAt(task, position);
- } else {
- // Reparent to new stack.
- task.reparent(stack, position, REPARENT_LEAVE_STACK_IN_PLACE, !ANIMATE,
- !DEFER_RESUME, "positionTaskInStack");
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
+ mActivityTaskManager.positionTaskInStack(taskId, stackId, position);
}
@Override
public List<StackInfo> getAllStackInfos() {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "getAllStackInfos()");
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- return mStackSupervisor.getAllStackInfosLocked();
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- @Override
- public StackInfo getStackInfo(int windowingMode, int activityType) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "getStackInfo()");
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- return mStackSupervisor.getStackInfo(windowingMode, activityType);
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ return mActivityTaskManager.getAllStackInfos();
}
@Override
public int getTaskForActivity(IBinder token, boolean onlyRoot) {
- synchronized(this) {
- return ActivityRecord.getTaskForActivityLocked(token, onlyRoot);
- }
+ return mActivityTaskManager.getTaskForActivity(token, onlyRoot);
}
@Override
@@ -11525,156 +9523,18 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public void updateLockTaskFeatures(int userId, int flags) {
- final int callingUid = Binder.getCallingUid();
- if (callingUid != 0 && callingUid != SYSTEM_UID) {
- enforceCallingPermission(android.Manifest.permission.UPDATE_LOCK_TASK_PACKAGES,
- "updateLockTaskFeatures()");
- }
- synchronized (this) {
- if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Allowing features " + userId + ":0x" +
- Integer.toHexString(flags));
- mLockTaskController.updateLockTaskFeatures(userId, flags);
- }
- }
-
- private void startLockTaskModeLocked(@Nullable TaskRecord task, boolean isSystemCaller) {
- if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "startLockTaskModeLocked: " + task);
- if (task == null || task.mLockTaskAuth == LOCK_TASK_AUTH_DONT_LOCK) {
- return;
- }
-
- final ActivityStack stack = mStackSupervisor.getFocusedStack();
- if (stack == null || task != stack.topTask()) {
- throw new IllegalArgumentException("Invalid task, not in foreground");
- }
-
- // {@code isSystemCaller} is used to distinguish whether this request is initiated by the
- // system or a specific app.
- // * System-initiated requests will only start the pinned mode (screen pinning)
- // * App-initiated requests
- // - will put the device in fully locked mode (LockTask), if the app is whitelisted
- // - will start the pinned mode, otherwise
- final int callingUid = Binder.getCallingUid();
- long ident = Binder.clearCallingIdentity();
- try {
- // When a task is locked, dismiss the pinned stack if it exists
- mStackSupervisor.removeStacksInWindowingModes(WINDOWING_MODE_PINNED);
-
- mLockTaskController.startLockTaskMode(task, isSystemCaller, callingUid);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- @Override
- public void startLockTaskModeByToken(IBinder token) {
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.forTokenLocked(token);
- if (r == null) {
- return;
- }
- startLockTaskModeLocked(r.getTask(), false /* isSystemCaller */);
- }
- }
-
- @Override
- public void startSystemLockTaskMode(int taskId) throws RemoteException {
- enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "startSystemLockTaskMode");
- // This makes inner call to look as if it was initiated by system.
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
-
- // When starting lock task mode the stack must be in front and focused
- task.getStack().moveToFront("startSystemLockTaskMode");
- startLockTaskModeLocked(task, true /* isSystemCaller */);
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- @Override
- public void stopLockTaskModeByToken(IBinder token) {
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.forTokenLocked(token);
- if (r == null) {
- return;
- }
- stopLockTaskModeInternal(r.getTask(), false /* isSystemCaller */);
- }
- }
-
- /**
- * This API should be called by SystemUI only when user perform certain action to dismiss
- * lock task mode. We should only dismiss pinned lock task mode in this case.
- */
- @Override
- public void stopSystemLockTaskMode() throws RemoteException {
- enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "stopSystemLockTaskMode");
- stopLockTaskModeInternal(null, true /* isSystemCaller */);
- }
-
- private void stopLockTaskModeInternal(@Nullable TaskRecord task, boolean isSystemCaller) {
- final int callingUid = Binder.getCallingUid();
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- mLockTaskController.stopLockTaskMode(task, isSystemCaller, callingUid);
- }
- // Launch in-call UI if a call is ongoing. This is necessary to allow stopping the lock
- // task and jumping straight into a call in the case of emergency call back.
- TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
- if (tm != null) {
- tm.showInCallScreen(false);
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- @Override
public boolean isInLockTaskMode() {
- return getLockTaskModeState() != LOCK_TASK_MODE_NONE;
+ return mActivityTaskManager.isInLockTaskMode();
}
@Override
public int getLockTaskModeState() {
- synchronized (this) {
- return mLockTaskController.getLockTaskModeState();
- }
- }
-
- @Override
- public void showLockTaskEscapeMessage(IBinder token) {
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.forTokenLocked(token);
- if (r == null) {
- return;
- }
- mLockTaskController.showLockTaskToast();
- }
+ return mActivityTaskManager.getLockTaskModeState();
}
@Override
- public void setDisablePreviewScreenshots(IBinder token, boolean disable)
- throws RemoteException {
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- Slog.w(TAG, "setDisablePreviewScreenshots: Unable to find activity for token="
- + token);
- return;
- }
- final long origId = Binder.clearCallingIdentity();
- try {
- r.setDisablePreviewScreenshots(disable);
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
+ public void startSystemLockTaskMode(int taskId) throws RemoteException {
+ mActivityTaskManager.startSystemLockTaskMode(taskId);
}
// =========================================================
@@ -13074,17 +10934,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
public void unhandledBack() {
- enforceCallingPermission(android.Manifest.permission.FORCE_BACK,
- "unhandledBack()");
-
- synchronized(this) {
- final long origId = Binder.clearCallingIdentity();
- try {
- getFocusedStack().unhandledBackLocked();
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
+ mActivityTaskManager.unhandledBack();
}
public ParcelFileDescriptor openContentUri(String uriString) throws RemoteException {
@@ -13151,12 +11001,6 @@ public class ActivityManagerService extends IActivityManager.Stub
: UsageEvents.Event.SCREEN_NON_INTERACTIVE);
}
- void reportCurKeyguardUsageEventLocked() {
- reportGlobalUsageEventLocked(mKeyguardShown
- ? UsageEvents.Event.KEYGUARD_SHOWN
- : UsageEvents.Event.KEYGUARD_HIDDEN);
- }
-
void onWakefulnessChanged(int wakefulness) {
synchronized(this) {
boolean wasAwake = mWakefulness == PowerManagerInternal.WAKEFULNESS_AWAKE;
@@ -13226,22 +11070,6 @@ public class ActivityManagerService extends IActivityManager.Stub
mRecentTasks.notifyTaskPersisterLocked(task, flush);
}
- /**
- * Notifies all listeners when the pinned stack animation starts.
- */
- @Override
- public void notifyPinnedStackAnimationStarted() {
- mTaskChangeNotificationController.notifyPinnedStackAnimationStarted();
- }
-
- /**
- * Notifies all listeners when the pinned stack animation ends.
- */
- @Override
- public void notifyPinnedStackAnimationEnded() {
- mTaskChangeNotificationController.notifyPinnedStackAnimationEnded();
- }
-
@Override
public void notifyCleartextNetwork(int uid, byte[] firstPacket) {
mHandler.obtainMessage(NOTIFY_CLEARTEXT_NETWORK_MSG, uid, 0, firstPacket).sendToTarget();
@@ -13277,21 +11105,6 @@ public class ActivityManagerService extends IActivityManager.Stub
return timedout;
}
- public final void activitySlept(IBinder token) {
- if (DEBUG_ALL) Slog.v(TAG, "Activity slept: token=" + token);
-
- final long origId = Binder.clearCallingIdentity();
-
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r != null) {
- mStackSupervisor.activitySleptLocked(r);
- }
- }
-
- Binder.restoreCallingIdentity(origId);
- }
-
@GuardedBy("this")
void startRunningVoiceLocked(IVoiceInteractionSession session, int targetUid) {
Slog.d(TAG, "<<< startRunningVoiceLocked()");
@@ -13313,28 +11126,8 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public void setLockScreenShown(boolean keyguardShowing, boolean aodShowing,
int secondaryDisplayShowing) {
- if (checkCallingPermission(android.Manifest.permission.DEVICE_POWER)
- != PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException("Requires permission "
- + android.Manifest.permission.DEVICE_POWER);
- }
-
- synchronized(this) {
- long ident = Binder.clearCallingIdentity();
- if (mKeyguardShown != keyguardShowing) {
- mKeyguardShown = keyguardShowing;
- reportCurKeyguardUsageEventLocked();
- }
- try {
- mKeyguardController.setKeyguardShown(keyguardShowing, aodShowing,
- secondaryDisplayShowing);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- mHandler.obtainMessage(DISPATCH_SCREEN_KEYGUARD_MSG, keyguardShowing ? 1 : 0, 0)
- .sendToTarget();
+ mActivityTaskManager.setLockScreenShown(
+ keyguardShowing, aodShowing, secondaryDisplayShowing);
}
@Override
@@ -13825,266 +11618,6 @@ public class ActivityManagerService extends IActivityManager.Stub
return true;
}
- @Override
- public Bundle getAssistContextExtras(int requestType) {
- PendingAssistExtras pae = enqueueAssistContext(requestType, null, null, null,
- null, null, true /* focused */, true /* newSessionId */,
- UserHandle.getCallingUserId(), null, PENDING_ASSIST_EXTRAS_TIMEOUT, 0);
- if (pae == null) {
- return null;
- }
- synchronized (pae) {
- while (!pae.haveResult) {
- try {
- pae.wait();
- } catch (InterruptedException e) {
- }
- }
- }
- synchronized (this) {
- buildAssistBundleLocked(pae, pae.result);
- mPendingAssistExtras.remove(pae);
- mUiHandler.removeCallbacks(pae);
- }
- return pae.extras;
- }
-
- @Override
- public boolean isAssistDataAllowedOnCurrentActivity() {
- int userId;
- synchronized (this) {
- final ActivityStack focusedStack = getFocusedStack();
- if (focusedStack == null || focusedStack.isActivityTypeAssistant()) {
- return false;
- }
-
- final ActivityRecord activity = focusedStack.getTopActivity();
- if (activity == null) {
- return false;
- }
- userId = activity.userId;
- }
- return !DevicePolicyCache.getInstance().getScreenCaptureDisabled(userId);
- }
-
- @Override
- public boolean showAssistFromActivity(IBinder token, Bundle args) {
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- ActivityRecord caller = ActivityRecord.forTokenLocked(token);
- ActivityRecord top = getFocusedStack().getTopActivity();
- if (top != caller) {
- Slog.w(TAG, "showAssistFromActivity failed: caller " + caller
- + " is not current top " + top);
- return false;
- }
- if (!top.nowVisible) {
- Slog.w(TAG, "showAssistFromActivity failed: caller " + caller
- + " is not visible");
- return false;
- }
- }
- return mAssistUtils.showSessionForActiveService(args, SHOW_SOURCE_APPLICATION, null,
- token);
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- @Override
- public boolean requestAssistContextExtras(int requestType, IAssistDataReceiver receiver,
- Bundle receiverExtras, IBinder activityToken, boolean focused, boolean newSessionId) {
- return enqueueAssistContext(requestType, null, null, receiver, receiverExtras,
- activityToken, focused, newSessionId, UserHandle.getCallingUserId(), null,
- PENDING_ASSIST_EXTRAS_LONG_TIMEOUT, 0) != null;
- }
-
- @Override
- public boolean requestAutofillData(IAssistDataReceiver receiver, Bundle receiverExtras,
- IBinder activityToken, int flags) {
- return enqueueAssistContext(ActivityManager.ASSIST_CONTEXT_AUTOFILL, null, null,
- receiver, receiverExtras, activityToken, true, true, UserHandle.getCallingUserId(),
- null, PENDING_AUTOFILL_ASSIST_STRUCTURE_TIMEOUT, flags) != null;
- }
-
- private PendingAssistExtras enqueueAssistContext(int requestType, Intent intent, String hint,
- IAssistDataReceiver receiver, Bundle receiverExtras, IBinder activityToken,
- boolean focused, boolean newSessionId, int userHandle, Bundle args, long timeout,
- int flags) {
- enforceCallingPermission(android.Manifest.permission.GET_TOP_ACTIVITY_INFO,
- "enqueueAssistContext()");
-
- synchronized (this) {
- ActivityRecord activity = getFocusedStack().getTopActivity();
- if (activity == null) {
- Slog.w(TAG, "getAssistContextExtras failed: no top activity");
- return null;
- }
- if (activity.app == null || activity.app.thread == null) {
- Slog.w(TAG, "getAssistContextExtras failed: no process for " + activity);
- return null;
- }
- if (focused) {
- if (activityToken != null) {
- ActivityRecord caller = ActivityRecord.forTokenLocked(activityToken);
- if (activity != caller) {
- Slog.w(TAG, "enqueueAssistContext failed: caller " + caller
- + " is not current top " + activity);
- return null;
- }
- }
- } else {
- activity = ActivityRecord.forTokenLocked(activityToken);
- if (activity == null) {
- Slog.w(TAG, "enqueueAssistContext failed: activity for token=" + activityToken
- + " couldn't be found");
- return null;
- }
- if (activity.app == null || activity.app.thread == null) {
- Slog.w(TAG, "enqueueAssistContext failed: no process for " + activity);
- return null;
- }
- }
-
- PendingAssistExtras pae;
- Bundle extras = new Bundle();
- if (args != null) {
- extras.putAll(args);
- }
- extras.putString(Intent.EXTRA_ASSIST_PACKAGE, activity.packageName);
- extras.putInt(Intent.EXTRA_ASSIST_UID, activity.app.uid);
-
- pae = new PendingAssistExtras(activity, extras, intent, hint, receiver, receiverExtras,
- userHandle);
- pae.isHome = activity.isActivityTypeHome();
-
- // Increment the sessionId if necessary
- if (newSessionId) {
- mViSessionId++;
- }
- try {
- activity.app.thread.requestAssistContextExtras(activity.appToken, pae, requestType,
- mViSessionId, flags);
- mPendingAssistExtras.add(pae);
- mUiHandler.postDelayed(pae, timeout);
- } catch (RemoteException e) {
- Slog.w(TAG, "getAssistContextExtras failed: crash calling " + activity);
- return null;
- }
- return pae;
- }
- }
-
- void pendingAssistExtrasTimedOut(PendingAssistExtras pae) {
- IAssistDataReceiver receiver;
- synchronized (this) {
- mPendingAssistExtras.remove(pae);
- receiver = pae.receiver;
- }
- if (receiver != null) {
- // Caller wants result sent back to them.
- Bundle sendBundle = new Bundle();
- // At least return the receiver extras
- sendBundle.putBundle(ASSIST_KEY_RECEIVER_EXTRAS, pae.receiverExtras);
- try {
- pae.receiver.onHandleAssistData(sendBundle);
- } catch (RemoteException e) {
- }
- }
- }
-
- private void buildAssistBundleLocked(PendingAssistExtras pae, Bundle result) {
- if (result != null) {
- pae.extras.putBundle(Intent.EXTRA_ASSIST_CONTEXT, result);
- }
- if (pae.hint != null) {
- pae.extras.putBoolean(pae.hint, true);
- }
- }
-
- /** Called from an app when assist data is ready. */
- @Override
- public void reportAssistContextExtras(IBinder token, Bundle extras, AssistStructure structure,
- AssistContent content, Uri referrer) {
- PendingAssistExtras pae = (PendingAssistExtras)token;
- synchronized (pae) {
- pae.result = extras;
- pae.structure = structure;
- pae.content = content;
- if (referrer != null) {
- pae.extras.putParcelable(Intent.EXTRA_REFERRER, referrer);
- }
- if (structure != null) {
- structure.setHomeActivity(pae.isHome);
- }
- pae.haveResult = true;
- pae.notifyAll();
- if (pae.intent == null && pae.receiver == null) {
- // Caller is just waiting for the result.
- return;
- }
- }
- // We are now ready to launch the assist activity.
- IAssistDataReceiver sendReceiver = null;
- Bundle sendBundle = null;
- synchronized (this) {
- buildAssistBundleLocked(pae, extras);
- boolean exists = mPendingAssistExtras.remove(pae);
- mUiHandler.removeCallbacks(pae);
- if (!exists) {
- // Timed out.
- return;
- }
-
- if ((sendReceiver=pae.receiver) != null) {
- // Caller wants result sent back to them.
- sendBundle = new Bundle();
- sendBundle.putBundle(ASSIST_KEY_DATA, pae.extras);
- sendBundle.putParcelable(ASSIST_KEY_STRUCTURE, pae.structure);
- sendBundle.putParcelable(ASSIST_KEY_CONTENT, pae.content);
- sendBundle.putBundle(ASSIST_KEY_RECEIVER_EXTRAS, pae.receiverExtras);
- }
- }
- if (sendReceiver != null) {
- try {
- sendReceiver.onHandleAssistData(sendBundle);
- } catch (RemoteException e) {
- }
- return;
- }
-
- final long ident = Binder.clearCallingIdentity();
- try {
- if (TextUtils.equals(pae.intent.getAction(),
- android.service.voice.VoiceInteractionService.SERVICE_INTERFACE)) {
- pae.intent.putExtras(pae.extras);
- mContext.startServiceAsUser(pae.intent, new UserHandle(pae.userHandle));
- } else {
- pae.intent.replaceExtras(pae.extras);
- pae.intent.setFlags(FLAG_ACTIVITY_NEW_TASK
- | Intent.FLAG_ACTIVITY_SINGLE_TOP
- | Intent.FLAG_ACTIVITY_CLEAR_TOP);
- closeSystemDialogs("assist");
-
- try {
- mContext.startActivityAsUser(pae.intent, new UserHandle(pae.userHandle));
- } catch (ActivityNotFoundException e) {
- Slog.w(TAG, "No activity to handle assist action.", e);
- }
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
- }
-
- public boolean launchAssistIntent(Intent intent, int requestType, String hint, int userHandle,
- Bundle args) {
- return enqueueAssistContext(requestType, intent, hint, null, null, null,
- true /* focused */, true /* newSessionId */, userHandle, args,
- PENDING_ASSIST_EXTRAS_TIMEOUT, 0) != null;
- }
-
public void registerProcessObserver(IProcessObserver observer) {
enforceCallingPermission(android.Manifest.permission.SET_ACTIVITY_WATCHER,
"registerProcessObserver()");
@@ -14150,101 +11683,6 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public boolean convertFromTranslucent(IBinder token) {
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return false;
- }
- final boolean translucentChanged = r.changeWindowTranslucency(true);
- if (translucentChanged) {
- mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
- }
- mWindowManager.setAppFullscreen(token, true);
- return translucentChanged;
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- @Override
- public boolean convertToTranslucent(IBinder token, Bundle options) {
- SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle(options);
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return false;
- }
- final TaskRecord task = r.getTask();
- int index = task.mActivities.lastIndexOf(r);
- if (index > 0) {
- ActivityRecord under = task.mActivities.get(index - 1);
- under.returningOptions = safeOptions != null ? safeOptions.getOptions(r) : null;
- }
- final boolean translucentChanged = r.changeWindowTranslucency(false);
- if (translucentChanged) {
- r.getStack().convertActivityToTranslucent(r);
- }
- mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
- mWindowManager.setAppFullscreen(token, false);
- return translucentChanged;
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- @Override
- public Bundle getActivityOptions(IBinder token) {
- final long origId = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r != null) {
- final ActivityOptions activityOptions = r.takeOptionsLocked();
- return activityOptions == null ? null : activityOptions.toBundle();
- }
- return null;
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
-
- @Override
- public void setImmersive(IBinder token, boolean immersive) {
- synchronized(this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- throw new IllegalArgumentException();
- }
- r.immersive = immersive;
-
- // update associated state if we're frontmost
- if (r == mStackSupervisor.getResumedActivityLocked()) {
- if (DEBUG_IMMERSIVE) Slog.d(TAG_IMMERSIVE, "Frontmost changed immersion: "+ r);
- applyUpdateLockStateLocked(r);
- }
- }
- }
-
- @Override
- public boolean isImmersive(IBinder token) {
- synchronized (this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- throw new IllegalArgumentException();
- }
- return r.immersive;
- }
- }
-
- @Override
public void setVrThread(int tid) {
enforceSystemHasVrFeature();
synchronized (this) {
@@ -14328,7 +11766,7 @@ public class ActivityManagerService extends IActivityManager.Stub
* Check that we have the features required for VR-related API calls, and throw an exception if
* not.
*/
- private void enforceSystemHasVrFeature() {
+ void enforceSystemHasVrFeature() {
if (!mContext.getPackageManager().hasSystemFeature(
PackageManager.FEATURE_VR_MODE_HIGH_PERFORMANCE)) {
throw new UnsupportedOperationException("VR mode not supported on this device!");
@@ -14388,44 +11826,6 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public int setVrMode(IBinder token, boolean enabled, ComponentName packageName) {
- enforceSystemHasVrFeature();
-
- final VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
-
- ActivityRecord r;
- synchronized (this) {
- r = ActivityRecord.isInStackLocked(token);
- }
-
- if (r == null) {
- throw new IllegalArgumentException();
- }
-
- int err;
- if ((err = vrService.hasVrPackage(packageName, r.userId)) !=
- VrManagerInternal.NO_ERROR) {
- return err;
- }
-
- // Clear the binder calling uid since this path may call moveToTask().
- final long callingId = Binder.clearCallingIdentity();
- try {
- synchronized(this) {
- r.requestedVrComponent = (enabled) ? packageName : null;
-
- // Update associated state if this activity is currently focused
- if (r == mStackSupervisor.getResumedActivityLocked()) {
- applyUpdateVrModeLocked(r);
- }
- return 0;
- }
- } finally {
- Binder.restoreCallingIdentity(callingId);
- }
- }
-
- @Override
public boolean isVrModePackageEnabled(ComponentName packageName) {
enforceSystemHasVrFeature();
@@ -14436,11 +11836,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
public boolean isTopActivityImmersive() {
- enforceNotIsolatedCaller("startActivity");
- synchronized (this) {
- ActivityRecord r = getFocusedStack().topRunningActivityLocked();
- return (r != null) ? r.immersive : false;
- }
+ return mActivityTaskManager.isTopActivityImmersive();
}
/**
@@ -14452,13 +11848,7 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public boolean isTopOfTask(IBinder token) {
- synchronized (this) {
- ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- throw new IllegalArgumentException();
- }
- return r.getTask().getTopActivity() == r;
- }
+ return mActivityTaskManager.isTopOfTask(token);
}
@Override
@@ -14922,11 +12312,11 @@ public class ActivityManagerService extends IActivityManager.Stub
|| Settings.Global.getInt(
resolver, DEVELOPMENT_ENABLE_FREEFORM_WINDOWS_SUPPORT, 0) != 0;
- final boolean supportsMultiWindow = ActivityManager.supportsMultiWindow(mContext);
+ final boolean supportsMultiWindow = ActivityTaskManager.supportsMultiWindow(mContext);
final boolean supportsPictureInPicture = supportsMultiWindow &&
mContext.getPackageManager().hasSystemFeature(FEATURE_PICTURE_IN_PICTURE);
final boolean supportsSplitScreenMultiWindow =
- ActivityManager.supportsSplitScreenMultiWindow(mContext);
+ ActivityTaskManager.supportsSplitScreenMultiWindow(mContext);
final boolean supportsMultiDisplay = mContext.getPackageManager()
.hasSystemFeature(FEATURE_ACTIVITIES_ON_SECONDARY_DISPLAYS);
final String debugApp = Settings.Global.getString(resolver, DEBUG_APP);
@@ -15024,7 +12414,7 @@ public class ActivityManagerService extends IActivityManager.Stub
PackageManager.FEATURE_CANT_SAVE_STATE);
mLocalDeviceIdleController
= LocalServices.getService(DeviceIdleController.LocalService.class);
- mAssistUtils = new AssistUtils(mContext);
+ mActivityTaskManager.onSystemReady();
mVrController.onSystemReady();
// Make sure we have the current profile info, since it is needed for security checks.
mUserController.onSystemReady();
@@ -15200,6 +12590,7 @@ public class ActivityManagerService extends IActivityManager.Stub
mStackSupervisor.resumeFocusedStackTopActivityLocked();
mUserController.sendUserSwitchBroadcasts(-1, currentUserId);
+ BinderInternal.nSetBinderProxyCountWatermarks(6000,5500);
BinderInternal.nSetBinderProxyCountEnabled(true);
BinderInternal.setBinderProxyCountCallback(
new BinderInternal.BinderProxyLimitListener() {
@@ -20924,15 +18315,9 @@ public class ActivityManagerService extends IActivityManager.Stub
}
private List<ResolveInfo> collectReceiverComponents(Intent intent, String resolvedType,
- int callingUid, boolean callerInstantApp, int[] users) {
+ int callingUid, int[] users) {
// TODO: come back and remove this assumption to triage all broadcasts
int pmFlags = STOCK_PM_FLAGS | MATCH_DEBUG_TRIAGED_MISSING;
- // Instant apps should be able to send broadcasts to themselves, so we would
- // match instant receivers and later the broadcast queue would enforce that
- // the broadcast cannot be sent to a receiver outside the instant UID.
- if (callerInstantApp) {
- pmFlags |= PackageManager.MATCH_INSTANT;
- }
List<ResolveInfo> receivers = null;
try {
@@ -21561,8 +18946,7 @@ public class ActivityManagerService extends IActivityManager.Stub
// Need to resolve the intent to interested receivers...
if ((intent.getFlags()&Intent.FLAG_RECEIVER_REGISTERED_ONLY)
== 0) {
- receivers = collectReceiverComponents(intent, resolvedType, callingUid,
- callerInstantApp, users);
+ receivers = collectReceiverComponents(intent, resolvedType, callingUid, users);
}
if (intent.getComponent() == null) {
if (userId == UserHandle.USER_ALL && callingUid == SHELL_UID) {
@@ -22193,19 +19577,7 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public StackInfo getFocusedStackInfo() throws RemoteException {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "getStackInfo()");
- long ident = Binder.clearCallingIdentity();
- try {
- synchronized (this) {
- ActivityStack focusedStack = getFocusedStack();
- if (focusedStack != null) {
- return mStackSupervisor.getStackInfo(focusedStack.mStackId);
- }
- return null;
- }
- } finally {
- Binder.restoreCallingIdentity(ident);
- }
+ return mActivityTaskManager.getFocusedStackInfo();
}
public Configuration getConfiguration() {
@@ -22219,37 +19591,7 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public void suppressResizeConfigChanges(boolean suppress) throws RemoteException {
- enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "suppressResizeConfigChanges()");
- synchronized (this) {
- mSuppressResizeConfigChanges = suppress;
- }
- }
-
- /**
- * NOTE: For the pinned stack, this method is usually called after the bounds animation has
- * animated the stack to the fullscreen, but can also be called if we are relaunching an
- * activity and clearing the task at the same time.
- */
- @Override
- // TODO: API should just be about changing windowing modes...
- public void moveTasksToFullscreenStack(int fromStackId, boolean onTop) {
- enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
- "moveTasksToFullscreenStack()");
- synchronized (this) {
- final long origId = Binder.clearCallingIdentity();
- try {
- final ActivityStack stack = mStackSupervisor.getStack(fromStackId);
- if (stack != null){
- if (!stack.isActivityTypeStandardOrUndefined()) {
- throw new IllegalArgumentException(
- "You can't move tasks from non-standard stacks.");
- }
- mStackSupervisor.moveTasksToFullscreenStackLocked(stack, onTop);
- }
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
+ mActivityTaskManager.suppressResizeConfigChanges(suppress);
}
@Override
@@ -22313,32 +19655,7 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public boolean updateConfiguration(Configuration values) {
- enforceCallingPermission(CHANGE_CONFIGURATION, "updateConfiguration()");
-
- synchronized(this) {
- if (values == null && mWindowManager != null) {
- // sentinel: fetch the current configuration from the window manager
- values = mWindowManager.computeNewConfiguration(DEFAULT_DISPLAY);
- }
-
- if (mWindowManager != null) {
- // Update OOM levels based on display size.
- mProcessList.applyDisplaySize(mWindowManager);
- }
-
- final long origId = Binder.clearCallingIdentity();
- try {
- if (values != null) {
- Settings.System.clearConfiguration(values);
- }
- updateConfigurationLocked(values, null, false, false /* persistent */,
- UserHandle.USER_NULL, false /* deferResume */,
- mTmpUpdateConfigurationResult);
- return mTmpUpdateConfigurationResult.changes != 0;
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
+ return mActivityTaskManager.updateConfiguration(values);
}
void updateUserConfigurationLocked() {
@@ -22381,9 +19698,9 @@ public class ActivityManagerService extends IActivityManager.Stub
* @param userId is only used when persistent parameter is set to true to persist configuration
* for that particular user
*/
- private boolean updateConfigurationLocked(Configuration values, ActivityRecord starting,
+ boolean updateConfigurationLocked(Configuration values, ActivityRecord starting,
boolean initLocale, boolean persistent, int userId, boolean deferResume,
- UpdateConfigurationResult result) {
+ ActivityTaskManagerService.UpdateConfigurationResult result) {
int changes = 0;
boolean kept = true;
@@ -22562,45 +19879,6 @@ public class ActivityManagerService extends IActivityManager.Stub
return changes;
}
- @Override
- public boolean updateDisplayOverrideConfiguration(Configuration values, int displayId) {
- enforceCallingPermission(CHANGE_CONFIGURATION, "updateDisplayOverrideConfiguration()");
-
- synchronized (this) {
- // Check if display is initialized in AM.
- if (!mStackSupervisor.isDisplayAdded(displayId)) {
- // Call might come when display is not yet added or has already been removed.
- if (DEBUG_CONFIGURATION) {
- Slog.w(TAG, "Trying to update display configuration for non-existing displayId="
- + displayId);
- }
- return false;
- }
-
- if (values == null && mWindowManager != null) {
- // sentinel: fetch the current configuration from the window manager
- values = mWindowManager.computeNewConfiguration(displayId);
- }
-
- if (mWindowManager != null) {
- // Update OOM levels based on display size.
- mProcessList.applyDisplaySize(mWindowManager);
- }
-
- final long origId = Binder.clearCallingIdentity();
- try {
- if (values != null) {
- Settings.System.clearConfiguration(values);
- }
- updateDisplayOverrideConfigurationLocked(values, null /* starting */,
- false /* deferResume */, displayId, mTmpUpdateConfigurationResult);
- return mTmpUpdateConfigurationResult.changes != 0;
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- }
-
boolean updateDisplayOverrideConfigurationLocked(Configuration values, ActivityRecord starting,
boolean deferResume, int displayId) {
return updateDisplayOverrideConfigurationLocked(values, starting, deferResume /* deferResume */,
@@ -22611,9 +19889,9 @@ public class ActivityManagerService extends IActivityManager.Stub
* Updates override configuration specific for the selected display. If no config is provided,
* new one will be computed in WM based on current display info.
*/
- private boolean updateDisplayOverrideConfigurationLocked(Configuration values,
+ boolean updateDisplayOverrideConfigurationLocked(Configuration values,
ActivityRecord starting, boolean deferResume, int displayId,
- UpdateConfigurationResult result) {
+ ActivityTaskManagerService.UpdateConfigurationResult result) {
int changes = 0;
boolean kept = true;
@@ -22754,48 +20032,12 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public boolean shouldUpRecreateTask(IBinder token, String destAffinity) {
- synchronized (this) {
- ActivityRecord srec = ActivityRecord.forTokenLocked(token);
- if (srec != null) {
- return srec.getStack().shouldUpRecreateTaskLocked(srec, destAffinity);
- }
- }
- return false;
- }
-
- public boolean navigateUpTo(IBinder token, Intent destIntent, int resultCode,
- Intent resultData) {
-
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.forTokenLocked(token);
- if (r != null) {
- return r.getStack().navigateUpToLocked(r, destIntent, resultCode, resultData);
- }
- return false;
- }
- }
-
public int getLaunchedFromUid(IBinder activityToken) {
- ActivityRecord srec;
- synchronized (this) {
- srec = ActivityRecord.forTokenLocked(activityToken);
- }
- if (srec == null) {
- return -1;
- }
- return srec.launchedFromUid;
+ return mActivityTaskManager.getLaunchedFromUid(activityToken);
}
public String getLaunchedFromPackage(IBinder activityToken) {
- ActivityRecord srec;
- synchronized (this) {
- srec = ActivityRecord.forTokenLocked(activityToken);
- }
- if (srec == null) {
- return null;
- }
- return srec.launchedFromPackage;
+ return mActivityTaskManager.getLaunchedFromPackage(activityToken);
}
// =========================================================
@@ -23978,7 +21220,8 @@ public class ActivityManagerService extends IActivityManager.Stub
+ myProc + " to " + heapdumpFile);
thread.dumpHeap(/* managed= */ true,
/* mallocInfo= */ false, /* runGc= */ false,
- heapdumpFile.toString(), fd);
+ heapdumpFile.toString(), fd,
+ /* finishCallback= */ null);
} catch (RemoteException e) {
}
}
@@ -25749,7 +22992,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
- private void clearProfilerLocked() {
+ void clearProfilerLocked() {
if (mProfilerInfo !=null && mProfilerInfo.profileFd != null) {
try {
mProfilerInfo.profileFd.close();
@@ -25871,8 +23114,9 @@ public class ActivityManagerService extends IActivityManager.Stub
return proc;
}
+ @Override
public boolean dumpHeap(String process, int userId, boolean managed, boolean mallocInfo,
- boolean runGc, String path, ParcelFileDescriptor fd) throws RemoteException {
+ boolean runGc, String path, ParcelFileDescriptor fd, RemoteCallback finishCallback) {
try {
synchronized (this) {
@@ -25900,7 +23144,7 @@ public class ActivityManagerService extends IActivityManager.Stub
}
}
- proc.thread.dumpHeap(managed, mallocInfo, runGc, path, fd);
+ proc.thread.dumpHeap(managed, mallocInfo, runGc, path, fd, finishCallback);
fd = null;
return true;
}
@@ -26395,7 +23639,7 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public int startActivityAsUser(IApplicationThread caller, String callerPacakge,
Intent intent, Bundle options, int userId) {
- return ActivityManagerService.this.startActivityAsUser(
+ return ActivityManagerService.this.mActivityTaskManager.startActivityAsUser(
caller, callerPacakge, intent,
intent.resolveTypeIfNeeded(mContext.getContentResolver()),
null, null, 0, Intent.FLAG_ACTIVITY_NEW_TASK, null, options, userId,
@@ -26679,7 +23923,8 @@ public class ActivityManagerService extends IActivityManager.Stub
@Override
public void cancelRecentsAnimation(boolean restoreHomeStackPosition) {
- ActivityManagerService.this.cancelRecentsAnimation(restoreHomeStackPosition);
+ ActivityManagerService.this.mActivityTaskManager.cancelRecentsAnimation(
+ restoreHomeStackPosition);
}
@Override
@@ -26819,21 +24064,6 @@ public class ActivityManagerService extends IActivityManager.Stub
}
/**
- * Return the user id of the last resumed activity.
- */
- @Override
- public @UserIdInt int getLastResumedActivityUserId() {
- enforceCallingPermission(
- permission.INTERACT_ACROSS_USERS_FULL, "getLastResumedActivityUserId()");
- synchronized (this) {
- if (mLastResumedActivity == null) {
- return mUserController.getCurrentUserId();
- }
- return mLastResumedActivity.userId;
- }
- }
-
- /**
* Kill processes for the user with id userId and that depend on the package named packageName
*/
@Override
@@ -26867,21 +24097,6 @@ public class ActivityManagerService extends IActivityManager.Stub
}
@Override
- public void dismissKeyguard(IBinder token, IKeyguardDismissCallback callback,
- CharSequence message) throws RemoteException {
- if (message != null) {
- enforceCallingPermission(permission.SHOW_KEYGUARD_MESSAGE,
- "dismissKeyguard()");
- }
- final long callingId = Binder.clearCallingIdentity();
- try {
- mKeyguardController.dismissKeyguard(token, callback, message);
- } finally {
- Binder.restoreCallingIdentity(callingId);
- }
- }
-
- @Override
public int restartUserInBackground(final int userId) {
return mUserController.restartUser(userId, /* foreground */ false);
}
@@ -27000,87 +24215,4 @@ public class ActivityManagerService extends IActivityManager.Stub
return mNmi != null;
}
}
-
- @Override
- public void setShowWhenLocked(IBinder token, boolean showWhenLocked)
- throws RemoteException {
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return;
- }
- final long origId = Binder.clearCallingIdentity();
- try {
- r.setShowWhenLocked(showWhenLocked);
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- }
-
- @Override
- public void setTurnScreenOn(IBinder token, boolean turnScreenOn) throws RemoteException {
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return;
- }
- final long origId = Binder.clearCallingIdentity();
- try {
- r.setTurnScreenOn(turnScreenOn);
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- }
-
- @Override
- public void registerRemoteAnimations(IBinder token, RemoteAnimationDefinition definition)
- throws RemoteException {
- enforceCallingPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS,
- "registerRemoteAnimations");
- definition.setCallingPid(Binder.getCallingPid());
- synchronized (this) {
- final ActivityRecord r = ActivityRecord.isInStackLocked(token);
- if (r == null) {
- return;
- }
- final long origId = Binder.clearCallingIdentity();
- try {
- r.registerRemoteAnimations(definition);
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- }
-
- @Override
- public void registerRemoteAnimationForNextActivityStart(String packageName,
- RemoteAnimationAdapter adapter) throws RemoteException {
- enforceCallingPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS,
- "registerRemoteAnimationForNextActivityStart");
- adapter.setCallingPid(Binder.getCallingPid());
- synchronized (this) {
- final long origId = Binder.clearCallingIdentity();
- try {
- mActivityStartController.registerRemoteAnimationForNextActivityStart(packageName,
- adapter);
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- }
-
- /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */
- @Override
- public void alwaysShowUnsupportedCompileSdkWarning(ComponentName activity) {
- synchronized (this) {
- final long origId = Binder.clearCallingIdentity();
- try {
- mAppWarnings.alwaysShowUnsupportedCompileSdkWarning(activity);
- } finally {
- Binder.restoreCallingIdentity(origId);
- }
- }
- }
}
diff --git a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
index dc9a5adb5a0c..0e78d06367d1 100644
--- a/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
+++ b/services/core/java/com/android/server/am/ActivityManagerShellCommand.java
@@ -18,9 +18,11 @@ package com.android.server.am;
import android.app.ActivityManager;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.app.AppGlobals;
import android.app.IActivityController;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.IStopUserCallback;
import android.app.IUidObserver;
import android.app.KeyguardManager;
@@ -56,6 +58,8 @@ import android.os.Binder;
import android.os.Build;
import android.os.Bundle;
import android.os.ParcelFileDescriptor;
+import android.os.RemoteCallback;
+import android.os.RemoteCallback.OnResultListener;
import android.os.RemoteException;
import android.os.ServiceManager;
import android.os.ShellCommand;
@@ -65,6 +69,7 @@ import android.os.SystemProperties;
import android.os.UserHandle;
import android.os.UserManager;
import android.text.TextUtils;
+import android.text.format.Time;
import android.util.ArrayMap;
import android.util.DebugUtils;
import android.util.DisplayMetrics;
@@ -89,6 +94,7 @@ import java.util.Comparator;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
+import java.util.concurrent.CountDownLatch;
import javax.microedition.khronos.egl.EGL10;
import javax.microedition.khronos.egl.EGLConfig;
@@ -96,9 +102,9 @@ import javax.microedition.khronos.egl.EGLContext;
import javax.microedition.khronos.egl.EGLDisplay;
import javax.microedition.khronos.egl.EGLSurface;
-import static android.app.ActivityManager.RESIZE_MODE_SYSTEM;
-import static android.app.ActivityManager.RESIZE_MODE_USER;
-import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
+import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM;
+import static android.app.ActivityTaskManager.RESIZE_MODE_USER;
+import static android.app.ActivityTaskManager.INVALID_STACK_ID;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
import static android.view.Display.INVALID_DISPLAY;
@@ -111,6 +117,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
// IPC interface to activity manager -- don't need to do additional security checks.
final IActivityManager mInterface;
+ final IActivityTaskManager mTaskInterface;
// Internal service impl -- must perform security checks before touching.
final ActivityManagerService mInternal;
@@ -143,6 +150,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
ActivityManagerShellCommand(ActivityManagerService service, boolean dumping) {
mInterface = service;
+ mTaskInterface = service.mActivityTaskManager;
mInternal = service;
mPm = AppGlobals.getPackageManager();
mDumping = dumping;
@@ -471,12 +479,12 @@ final class ActivityManagerShellCommand extends ShellCommand {
options.setLockTaskEnabled(true);
}
if (mWaitOption) {
- result = mInterface.startActivityAndWait(null, null, intent, mimeType,
+ result = mTaskInterface.startActivityAndWait(null, null, intent, mimeType,
null, null, 0, mStartFlags, profilerInfo,
options != null ? options.toBundle() : null, mUserId);
res = result.result;
} else {
- res = mInterface.startActivityAsUser(null, null, intent, mimeType,
+ res = mTaskInterface.startActivityAsUser(null, null, intent, mimeType,
null, null, 0, mStartFlags, profilerInfo,
options != null ? options.toBundle() : null, mUserId);
}
@@ -570,7 +578,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
}
mRepeat--;
if (mRepeat > 0) {
- mInterface.unhandledBack();
+ mTaskInterface.unhandledBack();
}
} while (mRepeat > 0);
return 0;
@@ -872,7 +880,14 @@ final class ActivityManagerShellCommand extends ShellCommand {
}
}
String process = getNextArgRequired();
- String heapFile = getNextArgRequired();
+ String heapFile = getNextArg();
+ if (heapFile == null) {
+ final Time t = new Time();
+ t.set(System.currentTimeMillis());
+ heapFile = "/data/local/tmp/heapdump-" + t.format("%Y%m%d-%H%M%S") + ".prof";
+ }
+ pw.println("File: " + heapFile);
+ pw.flush();
File file = new File(heapFile);
file.delete();
@@ -881,10 +896,28 @@ final class ActivityManagerShellCommand extends ShellCommand {
return -1;
}
- if (!mInterface.dumpHeap(process, userId, managed, mallocInfo, runGc, heapFile, fd)) {
+ final CountDownLatch latch = new CountDownLatch(1);
+
+ final RemoteCallback finishCallback = new RemoteCallback(new OnResultListener() {
+ @Override
+ public void onResult(Bundle result) {
+ latch.countDown();
+ }
+ }, null);
+
+ if (!mInterface.dumpHeap(process, userId, managed, mallocInfo, runGc, heapFile, fd,
+ finishCallback)) {
err.println("HEAP DUMP FAILED on process " + process);
return -1;
}
+ pw.println("Waiting for dump to finish...");
+ pw.flush();
+ try {
+ latch.await();
+ } catch (InterruptedException e) {
+ err.println("Caught InterruptedException");
+ }
+
return 0;
}
@@ -2153,7 +2186,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
int runSuppressResizeConfigChanges(PrintWriter pw) throws RemoteException {
boolean suppress = Boolean.valueOf(getNextArgRequired());
- mInterface.suppressResizeConfigChanges(suppress);
+ mTaskInterface.suppressResizeConfigChanges(suppress);
return 0;
}
@@ -2420,7 +2453,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
int stackId = Integer.parseInt(stackIdStr);
String displayIdStr = getNextArgRequired();
int displayId = Integer.parseInt(displayIdStr);
- mInterface.moveStackToDisplay(stackId, displayId);
+ mTaskInterface.moveStackToDisplay(stackId, displayId);
return 0;
}
@@ -2434,7 +2467,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
throw new RuntimeException(e.getMessage(), e);
}
- final int stackId = mInterface.createStackOnDisplay(displayId);
+ final int stackId = mTaskInterface.createStackOnDisplay(displayId);
if (stackId != INVALID_STACK_ID) {
// TODO: Need proper support if this is used by test...
// container.startActivity(intent);
@@ -2465,7 +2498,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
return -1;
}
- mInterface.moveTaskToStack(taskId, stackId, toTop);
+ mTaskInterface.moveTaskToStack(taskId, stackId, toTop);
return 0;
}
@@ -2499,7 +2532,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
int resizeStackUnchecked(int stackId, Rect bounds, int delayMs, boolean animate)
throws RemoteException {
try {
- mInterface.resizeStack(stackId, bounds, false, false, animate, -1);
+ mTaskInterface.resizeStack(stackId, bounds, false, false, animate, -1);
Thread.sleep(delayMs);
} catch (InterruptedException e) {
}
@@ -2513,7 +2546,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
getErrPrintWriter().println("Error: invalid input bounds");
return -1;
}
- mInterface.resizeDockedStack(bounds, taskBounds, null, null, null);
+ mTaskInterface.resizeDockedStack(bounds, taskBounds, null, null, null);
return 0;
}
@@ -2533,12 +2566,12 @@ final class ActivityManagerShellCommand extends ShellCommand {
String positionStr = getNextArgRequired();
int position = Integer.parseInt(positionStr);
- mInterface.positionTaskInStack(taskId, stackId, position);
+ mTaskInterface.positionTaskInStack(taskId, stackId, position);
return 0;
}
int runStackList(PrintWriter pw) throws RemoteException {
- List<ActivityManager.StackInfo> stacks = mInterface.getAllStackInfos();
+ List<ActivityManager.StackInfo> stacks = mTaskInterface.getAllStackInfos();
for (ActivityManager.StackInfo info : stacks) {
pw.println(info);
}
@@ -2548,7 +2581,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
int runStackInfo(PrintWriter pw) throws RemoteException {
int windowingMode = Integer.parseInt(getNextArgRequired());
int activityType = Integer.parseInt(getNextArgRequired());
- ActivityManager.StackInfo info = mInterface.getStackInfo(windowingMode, activityType);
+ ActivityManager.StackInfo info = mTaskInterface.getStackInfo(windowingMode, activityType);
pw.println(info);
return 0;
}
@@ -2556,7 +2589,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
int runStackRemove(PrintWriter pw) throws RemoteException {
String stackIdStr = getNextArgRequired();
int stackId = Integer.parseInt(stackIdStr);
- mInterface.removeStack(stackId);
+ mTaskInterface.removeStack(stackId);
return 0;
}
@@ -2568,7 +2601,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
return -1;
}
- if (!mInterface.moveTopActivityToPinnedStack(stackId, bounds)) {
+ if (!mTaskInterface.moveTopActivityToPinnedStack(stackId, bounds)) {
getErrPrintWriter().println("Didn't move top activity to pinned stack.");
return -1;
}
@@ -2614,12 +2647,12 @@ final class ActivityManagerShellCommand extends ShellCommand {
int runTaskLock(PrintWriter pw) throws RemoteException {
String taskIdStr = getNextArgRequired();
if (taskIdStr.equals("stop")) {
- mInterface.stopSystemLockTaskMode();
+ mTaskInterface.stopSystemLockTaskMode();
} else {
int taskId = Integer.parseInt(taskIdStr);
- mInterface.startSystemLockTaskMode(taskId);
+ mTaskInterface.startSystemLockTaskMode(taskId);
}
- pw.println("Activity manager is " + (mInterface.isInLockTaskMode() ? "" : "not ") +
+ pw.println("Activity manager is " + (mTaskInterface.isInLockTaskMode() ? "" : "not ") +
"in lockTaskMode");
return 0;
}
@@ -2629,7 +2662,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
final int taskId = Integer.parseInt(taskIdStr);
final String resizeableStr = getNextArgRequired();
final int resizeableMode = Integer.parseInt(resizeableStr);
- mInterface.setTaskResizeable(taskId, resizeableMode);
+ mTaskInterface.setTaskResizeable(taskId, resizeableMode);
return 0;
}
@@ -2648,7 +2681,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
void taskResize(int taskId, Rect bounds, int delay_ms, boolean pretendUserResize)
throws RemoteException {
final int resizeMode = pretendUserResize ? RESIZE_MODE_USER : RESIZE_MODE_SYSTEM;
- mInterface.resizeTask(taskId, bounds, resizeMode);
+ mTaskInterface.resizeTask(taskId, bounds, resizeMode);
try {
Thread.sleep(delay_ms);
} catch (InterruptedException e) {
@@ -2720,7 +2753,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
int runTaskFocus(PrintWriter pw) throws RemoteException {
final int taskId = Integer.parseInt(getNextArgRequired());
pw.println("Setting focus to task " + taskId);
- mInterface.setFocusedTask(taskId);
+ mTaskInterface.setFocusedTask(taskId);
return 0;
}
@@ -2752,7 +2785,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
if (res == null) {
return -1;
}
- pw.println(ActivityManager.supportsMultiWindow(mInternal.mContext));
+ pw.println(ActivityTaskManager.supportsMultiWindow(mInternal.mContext));
return 0;
}
@@ -2761,7 +2794,7 @@ final class ActivityManagerShellCommand extends ShellCommand {
if (res == null) {
return -1;
}
- pw.println(ActivityManager.supportsSplitScreenMultiWindow(mInternal.mContext));
+ pw.println(ActivityTaskManager.supportsSplitScreenMultiWindow(mInternal.mContext));
return 0;
}
diff --git a/services/core/java/com/android/server/am/ActivityRecord.java b/services/core/java/com/android/server/am/ActivityRecord.java
index 75f27231c976..35f3c0938579 100644
--- a/services/core/java/com/android/server/am/ActivityRecord.java
+++ b/services/core/java/com/android/server/am/ActivityRecord.java
@@ -17,7 +17,7 @@
package com.android.server.am;
import static android.app.ActivityManager.LOCK_TASK_MODE_NONE;
-import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
+import static android.app.ActivityTaskManager.INVALID_STACK_ID;
import static android.app.ActivityManager.TaskDescription.ATTR_TASKDESCRIPTION_PREFIX;
import static android.app.ActivityOptions.ANIM_CLIP_REVEAL;
import static android.app.ActivityOptions.ANIM_CUSTOM;
@@ -1293,7 +1293,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
}
boolean isKeyguardLocked = service.isKeyguardLocked();
- boolean isCurrentAppLocked = service.getLockTaskModeState() != LOCK_TASK_MODE_NONE;
+ boolean isCurrentAppLocked = service.mActivityTaskManager.getLockTaskModeState() != LOCK_TASK_MODE_NONE;
final ActivityDisplay display = getDisplay();
boolean hasPinnedStack = display != null && display.hasPinnedStack();
// Don't return early if !isNotLocked, since we want to throw an exception if the activity
@@ -2732,7 +2732,7 @@ final class ActivityRecord extends ConfigurationContainer implements AppWindowCo
}
void relaunchActivityLocked(boolean andResume, boolean preserveWindow) {
- if (service.mSuppressResizeConfigChanges && preserveWindow) {
+ if (service.mActivityTaskManager.mSuppressResizeConfigChanges && preserveWindow) {
configChangeFlags = 0;
return;
}
diff --git a/services/core/java/com/android/server/am/ActivityStack.java b/services/core/java/com/android/server/am/ActivityStack.java
index cc7a2308834e..88589cc09143 100644
--- a/services/core/java/com/android/server/am/ActivityStack.java
+++ b/services/core/java/com/android/server/am/ActivityStack.java
@@ -1654,13 +1654,6 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
void addToStopping(ActivityRecord r, boolean scheduleIdle, boolean idleDelayed) {
if (!mStackSupervisor.mStoppingActivities.contains(r)) {
mStackSupervisor.mStoppingActivities.add(r);
-
- // Some activity is waiting for another activity to become visible before it's being
- // stopped, which means that we also want to wait with stopping this one to avoid
- // flickers.
- if (!mStackSupervisor.mActivitiesWaitingForVisibleActivity.isEmpty()) {
- mStackSupervisor.mActivitiesWaitingForVisibleActivity.add(r);
- }
}
// If we already have a few activities waiting to stop, then give up
@@ -2825,7 +2818,7 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
/**
* Used from {@link ActivityStack#positionTask(TaskRecord, int)}.
- * @see ActivityManagerService#positionTaskInStack(int, int, int).
+ * @see ActivityTaskManagerService#positionTaskInStack(int, int, int).
*/
private void insertTaskAtPosition(TaskRecord task, int position) {
if (position >= mTaskHistory.size()) {
@@ -4758,8 +4751,9 @@ class ActivityStack<T extends StackWindowController> extends ConfigurationContai
// TODO: Figure-out a way to consolidate with resize() method below.
@Override
public void requestResize(Rect bounds) {
- mService.resizeStack(mStackId, bounds, true /* allowResizeInDockedMode */,
- false /* preserveWindows */, false /* animate */, -1 /* animationDuration */);
+ mService.mActivityTaskManager.resizeStack(mStackId, bounds,
+ true /* allowResizeInDockedMode */, false /* preserveWindows */,
+ false /* animate */, -1 /* animationDuration */);
}
// TODO: Can only be called from special methods in ActivityStackSupervisor.
diff --git a/services/core/java/com/android/server/am/ActivityStackSupervisor.java b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
index e034b824dc50..615edd5424e4 100644
--- a/services/core/java/com/android/server/am/ActivityStackSupervisor.java
+++ b/services/core/java/com/android/server/am/ActivityStackSupervisor.java
@@ -24,7 +24,7 @@ import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
import static android.app.ActivityManager.LOCK_TASK_MODE_LOCKED;
import static android.app.ActivityManager.START_DELIVERED_TO_TOP;
import static android.app.ActivityManager.START_TASK_TO_FRONT;
-import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
+import static android.app.ActivityTaskManager.INVALID_STACK_ID;
import static android.app.ITaskStackListener.FORCED_RESIZEABLE_REASON_SECONDARY_DISPLAY;
import static android.app.ITaskStackListener.FORCED_RESIZEABLE_REASON_SPLIT_SCREEN;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
@@ -305,7 +305,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
/** The number of distinct task ids that can be assigned to the tasks of a single user */
private static final int MAX_TASK_IDS_PER_USER = UserHandle.PER_USER_RANGE;
- final ActivityManagerService mService;
+ ActivityManagerService mService;
/** The historial list of recent tasks including inactive tasks */
RecentTasks mRecentTasks;
@@ -319,6 +319,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
/** Short cut */
WindowManagerService mWindowManager;
DisplayManager mDisplayManager;
+ ActivityTaskManagerService mAtm;
private LaunchParamsController mLaunchParamsController;
@@ -610,6 +611,11 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
mHandler = new ActivityStackSupervisorHandler(looper);
}
+ @VisibleForTesting
+ void setService(ActivityManagerService service) {
+ mService = service;
+ }
+
public void initialize() {
if (mInitialized) {
return;
@@ -660,27 +666,29 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
mLaunchingActivity.setReferenceCounted(false);
}
- void setWindowManager(WindowManagerService wm) {
- synchronized (mService) {
- mWindowManager = wm;
- getKeyguardController().setWindowManager(wm);
+ void setActivityTaskManager(ActivityTaskManagerService atm) {
+ mAtm = atm;
+ }
- mDisplayManager =
- (DisplayManager)mService.mContext.getSystemService(Context.DISPLAY_SERVICE);
- mDisplayManager.registerDisplayListener(this, null);
- mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
+ void setWindowManager(WindowManagerService wm) {
+ mWindowManager = wm;
+ getKeyguardController().setWindowManager(wm);
- Display[] displays = mDisplayManager.getDisplays();
- for (int displayNdx = displays.length - 1; displayNdx >= 0; --displayNdx) {
- final Display display = displays[displayNdx];
- ActivityDisplay activityDisplay = new ActivityDisplay(this, display);
- mActivityDisplays.put(display.getDisplayId(), activityDisplay);
- calculateDefaultMinimalSizeOfResizeableTasks(activityDisplay);
- }
+ mDisplayManager =
+ (DisplayManager) mService.mContext.getSystemService(Context.DISPLAY_SERVICE);
+ mDisplayManager.registerDisplayListener(this, null);
+ mDisplayManagerInternal = LocalServices.getService(DisplayManagerInternal.class);
- mHomeStack = mFocusedStack = mLastFocusedStack = getDefaultDisplay().getOrCreateStack(
- WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP);
+ Display[] displays = mDisplayManager.getDisplays();
+ for (int displayNdx = displays.length - 1; displayNdx >= 0; --displayNdx) {
+ final Display display = displays[displayNdx];
+ ActivityDisplay activityDisplay = new ActivityDisplay(this, display);
+ mActivityDisplays.put(display.getDisplayId(), activityDisplay);
+ calculateDefaultMinimalSizeOfResizeableTasks(activityDisplay);
}
+
+ mHomeStack = mFocusedStack = mLastFocusedStack = getDefaultDisplay().getOrCreateStack(
+ WINDOWING_MODE_FULLSCREEN, ACTIVITY_TYPE_HOME, ON_TOP);
}
ActivityStack getFocusedStack() {
@@ -4496,7 +4504,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
}
// The task might have landed on a display different from requested.
// TODO(multi-display): Find proper stack for the task on the default display.
- mService.setTaskWindowingMode(task.taskId,
+ mAtm.setTaskWindowingMode(task.taskId,
WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY, true /* toTop */);
if (preferredDisplayId != actualDisplayId) {
// Display a warning toast that we tried to put a non-resizeable task on a secondary
@@ -4823,7 +4831,7 @@ public class ActivityStackSupervisor extends ConfigurationContainer implements D
sendPowerHintForLaunchStartIfNeeded(true /* forceSend */, targetActivity);
mActivityMetricsLogger.notifyActivityLaunching();
try {
- mService.moveTaskToFrontLocked(task.taskId, 0, options,
+ mService.mActivityTaskManager.moveTaskToFrontLocked(task.taskId, 0, options,
true /* fromRecents */);
} finally {
mActivityMetricsLogger.notifyActivityLaunched(START_TASK_TO_FRONT,
diff --git a/services/core/java/com/android/server/am/ActivityStarter.java b/services/core/java/com/android/server/am/ActivityStarter.java
index 73e3d33073fc..3297560612ec 100644
--- a/services/core/java/com/android/server/am/ActivityStarter.java
+++ b/services/core/java/com/android/server/am/ActivityStarter.java
@@ -2251,7 +2251,8 @@ class ActivityStarter {
final ActivityStack stack = task.getStack();
if (stack != null && stack.resizeStackWithLaunchBounds()) {
- mService.resizeStack(stack.mStackId, bounds, true, !PRESERVE_WINDOWS, ANIMATE, -1);
+ mService.mActivityTaskManager.resizeStack(
+ stack.mStackId, bounds, true, !PRESERVE_WINDOWS, ANIMATE, -1);
} else {
task.updateOverrideConfiguration(bounds);
}
diff --git a/services/core/java/com/android/server/am/ActivityTaskManagerService.java b/services/core/java/com/android/server/am/ActivityTaskManagerService.java
new file mode 100644
index 000000000000..c6edfe59cd3e
--- /dev/null
+++ b/services/core/java/com/android/server/am/ActivityTaskManagerService.java
@@ -0,0 +1,3330 @@
+/*
+ * 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.server.am;
+
+import static android.Manifest.permission.BIND_VOICE_INTERACTION;
+import static android.Manifest.permission.CHANGE_CONFIGURATION;
+import static android.Manifest.permission.CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS;
+import static android.Manifest.permission.INTERNAL_SYSTEM_WINDOW;
+import static android.Manifest.permission.MANAGE_ACTIVITY_STACKS;
+import static android.Manifest.permission.READ_FRAME_BUFFER;
+import static android.Manifest.permission.REMOVE_TASKS;
+import static android.Manifest.permission.START_TASKS_FROM_RECENTS;
+import static android.app.ActivityManager.LOCK_TASK_MODE_NONE;
+import static android.app.ActivityManagerInternal.ASSIST_KEY_CONTENT;
+import static android.app.ActivityManagerInternal.ASSIST_KEY_DATA;
+import static android.app.ActivityManagerInternal.ASSIST_KEY_RECEIVER_EXTRAS;
+import static android.app.ActivityManagerInternal.ASSIST_KEY_STRUCTURE;
+import static android.app.ActivityTaskManager.INVALID_STACK_ID;
+import static android.app.ActivityTaskManager.RESIZE_MODE_PRESERVE_WINDOW;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
+import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
+import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
+import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN;
+import static android.app.WindowConfiguration.WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY;
+import static android.app.WindowConfiguration.WINDOWING_MODE_PINNED;
+import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_PRIMARY;
+import static android.app.WindowConfiguration.WINDOWING_MODE_SPLIT_SCREEN_SECONDARY;
+import static android.app.WindowConfiguration.WINDOWING_MODE_UNDEFINED;
+import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
+import static android.os.Process.SYSTEM_UID;
+import static android.service.voice.VoiceInteractionSession.SHOW_SOURCE_APPLICATION;
+import static android.view.Display.DEFAULT_DISPLAY;
+import static android.view.Display.INVALID_DISPLAY;
+import static android.view.WindowManager.TRANSIT_TASK_IN_PLACE;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_ALL;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_CONFIGURATION;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_FOCUS;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_IMMERSIVE;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_LOCKTASK;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_STACK;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_SWITCH;
+import static com.android.server.am.ActivityManagerDebugConfig.DEBUG_VISIBILITY;
+import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_FOCUS;
+import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_IMMERSIVE;
+import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_LOCKTASK;
+import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_STACK;
+import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_SWITCH;
+import static com.android.server.am.ActivityManagerDebugConfig.POSTFIX_VISIBILITY;
+import static com.android.server.am.ActivityManagerDebugConfig.TAG_AM;
+import static com.android.server.am.ActivityManagerDebugConfig.TAG_WITH_CLASS_NAME;
+import static com.android.server.am.ActivityManagerService.ALLOW_FULL_ONLY;
+import static com.android.server.am.ActivityManagerService.ANIMATE;
+import static com.android.server.am.ActivityManagerService.DISPATCH_SCREEN_KEYGUARD_MSG;
+import static com.android.server.am.ActivityManagerService.ENTER_ANIMATION_COMPLETE_MSG;
+import static com.android.server.am.ActivityManagerService.STOCK_PM_FLAGS;
+import static com.android.server.am.ActivityStack.REMOVE_TASK_MODE_DESTROYING;
+import static com.android.server.am.ActivityStackSupervisor.DEFER_RESUME;
+import static com.android.server.am.ActivityStackSupervisor.MATCH_TASK_IN_STACKS_ONLY;
+import static com.android.server.am.ActivityStackSupervisor.MATCH_TASK_IN_STACKS_OR_RECENT_TASKS;
+import static com.android.server.am.ActivityStackSupervisor.ON_TOP;
+import static com.android.server.am.ActivityStackSupervisor.PRESERVE_WINDOWS;
+import static com.android.server.am.ActivityStackSupervisor.REMOVE_FROM_RECENTS;
+import static com.android.server.am.TaskRecord.INVALID_TASK_ID;
+import static com.android.server.am.TaskRecord.LOCK_TASK_AUTH_DONT_LOCK;
+import static com.android.server.am.TaskRecord.REPARENT_KEEP_STACK_AT_FRONT;
+import static com.android.server.am.TaskRecord.REPARENT_LEAVE_STACK_IN_PLACE;
+import static com.android.server.wm.RecentsAnimationController.REORDER_KEEP_IN_PLACE;
+import static com.android.server.wm.RecentsAnimationController.REORDER_MOVE_TO_ORIGINAL_POSITION;
+
+import android.Manifest;
+import android.annotation.Nullable;
+import android.annotation.UserIdInt;
+import android.app.Activity;
+import android.app.ActivityManager;
+import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
+import android.app.AppGlobals;
+import android.app.IActivityTaskManager;
+import android.app.IApplicationThread;
+import android.app.IAssistDataReceiver;
+import android.app.ITaskStackListener;
+import android.app.PictureInPictureParams;
+import android.app.ProfilerInfo;
+import android.app.RemoteAction;
+import android.app.WaitResult;
+import android.app.WindowConfiguration;
+import android.app.admin.DevicePolicyCache;
+import android.app.assist.AssistContent;
+import android.app.assist.AssistStructure;
+import android.app.usage.UsageEvents;
+import android.content.ActivityNotFoundException;
+import android.content.ComponentName;
+import android.content.Context;
+import android.content.IIntentSender;
+import android.content.Intent;
+import android.content.pm.ActivityInfo;
+import android.content.pm.PackageManager;
+import android.content.pm.ParceledListSlice;
+import android.content.pm.ResolveInfo;
+import android.content.res.Configuration;
+import android.graphics.Bitmap;
+import android.graphics.Point;
+import android.graphics.Rect;
+import android.metrics.LogMaker;
+import android.net.Uri;
+import android.os.Binder;
+import android.os.Bundle;
+import android.os.IBinder;
+import android.os.PersistableBundle;
+import android.os.RemoteException;
+import android.os.TransactionTooLargeException;
+import android.os.UserHandle;
+import android.provider.Settings;
+import android.service.voice.IVoiceInteractionSession;
+import android.service.voice.VoiceInteractionManagerInternal;
+import android.telecom.TelecomManager;
+import android.text.TextUtils;
+import android.util.Slog;
+
+import android.view.IRecentsAnimationRunner;
+import android.view.RemoteAnimationAdapter;
+import android.view.RemoteAnimationDefinition;
+
+import com.android.internal.app.AssistUtils;
+import com.android.internal.app.IVoiceInteractor;
+import com.android.internal.logging.MetricsLogger;
+import com.android.internal.os.logging.MetricsLoggerWrapper;
+import com.android.internal.logging.nano.MetricsProto.MetricsEvent;
+import com.android.internal.policy.IKeyguardDismissCallback;
+import com.android.internal.policy.KeyguardDismissCallback;
+import com.android.server.LocalServices;
+import com.android.server.SystemService;
+import com.android.server.Watchdog;
+import com.android.server.vr.VrManagerInternal;
+import com.android.server.wm.PinnedStackWindowController;
+
+import java.io.File;
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * System service for managing activities and their containers (task, stacks, displays,... ).
+ *
+ * {@hide}
+ */
+public class ActivityTaskManagerService extends IActivityTaskManager.Stub {
+ private static final String TAG = TAG_WITH_CLASS_NAME ? "ActivityTaskManagerService" : TAG_AM;
+ private static final String TAG_STACK = TAG + POSTFIX_STACK;
+ private static final String TAG_SWITCH = TAG + POSTFIX_SWITCH;
+ private static final String TAG_IMMERSIVE = TAG + POSTFIX_IMMERSIVE;
+ private static final String TAG_FOCUS = TAG + POSTFIX_FOCUS;
+ private static final String TAG_VISIBILITY = TAG + POSTFIX_VISIBILITY;
+ private static final String TAG_LOCKTASK = TAG + POSTFIX_LOCKTASK;
+
+ private Context mContext;
+ private ActivityManagerService mAm;
+ /* Global service lock used by the package the owns this service. */
+ Object mGlobalLock;
+ private ActivityStackSupervisor mStackSupervisor;
+
+ /** State of external calls telling us if the device is awake or asleep. */
+ private boolean mKeyguardShown = false;
+
+ // Wrapper around VoiceInteractionServiceManager
+ private AssistUtils mAssistUtils;
+
+ // VoiceInteraction session ID that changes for each new request except when
+ // being called for multi-window assist in a single session.
+ private int mViSessionId = 1000;
+
+ // How long to wait in getAssistContextExtras for the activity and foreground services
+ // to respond with the result.
+ private static final int PENDING_ASSIST_EXTRAS_TIMEOUT = 500;
+
+ // How long top wait when going through the modern assist (which doesn't need to block
+ // on getting this result before starting to launch its UI).
+ private static final int PENDING_ASSIST_EXTRAS_LONG_TIMEOUT = 2000;
+
+ // How long to wait in getAutofillAssistStructure() for the activity to respond with the result.
+ private static final int PENDING_AUTOFILL_ASSIST_STRUCTURE_TIMEOUT = 2000;
+
+ private final ArrayList<PendingAssistExtras> mPendingAssistExtras = new ArrayList<>();
+
+ boolean mSuppressResizeConfigChanges;
+
+ private final UpdateConfigurationResult mTmpUpdateConfigurationResult =
+ new UpdateConfigurationResult();
+
+ static final class UpdateConfigurationResult {
+ // Configuration changes that were updated.
+ int changes;
+ // If the activity was relaunched to match the new configuration.
+ boolean activityRelaunched;
+
+ void reset() {
+ changes = 0;
+ activityRelaunched = false;
+ }
+ }
+
+ ActivityTaskManagerService(Context context) {
+ mContext = context;
+ }
+
+ void onSystemReady() {
+ mAssistUtils = new AssistUtils(mContext);
+ }
+
+ // TODO: Will be converted to WM lock once transition is complete.
+ void setActivityManagerService(ActivityManagerService am) {
+ mAm = am;
+ mGlobalLock = mAm;
+ mStackSupervisor = mAm.mStackSupervisor;
+ }
+
+ public static final class Lifecycle extends SystemService {
+ private final ActivityTaskManagerService mService;
+
+ public Lifecycle(Context context) {
+ super(context);
+ mService = new ActivityTaskManagerService(context);
+ }
+
+ @Override
+ public void onStart() {
+ publishBinderService(Context.ACTIVITY_TASK_SERVICE, mService);
+ }
+
+ public ActivityTaskManagerService getService() {
+ return mService;
+ }
+ }
+
+ @Override
+ public final int startActivity(IApplicationThread caller, String callingPackage,
+ Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int startFlags, ProfilerInfo profilerInfo, Bundle bOptions) {
+ return startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo,
+ resultWho, requestCode, startFlags, profilerInfo, bOptions,
+ UserHandle.getCallingUserId());
+ }
+
+ @Override
+ public final int startActivities(IApplicationThread caller, String callingPackage,
+ Intent[] intents, String[] resolvedTypes, IBinder resultTo, Bundle bOptions,
+ int userId) {
+ final String reason = "startActivities";
+ mAm.enforceNotIsolatedCaller(reason);
+ userId = mAm.mUserController.handleIncomingUser(Binder.getCallingPid(),
+ Binder.getCallingUid(), userId, false, ALLOW_FULL_ONLY, reason, null);
+ // TODO: Switch to user app stacks here.
+ return mAm.getActivityStartController().startActivities(caller, -1, callingPackage, intents,
+ resolvedTypes, resultTo, SafeActivityOptions.fromBundle(bOptions), userId, reason);
+ }
+
+ @Override
+ public int startActivityAsUser(IApplicationThread caller, String callingPackage,
+ Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId) {
+ return startActivityAsUser(caller, callingPackage, intent, resolvedType, resultTo,
+ resultWho, requestCode, startFlags, profilerInfo, bOptions, userId,
+ true /*validateIncomingUser*/);
+ }
+
+ int startActivityAsUser(IApplicationThread caller, String callingPackage,
+ Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId,
+ boolean validateIncomingUser) {
+ mAm.enforceNotIsolatedCaller("startActivityAsUser");
+
+ userId = mAm.getActivityStartController().checkTargetUser(userId, validateIncomingUser,
+ Binder.getCallingPid(), Binder.getCallingUid(), "startActivityAsUser");
+
+ // TODO: Switch to user app stacks here.
+ return mAm.getActivityStartController().obtainStarter(intent, "startActivityAsUser")
+ .setCaller(caller)
+ .setCallingPackage(callingPackage)
+ .setResolvedType(resolvedType)
+ .setResultTo(resultTo)
+ .setResultWho(resultWho)
+ .setRequestCode(requestCode)
+ .setStartFlags(startFlags)
+ .setProfilerInfo(profilerInfo)
+ .setActivityOptions(bOptions)
+ .setMayWait(userId)
+ .execute();
+
+ }
+
+ @Override
+ public int startActivityIntentSender(IApplicationThread caller, IIntentSender target,
+ IBinder whitelistToken, Intent fillInIntent, String resolvedType, IBinder resultTo,
+ String resultWho, int requestCode, int flagsMask, int flagsValues, Bundle bOptions)
+ throws TransactionTooLargeException {
+ mAm.enforceNotIsolatedCaller("startActivityIntentSender");
+ // Refuse possible leaked file descriptors
+ if (fillInIntent != null && fillInIntent.hasFileDescriptors()) {
+ throw new IllegalArgumentException("File descriptors passed in Intent");
+ }
+
+ if (!(target instanceof PendingIntentRecord)) {
+ throw new IllegalArgumentException("Bad PendingIntent object");
+ }
+
+ PendingIntentRecord pir = (PendingIntentRecord)target;
+
+ synchronized (mGlobalLock) {
+ // If this is coming from the currently resumed activity, it is
+ // effectively saying that app switches are allowed at this point.
+ final ActivityStack stack = mAm.getFocusedStack();
+ if (stack.mResumedActivity != null &&
+ stack.mResumedActivity.info.applicationInfo.uid == Binder.getCallingUid()) {
+ mAm.mAppSwitchesAllowedTime = 0;
+ }
+ }
+ int ret = pir.sendInner(0, fillInIntent, resolvedType, whitelistToken, null, null,
+ resultTo, resultWho, requestCode, flagsMask, flagsValues, bOptions);
+ return ret;
+ }
+
+ @Override
+ public boolean startNextMatchingActivity(IBinder callingActivity, Intent intent,
+ Bundle bOptions) {
+ // Refuse possible leaked file descriptors
+ if (intent != null && intent.hasFileDescriptors()) {
+ throw new IllegalArgumentException("File descriptors passed in Intent");
+ }
+ SafeActivityOptions options = SafeActivityOptions.fromBundle(bOptions);
+
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(callingActivity);
+ if (r == null) {
+ SafeActivityOptions.abort(options);
+ return false;
+ }
+ if (r.app == null || r.app.thread == null) {
+ // The caller is not running... d'oh!
+ SafeActivityOptions.abort(options);
+ return false;
+ }
+ intent = new Intent(intent);
+ // The caller is not allowed to change the data.
+ intent.setDataAndType(r.intent.getData(), r.intent.getType());
+ // And we are resetting to find the next component...
+ intent.setComponent(null);
+
+ final boolean debug = ((intent.getFlags() & Intent.FLAG_DEBUG_LOG_RESOLUTION) != 0);
+
+ ActivityInfo aInfo = null;
+ try {
+ List<ResolveInfo> resolves =
+ AppGlobals.getPackageManager().queryIntentActivities(
+ intent, r.resolvedType,
+ PackageManager.MATCH_DEFAULT_ONLY | STOCK_PM_FLAGS,
+ UserHandle.getCallingUserId()).getList();
+
+ // Look for the original activity in the list...
+ final int N = resolves != null ? resolves.size() : 0;
+ for (int i=0; i<N; i++) {
+ ResolveInfo rInfo = resolves.get(i);
+ if (rInfo.activityInfo.packageName.equals(r.packageName)
+ && rInfo.activityInfo.name.equals(r.info.name)) {
+ // We found the current one... the next matching is
+ // after it.
+ i++;
+ if (i<N) {
+ aInfo = resolves.get(i).activityInfo;
+ }
+ if (debug) {
+ Slog.v(TAG, "Next matching activity: found current " + r.packageName
+ + "/" + r.info.name);
+ Slog.v(TAG, "Next matching activity: next is " + ((aInfo == null)
+ ? "null" : aInfo.packageName + "/" + aInfo.name));
+ }
+ break;
+ }
+ }
+ } catch (RemoteException e) {
+ }
+
+ if (aInfo == null) {
+ // Nobody who is next!
+ SafeActivityOptions.abort(options);
+ if (debug) Slog.d(TAG, "Next matching activity: nothing found");
+ return false;
+ }
+
+ intent.setComponent(new ComponentName(
+ aInfo.applicationInfo.packageName, aInfo.name));
+ intent.setFlags(intent.getFlags()&~(
+ Intent.FLAG_ACTIVITY_FORWARD_RESULT|
+ Intent.FLAG_ACTIVITY_CLEAR_TOP|
+ Intent.FLAG_ACTIVITY_MULTIPLE_TASK|
+ FLAG_ACTIVITY_NEW_TASK));
+
+ // Okay now we need to start the new activity, replacing the currently running activity.
+ // This is a little tricky because we want to start the new one as if the current one is
+ // finished, but not finish the current one first so that there is no flicker.
+ // And thus...
+ final boolean wasFinishing = r.finishing;
+ r.finishing = true;
+
+ // Propagate reply information over to the new activity.
+ final ActivityRecord resultTo = r.resultTo;
+ final String resultWho = r.resultWho;
+ final int requestCode = r.requestCode;
+ r.resultTo = null;
+ if (resultTo != null) {
+ resultTo.removeResultsLocked(r, resultWho, requestCode);
+ }
+
+ final long origId = Binder.clearCallingIdentity();
+ // TODO(b/64750076): Check if calling pid should really be -1.
+ final int res = mAm.getActivityStartController()
+ .obtainStarter(intent, "startNextMatchingActivity")
+ .setCaller(r.app.thread)
+ .setResolvedType(r.resolvedType)
+ .setActivityInfo(aInfo)
+ .setResultTo(resultTo != null ? resultTo.appToken : null)
+ .setResultWho(resultWho)
+ .setRequestCode(requestCode)
+ .setCallingPid(-1)
+ .setCallingUid(r.launchedFromUid)
+ .setCallingPackage(r.launchedFromPackage)
+ .setRealCallingPid(-1)
+ .setRealCallingUid(r.launchedFromUid)
+ .setActivityOptions(options)
+ .execute();
+ Binder.restoreCallingIdentity(origId);
+
+ r.finishing = wasFinishing;
+ if (res != ActivityManager.START_SUCCESS) {
+ return false;
+ }
+ return true;
+ }
+ }
+
+ @Override
+ public final WaitResult startActivityAndWait(IApplicationThread caller, String callingPackage,
+ Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, int userId) {
+ final WaitResult res = new WaitResult();
+ synchronized (mGlobalLock) {
+ mAm.enforceNotIsolatedCaller("startActivityAndWait");
+ userId = mAm.mUserController.handleIncomingUser(Binder.getCallingPid(),
+ Binder.getCallingUid(), userId, false, ALLOW_FULL_ONLY,
+ "startActivityAndWait", null);
+ // TODO: Switch to user app stacks here.
+ mAm.getActivityStartController().obtainStarter(intent, "startActivityAndWait")
+ .setCaller(caller)
+ .setCallingPackage(callingPackage)
+ .setResolvedType(resolvedType)
+ .setResultTo(resultTo)
+ .setResultWho(resultWho)
+ .setRequestCode(requestCode)
+ .setStartFlags(startFlags)
+ .setActivityOptions(bOptions)
+ .setMayWait(userId)
+ .setProfilerInfo(profilerInfo)
+ .setWaitResult(res)
+ .execute();
+ }
+ return res;
+ }
+
+ @Override
+ public final int startActivityWithConfig(IApplicationThread caller, String callingPackage,
+ Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int startFlags, Configuration config, Bundle bOptions, int userId) {
+ synchronized (mGlobalLock) {
+ mAm.enforceNotIsolatedCaller("startActivityWithConfig");
+ userId = mAm.mUserController.handleIncomingUser(Binder.getCallingPid(),
+ Binder.getCallingUid(), userId, false, ALLOW_FULL_ONLY,
+ "startActivityWithConfig", null);
+ // TODO: Switch to user app stacks here.
+ return mAm.getActivityStartController().obtainStarter(intent, "startActivityWithConfig")
+ .setCaller(caller)
+ .setCallingPackage(callingPackage)
+ .setResolvedType(resolvedType)
+ .setResultTo(resultTo)
+ .setResultWho(resultWho)
+ .setRequestCode(requestCode)
+ .setStartFlags(startFlags)
+ .setGlobalConfiguration(config)
+ .setActivityOptions(bOptions)
+ .setMayWait(userId)
+ .execute();
+ }
+ }
+
+ @Override
+ public final int startActivityAsCaller(IApplicationThread caller, String callingPackage,
+ Intent intent, String resolvedType, IBinder resultTo, String resultWho, int requestCode,
+ int startFlags, ProfilerInfo profilerInfo, Bundle bOptions, boolean ignoreTargetSecurity,
+ int userId) {
+
+ // This is very dangerous -- it allows you to perform a start activity (including
+ // permission grants) as any app that may launch one of your own activities. So
+ // we will only allow this to be done from activities that are part of the core framework,
+ // and then only when they are running as the system.
+ final ActivityRecord sourceRecord;
+ final int targetUid;
+ final String targetPackage;
+ final boolean isResolver;
+ synchronized (mGlobalLock) {
+ if (resultTo == null) {
+ throw new SecurityException("Must be called from an activity");
+ }
+ sourceRecord = mStackSupervisor.isInAnyStackLocked(resultTo);
+ if (sourceRecord == null) {
+ throw new SecurityException("Called with bad activity token: " + resultTo);
+ }
+ if (!sourceRecord.info.packageName.equals("android")) {
+ throw new SecurityException(
+ "Must be called from an activity that is declared in the android package");
+ }
+ if (sourceRecord.app == null) {
+ throw new SecurityException("Called without a process attached to activity");
+ }
+ if (UserHandle.getAppId(sourceRecord.app.uid) != SYSTEM_UID) {
+ // This is still okay, as long as this activity is running under the
+ // uid of the original calling activity.
+ if (sourceRecord.app.uid != sourceRecord.launchedFromUid) {
+ throw new SecurityException(
+ "Calling activity in uid " + sourceRecord.app.uid
+ + " must be system uid or original calling uid "
+ + sourceRecord.launchedFromUid);
+ }
+ }
+ if (ignoreTargetSecurity) {
+ if (intent.getComponent() == null) {
+ throw new SecurityException(
+ "Component must be specified with ignoreTargetSecurity");
+ }
+ if (intent.getSelector() != null) {
+ throw new SecurityException(
+ "Selector not allowed with ignoreTargetSecurity");
+ }
+ }
+ targetUid = sourceRecord.launchedFromUid;
+ targetPackage = sourceRecord.launchedFromPackage;
+ isResolver = sourceRecord.isResolverOrChildActivity();
+ }
+
+ if (userId == UserHandle.USER_NULL) {
+ userId = UserHandle.getUserId(sourceRecord.app.uid);
+ }
+
+ // TODO: Switch to user app stacks here.
+ try {
+ return mAm.getActivityStartController().obtainStarter(intent, "startActivityAsCaller")
+ .setCallingUid(targetUid)
+ .setCallingPackage(targetPackage)
+ .setResolvedType(resolvedType)
+ .setResultTo(resultTo)
+ .setResultWho(resultWho)
+ .setRequestCode(requestCode)
+ .setStartFlags(startFlags)
+ .setActivityOptions(bOptions)
+ .setMayWait(userId)
+ .setIgnoreTargetSecurity(ignoreTargetSecurity)
+ .setFilterCallingUid(isResolver ? 0 /* system */ : targetUid)
+ .execute();
+ } catch (SecurityException e) {
+ // XXX need to figure out how to propagate to original app.
+ // A SecurityException here is generally actually a fault of the original
+ // calling activity (such as a fairly granting permissions), so propagate it
+ // back to them.
+ /*
+ StringBuilder msg = new StringBuilder();
+ msg.append("While launching");
+ msg.append(intent.toString());
+ msg.append(": ");
+ msg.append(e.getMessage());
+ */
+ throw e;
+ }
+ }
+
+ @Override
+ public int startVoiceActivity(String callingPackage, int callingPid, int callingUid,
+ Intent intent, String resolvedType, IVoiceInteractionSession session,
+ IVoiceInteractor interactor, int startFlags, ProfilerInfo profilerInfo,
+ Bundle bOptions, int userId) {
+ mAm.enforceCallingPermission(BIND_VOICE_INTERACTION, "startVoiceActivity()");
+ if (session == null || interactor == null) {
+ throw new NullPointerException("null session or interactor");
+ }
+ userId = mAm.mUserController.handleIncomingUser(callingPid, callingUid, userId, false,
+ ALLOW_FULL_ONLY, "startVoiceActivity", null);
+ // TODO: Switch to user app stacks here.
+ return mAm.getActivityStartController().obtainStarter(intent, "startVoiceActivity")
+ .setCallingUid(callingUid)
+ .setCallingPackage(callingPackage)
+ .setResolvedType(resolvedType)
+ .setVoiceSession(session)
+ .setVoiceInteractor(interactor)
+ .setStartFlags(startFlags)
+ .setProfilerInfo(profilerInfo)
+ .setActivityOptions(bOptions)
+ .setMayWait(userId)
+ .execute();
+ }
+
+ @Override
+ public int startAssistantActivity(String callingPackage, int callingPid, int callingUid,
+ Intent intent, String resolvedType, Bundle bOptions, int userId) {
+ mAm.enforceCallingPermission(BIND_VOICE_INTERACTION, "startAssistantActivity()");
+ userId = mAm.mUserController.handleIncomingUser(callingPid, callingUid, userId, false,
+ ALLOW_FULL_ONLY, "startAssistantActivity", null);
+
+ return mAm.getActivityStartController().obtainStarter(intent, "startAssistantActivity")
+ .setCallingUid(callingUid)
+ .setCallingPackage(callingPackage)
+ .setResolvedType(resolvedType)
+ .setActivityOptions(bOptions)
+ .setMayWait(userId)
+ .execute();
+ }
+
+ @Override
+ public void startRecentsActivity(Intent intent, IAssistDataReceiver assistDataReceiver,
+ IRecentsAnimationRunner recentsAnimationRunner) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "startRecentsActivity()");
+ final int callingPid = Binder.getCallingPid();
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final ComponentName recentsComponent = mAm.getRecentTasks().getRecentsComponent();
+ final int recentsUid = mAm.getRecentTasks().getRecentsComponentUid();
+
+ // Start a new recents animation
+ final RecentsAnimation anim = new RecentsAnimation(mAm, mStackSupervisor,
+ mAm.getActivityStartController(), mAm.mWindowManager, mAm.mUserController,
+ callingPid);
+ anim.startRecentsActivity(intent, recentsAnimationRunner, recentsComponent,
+ recentsUid, assistDataReceiver);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
+ public final int startActivityFromRecents(int taskId, Bundle bOptions) {
+ mAm.enforceCallerIsRecentsOrHasPermission(START_TASKS_FROM_RECENTS,
+ "startActivityFromRecents()");
+
+ final int callingPid = Binder.getCallingPid();
+ final int callingUid = Binder.getCallingUid();
+ final SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle(bOptions);
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ return mStackSupervisor.startActivityFromRecents(callingPid, callingUid, taskId,
+ safeOptions);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ /**
+ * This is the internal entry point for handling Activity.finish().
+ *
+ * @param token The Binder token referencing the Activity we want to finish.
+ * @param resultCode Result code, if any, from this Activity.
+ * @param resultData Result data (Intent), if any, from this Activity.
+ * @param finishTask Whether to finish the task associated with this Activity.
+ *
+ * @return Returns true if the activity successfully finished, or false if it is still running.
+ */
+ @Override
+ public final boolean finishActivity(IBinder token, int resultCode, Intent resultData,
+ int finishTask) {
+ // Refuse possible leaked file descriptors
+ if (resultData != null && resultData.hasFileDescriptors()) {
+ throw new IllegalArgumentException("File descriptors passed in Intent");
+ }
+
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return true;
+ }
+ // Keep track of the root activity of the task before we finish it
+ TaskRecord tr = r.getTask();
+ ActivityRecord rootR = tr.getRootActivity();
+ if (rootR == null) {
+ Slog.w(TAG, "Finishing task with all activities already finished");
+ }
+ // Do not allow task to finish if last task in lockTask mode. Launchable priv-apps can
+ // finish.
+ if (mAm.getLockTaskController().activityBlockedFromFinish(r)) {
+ return false;
+ }
+
+ if (mAm.mController != null) {
+ // Find the first activity that is not finishing.
+ ActivityRecord next = r.getStack().topRunningActivityLocked(token, 0);
+ if (next != null) {
+ // ask watcher if this is allowed
+ boolean resumeOK = true;
+ try {
+ resumeOK = mAm.mController.activityResuming(next.packageName);
+ } catch (RemoteException e) {
+ mAm.mController = null;
+ Watchdog.getInstance().setActivityController(null);
+ }
+
+ if (!resumeOK) {
+ Slog.i(TAG, "Not finishing activity because controller resumed");
+ return false;
+ }
+ }
+ }
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ boolean res;
+ final boolean finishWithRootActivity =
+ finishTask == Activity.FINISH_TASK_WITH_ROOT_ACTIVITY;
+ if (finishTask == Activity.FINISH_TASK_WITH_ACTIVITY
+ || (finishWithRootActivity && r == rootR)) {
+ // If requested, remove the task that is associated to this activity only if it
+ // was the root activity in the task. The result code and data is ignored
+ // because we don't support returning them across task boundaries. Also, to
+ // keep backwards compatibility we remove the task from recents when finishing
+ // task with root activity.
+ res = mStackSupervisor.removeTaskByIdLocked(tr.taskId, false,
+ finishWithRootActivity, "finish-activity");
+ if (!res) {
+ Slog.i(TAG, "Removing task failed to finish activity");
+ }
+ } else {
+ res = tr.getStack().requestFinishActivityLocked(token, resultCode,
+ resultData, "app-request", true);
+ if (!res) {
+ Slog.i(TAG, "Failed to finish by app-request");
+ }
+ }
+ return res;
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ @Override
+ public boolean finishActivityAffinity(IBinder token) {
+ synchronized (mGlobalLock) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return false;
+ }
+
+ // Do not allow task to finish if last task in lockTask mode. Launchable priv-apps
+ // can finish.
+ final TaskRecord task = r.getTask();
+ if (mAm.getLockTaskController().activityBlockedFromFinish(r)) {
+ return false;
+ }
+ return task.getStack().finishActivityAffinityLocked(r);
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ @Override
+ public final void activityIdle(IBinder token, Configuration config, boolean stopProfiling) {
+ final long origId = Binder.clearCallingIdentity();
+ synchronized (mGlobalLock) {
+ ActivityStack stack = ActivityRecord.getStackLocked(token);
+ if (stack != null) {
+ ActivityRecord r =
+ mStackSupervisor.activityIdleInternalLocked(token, false /* fromTimeout */,
+ false /* processPausingActivities */, config);
+ if (stopProfiling) {
+ if ((mAm.mProfileProc == r.app) && mAm.mProfilerInfo != null) {
+ mAm.clearProfilerLocked();
+ }
+ }
+ }
+ }
+ Binder.restoreCallingIdentity(origId);
+ }
+
+ @Override
+ public final void activityResumed(IBinder token) {
+ final long origId = Binder.clearCallingIdentity();
+ synchronized (mGlobalLock) {
+ ActivityRecord.activityResumedLocked(token);
+ mAm.mWindowManager.notifyAppResumedFinished(token);
+ }
+ Binder.restoreCallingIdentity(origId);
+ }
+
+ @Override
+ public final void activityPaused(IBinder token) {
+ final long origId = Binder.clearCallingIdentity();
+ synchronized (mGlobalLock) {
+ ActivityStack stack = ActivityRecord.getStackLocked(token);
+ if (stack != null) {
+ stack.activityPausedLocked(token, false);
+ }
+ }
+ Binder.restoreCallingIdentity(origId);
+ }
+
+ @Override
+ public final void activityStopped(IBinder token, Bundle icicle,
+ PersistableBundle persistentState, CharSequence description) {
+ if (DEBUG_ALL) Slog.v(TAG, "Activity stopped: token=" + token);
+
+ // Refuse possible leaked file descriptors
+ if (icicle != null && icicle.hasFileDescriptors()) {
+ throw new IllegalArgumentException("File descriptors passed in Bundle");
+ }
+
+ final long origId = Binder.clearCallingIdentity();
+
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r != null) {
+ r.activityStoppedLocked(icicle, persistentState, description);
+ }
+ }
+
+ mAm.trimApplications();
+
+ Binder.restoreCallingIdentity(origId);
+ }
+
+ @Override
+ public final void activityDestroyed(IBinder token) {
+ if (DEBUG_SWITCH) Slog.v(TAG_SWITCH, "ACTIVITY DESTROYED: " + token);
+ synchronized (mGlobalLock) {
+ ActivityStack stack = ActivityRecord.getStackLocked(token);
+ if (stack != null) {
+ stack.activityDestroyedLocked(token, "activityDestroyed");
+ }
+ }
+ }
+
+ @Override
+ public final void activityRelaunched(IBinder token) {
+ final long origId = Binder.clearCallingIdentity();
+ synchronized (mGlobalLock) {
+ mStackSupervisor.activityRelaunchedLocked(token);
+ }
+ Binder.restoreCallingIdentity(origId);
+ }
+
+ public final void activitySlept(IBinder token) {
+ if (DEBUG_ALL) Slog.v(TAG, "Activity slept: token=" + token);
+
+ final long origId = Binder.clearCallingIdentity();
+
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r != null) {
+ mStackSupervisor.activitySleptLocked(r);
+ }
+ }
+
+ Binder.restoreCallingIdentity(origId);
+ }
+
+ @Override
+ public void setRequestedOrientation(IBinder token, int requestedOrientation) {
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return;
+ }
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ r.setRequestedOrientation(requestedOrientation);
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ @Override
+ public int getRequestedOrientation(IBinder token) {
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED;
+ }
+ return r.getRequestedOrientation();
+ }
+ }
+
+ @Override
+ public void setImmersive(IBinder token, boolean immersive) {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ throw new IllegalArgumentException();
+ }
+ r.immersive = immersive;
+
+ // update associated state if we're frontmost
+ if (r == mStackSupervisor.getResumedActivityLocked()) {
+ if (DEBUG_IMMERSIVE) Slog.d(TAG_IMMERSIVE, "Frontmost changed immersion: "+ r);
+ mAm.applyUpdateLockStateLocked(r);
+ }
+ }
+ }
+
+ @Override
+ public boolean isImmersive(IBinder token) {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ throw new IllegalArgumentException();
+ }
+ return r.immersive;
+ }
+ }
+
+ @Override
+ public boolean isTopActivityImmersive() {
+ mAm.enforceNotIsolatedCaller("isTopActivityImmersive");
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = mAm.getFocusedStack().topRunningActivityLocked();
+ return (r != null) ? r.immersive : false;
+ }
+ }
+
+ @Override
+ public void overridePendingTransition(IBinder token, String packageName,
+ int enterAnim, int exitAnim) {
+ synchronized (mGlobalLock) {
+ ActivityRecord self = ActivityRecord.isInStackLocked(token);
+ if (self == null) {
+ return;
+ }
+
+ final long origId = Binder.clearCallingIdentity();
+
+ if (self.isState(
+ ActivityStack.ActivityState.RESUMED, ActivityStack.ActivityState.PAUSING)) {
+ mAm.mWindowManager.overridePendingAppTransition(packageName,
+ enterAnim, exitAnim, null);
+ }
+
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
+ public int getFrontActivityScreenCompatMode() {
+ mAm.enforceNotIsolatedCaller("getFrontActivityScreenCompatMode");
+ synchronized (mGlobalLock) {
+ return mAm.mCompatModePackages.getFrontActivityScreenCompatModeLocked();
+ }
+ }
+
+ @Override
+ public void setFrontActivityScreenCompatMode(int mode) {
+ mAm.enforceCallingPermission(android.Manifest.permission.SET_SCREEN_COMPATIBILITY,
+ "setFrontActivityScreenCompatMode");
+ synchronized (mGlobalLock) {
+ mAm.mCompatModePackages.setFrontActivityScreenCompatModeLocked(mode);
+ }
+ }
+
+ @Override
+ public int getLaunchedFromUid(IBinder activityToken) {
+ ActivityRecord srec;
+ synchronized (mGlobalLock) {
+ srec = ActivityRecord.forTokenLocked(activityToken);
+ }
+ if (srec == null) {
+ return -1;
+ }
+ return srec.launchedFromUid;
+ }
+
+ @Override
+ public String getLaunchedFromPackage(IBinder activityToken) {
+ ActivityRecord srec;
+ synchronized (mGlobalLock) {
+ srec = ActivityRecord.forTokenLocked(activityToken);
+ }
+ if (srec == null) {
+ return null;
+ }
+ return srec.launchedFromPackage;
+ }
+
+ @Override
+ public boolean convertFromTranslucent(IBinder token) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return false;
+ }
+ final boolean translucentChanged = r.changeWindowTranslucency(true);
+ if (translucentChanged) {
+ mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
+ }
+ mAm.mWindowManager.setAppFullscreen(token, true);
+ return translucentChanged;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
+ public boolean convertToTranslucent(IBinder token, Bundle options) {
+ SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle(options);
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return false;
+ }
+ final TaskRecord task = r.getTask();
+ int index = task.mActivities.lastIndexOf(r);
+ if (index > 0) {
+ ActivityRecord under = task.mActivities.get(index - 1);
+ under.returningOptions = safeOptions != null ? safeOptions.getOptions(r) : null;
+ }
+ final boolean translucentChanged = r.changeWindowTranslucency(false);
+ if (translucentChanged) {
+ r.getStack().convertActivityToTranslucent(r);
+ }
+ mStackSupervisor.ensureActivitiesVisibleLocked(null, 0, !PRESERVE_WINDOWS);
+ mAm.mWindowManager.setAppFullscreen(token, false);
+ return translucentChanged;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
+ public void notifyActivityDrawn(IBinder token) {
+ if (DEBUG_VISIBILITY) Slog.d(TAG_VISIBILITY, "notifyActivityDrawn: token=" + token);
+ synchronized (mGlobalLock) {
+ ActivityRecord r = mStackSupervisor.isInAnyStackLocked(token);
+ if (r != null) {
+ r.getStack().notifyActivityDrawnLocked(r);
+ }
+ }
+ }
+
+ @Override
+ public void reportActivityFullyDrawn(IBinder token, boolean restoredFromBundle) {
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return;
+ }
+ r.reportFullyDrawnLocked(restoredFromBundle);
+ }
+ }
+
+ @Override
+ public int getActivityDisplayId(IBinder activityToken) throws RemoteException {
+ synchronized (mGlobalLock) {
+ final ActivityStack stack = ActivityRecord.getStackLocked(activityToken);
+ if (stack != null && stack.mDisplayId != INVALID_DISPLAY) {
+ return stack.mDisplayId;
+ }
+ return DEFAULT_DISPLAY;
+ }
+ }
+
+ @Override
+ public ActivityManager.StackInfo getFocusedStackInfo() throws RemoteException {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "getStackInfo()");
+ long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ ActivityStack focusedStack = mAm.getFocusedStack();
+ if (focusedStack != null) {
+ return mStackSupervisor.getStackInfo(focusedStack.mStackId);
+ }
+ return null;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void setFocusedStack(int stackId) {
+ mAm.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "setFocusedStack()");
+ if (DEBUG_FOCUS) Slog.d(TAG_FOCUS, "setFocusedStack: stackId=" + stackId);
+ final long callingId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final ActivityStack stack = mStackSupervisor.getStack(stackId);
+ if (stack == null) {
+ Slog.w(TAG, "setFocusedStack: No stack with id=" + stackId);
+ return;
+ }
+ final ActivityRecord r = stack.topRunningActivityLocked();
+ if (mStackSupervisor.moveFocusableActivityStackToFrontLocked(
+ r, "setFocusedStack")) {
+ mStackSupervisor.resumeFocusedStackTopActivityLocked();
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(callingId);
+ }
+ }
+
+ @Override
+ public void setFocusedTask(int taskId) {
+ mAm.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "setFocusedTask()");
+ if (DEBUG_FOCUS) Slog.d(TAG_FOCUS, "setFocusedTask: taskId=" + taskId);
+ final long callingId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
+ if (task == null) {
+ return;
+ }
+ final ActivityRecord r = task.topRunningActivityLocked();
+ if (mStackSupervisor.moveFocusableActivityStackToFrontLocked(r, "setFocusedTask")) {
+ mStackSupervisor.resumeFocusedStackTopActivityLocked();
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(callingId);
+ }
+ }
+
+ @Override
+ public boolean removeTask(int taskId) {
+ mAm.enforceCallerIsRecentsOrHasPermission(REMOVE_TASKS, "removeTask()");
+ synchronized (mGlobalLock) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ return mStackSupervisor.removeTaskByIdLocked(taskId, true, REMOVE_FROM_RECENTS,
+ "remove-task");
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ @Override
+ public boolean shouldUpRecreateTask(IBinder token, String destAffinity) {
+ synchronized (mGlobalLock) {
+ final ActivityRecord srec = ActivityRecord.forTokenLocked(token);
+ if (srec != null) {
+ return srec.getStack().shouldUpRecreateTaskLocked(srec, destAffinity);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public boolean navigateUpTo(IBinder token, Intent destIntent, int resultCode,
+ Intent resultData) {
+
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.forTokenLocked(token);
+ if (r != null) {
+ return r.getStack().navigateUpToLocked(r, destIntent, resultCode, resultData);
+ }
+ return false;
+ }
+ }
+
+ /**
+ * Attempts to move a task backwards in z-order (the order of activities within the task is
+ * unchanged).
+ *
+ * There are several possible results of this call:
+ * - if the task is locked, then we will show the lock toast
+ * - if there is a task behind the provided task, then that task is made visible and resumed as
+ * this task is moved to the back
+ * - otherwise, if there are no other tasks in the stack:
+ * - if this task is in the pinned stack, then we remove the stack completely, which will
+ * have the effect of moving the task to the top or bottom of the fullscreen stack
+ * (depending on whether it is visible)
+ * - otherwise, we simply return home and hide this task
+ *
+ * @param token A reference to the activity we wish to move
+ * @param nonRoot If false then this only works if the activity is the root
+ * of a task; if true it will work for any activity in a task.
+ * @return Returns true if the move completed, false if not.
+ */
+ @Override
+ public boolean moveActivityTaskToBack(IBinder token, boolean nonRoot) {
+ mAm.enforceNotIsolatedCaller("moveActivityTaskToBack");
+ synchronized (mGlobalLock) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ int taskId = ActivityRecord.getTaskForActivityLocked(token, !nonRoot);
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
+ if (task != null) {
+ return ActivityRecord.getStackLocked(token).moveTaskToBackLocked(taskId);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ return false;
+ }
+
+ @Override
+ public Rect getTaskBounds(int taskId) {
+ mAm.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "getTaskBounds()");
+ long ident = Binder.clearCallingIdentity();
+ Rect rect = new Rect();
+ try {
+ synchronized (mGlobalLock) {
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId,
+ MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
+ if (task == null) {
+ Slog.w(TAG, "getTaskBounds: taskId=" + taskId + " not found");
+ return rect;
+ }
+ if (task.getStack() != null) {
+ // Return the bounds from window manager since it will be adjusted for various
+ // things like the presense of a docked stack for tasks that aren't resizeable.
+ task.getWindowContainerBounds(rect);
+ } else {
+ // Task isn't in window manager yet since it isn't associated with a stack.
+ // Return the persist value from activity manager
+ if (!task.matchParentBounds()) {
+ rect.set(task.getBounds());
+ } else if (task.mLastNonFullscreenBounds != null) {
+ rect.set(task.mLastNonFullscreenBounds);
+ }
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ return rect;
+ }
+
+ @Override
+ public ActivityManager.TaskDescription getTaskDescription(int id) {
+ synchronized (mGlobalLock) {
+ mAm.enforceCallerIsRecentsOrHasPermission(
+ MANAGE_ACTIVITY_STACKS, "getTaskDescription()");
+ final TaskRecord tr = mStackSupervisor.anyTaskForIdLocked(id,
+ MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
+ if (tr != null) {
+ return tr.lastTaskDescription;
+ }
+ }
+ return null;
+ }
+
+ @Override
+ public void setTaskWindowingMode(int taskId, int windowingMode, boolean toTop) {
+ if (windowingMode == WINDOWING_MODE_SPLIT_SCREEN_PRIMARY) {
+ setTaskWindowingModeSplitScreenPrimary(taskId, SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT,
+ toTop, ANIMATE, null /* initialBounds */, true /* showRecents */);
+ return;
+ }
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "setTaskWindowingMode()");
+ synchronized (mGlobalLock) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
+ if (task == null) {
+ Slog.w(TAG, "setTaskWindowingMode: No task for id=" + taskId);
+ return;
+ }
+
+ if (DEBUG_STACK) Slog.d(TAG_STACK, "setTaskWindowingMode: moving task=" + taskId
+ + " to windowingMode=" + windowingMode + " toTop=" + toTop);
+
+ if (!task.isActivityTypeStandardOrUndefined()) {
+ throw new IllegalArgumentException("setTaskWindowingMode: Attempt to move"
+ + " non-standard task " + taskId + " to windowing mode="
+ + windowingMode);
+ }
+
+ final ActivityStack stack = task.getStack();
+ if (toTop) {
+ stack.moveToFront("setTaskWindowingMode", task);
+ }
+ stack.setWindowingMode(windowingMode);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ @Override
+ public String getCallingPackage(IBinder token) {
+ synchronized (this) {
+ ActivityRecord r = getCallingRecordLocked(token);
+ return r != null ? r.info.packageName : null;
+ }
+ }
+
+ @Override
+ public ComponentName getCallingActivity(IBinder token) {
+ synchronized (this) {
+ ActivityRecord r = getCallingRecordLocked(token);
+ return r != null ? r.intent.getComponent() : null;
+ }
+ }
+
+ private ActivityRecord getCallingRecordLocked(IBinder token) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return null;
+ }
+ return r.resultTo;
+ }
+
+ @Override
+ public void unhandledBack() {
+ mAm.enforceCallingPermission(android.Manifest.permission.FORCE_BACK, "unhandledBack()");
+
+ synchronized (mGlobalLock) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ mAm.getFocusedStack().unhandledBackLocked();
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ /**
+ * TODO: Add mController hook
+ */
+ @Override
+ public void moveTaskToFront(int taskId, int flags, Bundle bOptions) {
+ mAm.enforceCallingPermission(android.Manifest.permission.REORDER_TASKS, "moveTaskToFront()");
+
+ if (DEBUG_STACK) Slog.d(TAG_STACK, "moveTaskToFront: moving taskId=" + taskId);
+ synchronized (mGlobalLock) {
+ moveTaskToFrontLocked(taskId, flags, SafeActivityOptions.fromBundle(bOptions),
+ false /* fromRecents */);
+ }
+ }
+
+ void moveTaskToFrontLocked(int taskId, int flags, SafeActivityOptions options,
+ boolean fromRecents) {
+
+ if (!mAm.checkAppSwitchAllowedLocked(Binder.getCallingPid(),
+ Binder.getCallingUid(), -1, -1, "Task to front")) {
+ SafeActivityOptions.abort(options);
+ return;
+ }
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
+ if (task == null) {
+ Slog.d(TAG, "Could not find task for id: "+ taskId);
+ return;
+ }
+ if (mAm.getLockTaskController().isLockTaskModeViolation(task)) {
+ Slog.e(TAG, "moveTaskToFront: Attempt to violate Lock Task Mode");
+ return;
+ }
+ ActivityOptions realOptions = options != null
+ ? options.getOptions(mStackSupervisor)
+ : null;
+ mStackSupervisor.findTaskToMoveToFront(task, flags, realOptions, "moveTaskToFront",
+ false /* forceNonResizable */);
+
+ final ActivityRecord topActivity = task.getTopActivity();
+ if (topActivity != null) {
+
+ // We are reshowing a task, use a starting window to hide the initial draw delay
+ // so the transition can start earlier.
+ topActivity.showStartingWindow(null /* prev */, false /* newTask */,
+ true /* taskSwitch */, fromRecents);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ SafeActivityOptions.abort(options);
+ }
+
+ @Override
+ public int getTaskForActivity(IBinder token, boolean onlyRoot) {
+ synchronized (mGlobalLock) {
+ return ActivityRecord.getTaskForActivityLocked(token, onlyRoot);
+ }
+ }
+
+ @Override
+ public List<ActivityManager.RunningTaskInfo> getTasks(int maxNum) {
+ return getFilteredTasks(maxNum, ACTIVITY_TYPE_UNDEFINED, WINDOWING_MODE_UNDEFINED);
+ }
+
+ @Override
+ public List<ActivityManager.RunningTaskInfo> getFilteredTasks(int maxNum,
+ @WindowConfiguration.ActivityType int ignoreActivityType,
+ @WindowConfiguration.WindowingMode int ignoreWindowingMode) {
+ final int callingUid = Binder.getCallingUid();
+ ArrayList<ActivityManager.RunningTaskInfo> list = new ArrayList<>();
+
+ synchronized (mGlobalLock) {
+ if (DEBUG_ALL) Slog.v(TAG, "getTasks: max=" + maxNum);
+
+ final boolean allowed = mAm.isGetTasksAllowed("getTasks", Binder.getCallingPid(),
+ callingUid);
+ mStackSupervisor.getRunningTasks(maxNum, list, ignoreActivityType,
+ ignoreWindowingMode, callingUid, allowed);
+ }
+
+ return list;
+ }
+
+ @Override
+ public final void finishSubActivity(IBinder token, String resultWho, int requestCode) {
+ synchronized (mGlobalLock) {
+ final long origId = Binder.clearCallingIdentity();
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r != null) {
+ r.getStack().finishSubActivityLocked(r, resultWho, requestCode);
+ }
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
+ public boolean willActivityBeVisible(IBinder token) {
+ synchronized(this) {
+ ActivityStack stack = ActivityRecord.getStackLocked(token);
+ if (stack != null) {
+ return stack.willActivityBeVisibleLocked(token);
+ }
+ return false;
+ }
+ }
+
+ @Override
+ public void moveTaskToStack(int taskId, int stackId, boolean toTop) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "moveTaskToStack()");
+ synchronized (mGlobalLock) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
+ if (task == null) {
+ Slog.w(TAG, "moveTaskToStack: No task for id=" + taskId);
+ return;
+ }
+
+ if (DEBUG_STACK) Slog.d(TAG_STACK, "moveTaskToStack: moving task=" + taskId
+ + " to stackId=" + stackId + " toTop=" + toTop);
+
+ final ActivityStack stack = mStackSupervisor.getStack(stackId);
+ if (stack == null) {
+ throw new IllegalStateException(
+ "moveTaskToStack: No stack for stackId=" + stackId);
+ }
+ if (!stack.isActivityTypeStandardOrUndefined()) {
+ throw new IllegalArgumentException("moveTaskToStack: Attempt to move task "
+ + taskId + " to stack " + stackId);
+ }
+ if (stack.inSplitScreenPrimaryWindowingMode()) {
+ mAm.mWindowManager.setDockedStackCreateState(
+ SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, null /* initialBounds */);
+ }
+ task.reparent(stack, toTop, REPARENT_KEEP_STACK_AT_FRONT, ANIMATE, !DEFER_RESUME,
+ "moveTaskToStack");
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ @Override
+ public void resizeStack(int stackId, Rect destBounds, boolean allowResizeInDockedMode,
+ boolean preserveWindows, boolean animate, int animationDuration) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "resizeStack()");
+
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ if (animate) {
+ final PinnedActivityStack stack = mStackSupervisor.getStack(stackId);
+ if (stack == null) {
+ Slog.w(TAG, "resizeStack: stackId " + stackId + " not found.");
+ return;
+ }
+ if (stack.getWindowingMode() != WINDOWING_MODE_PINNED) {
+ throw new IllegalArgumentException("Stack: " + stackId
+ + " doesn't support animated resize.");
+ }
+ stack.animateResizePinnedStack(null /* sourceHintBounds */, destBounds,
+ animationDuration, false /* fromFullscreen */);
+ } else {
+ final ActivityStack stack = mStackSupervisor.getStack(stackId);
+ if (stack == null) {
+ Slog.w(TAG, "resizeStack: stackId " + stackId + " not found.");
+ return;
+ }
+ mStackSupervisor.resizeStackLocked(stack, destBounds,
+ null /* tempTaskBounds */, null /* tempTaskInsetBounds */,
+ preserveWindows, allowResizeInDockedMode, !DEFER_RESUME);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ /**
+ * Moves the specified task to the primary-split-screen stack.
+ *
+ * @param taskId Id of task to move.
+ * @param createMode The mode the primary split screen stack should be created in if it doesn't
+ * exist already. See
+ * {@link android.app.ActivityTaskManager#SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT}
+ * and
+ * {@link android.app.ActivityTaskManager#SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT}
+ * @param toTop If the task and stack should be moved to the top.
+ * @param animate Whether we should play an animation for the moving the task.
+ * @param initialBounds If the primary stack gets created, it will use these bounds for the
+ * stack. Pass {@code null} to use default bounds.
+ * @param showRecents If the recents activity should be shown on the other side of the task
+ * going into split-screen mode.
+ */
+ @Override
+ public boolean setTaskWindowingModeSplitScreenPrimary(int taskId, int createMode,
+ boolean toTop, boolean animate, Rect initialBounds, boolean showRecents) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
+ "setTaskWindowingModeSplitScreenPrimary()");
+ synchronized (mGlobalLock) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
+ if (task == null) {
+ Slog.w(TAG, "setTaskWindowingModeSplitScreenPrimary: No task for id=" + taskId);
+ return false;
+ }
+ if (DEBUG_STACK) Slog.d(TAG_STACK,
+ "setTaskWindowingModeSplitScreenPrimary: moving task=" + taskId
+ + " to createMode=" + createMode + " toTop=" + toTop);
+ if (!task.isActivityTypeStandardOrUndefined()) {
+ throw new IllegalArgumentException("setTaskWindowingMode: Attempt to move"
+ + " non-standard task " + taskId + " to split-screen windowing mode");
+ }
+
+ mAm.mWindowManager.setDockedStackCreateState(createMode, initialBounds);
+ final int windowingMode = task.getWindowingMode();
+ final ActivityStack stack = task.getStack();
+ if (toTop) {
+ stack.moveToFront("setTaskWindowingModeSplitScreenPrimary", task);
+ }
+ stack.setWindowingMode(WINDOWING_MODE_SPLIT_SCREEN_PRIMARY, animate, showRecents,
+ false /* enteringSplitScreenMode */, false /* deferEnsuringVisibility */);
+ return windowingMode != task.getWindowingMode();
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ /**
+ * Removes stacks in the input windowing modes from the system if they are of activity type
+ * ACTIVITY_TYPE_STANDARD or ACTIVITY_TYPE_UNDEFINED
+ */
+ @Override
+ public void removeStacksInWindowingModes(int[] windowingModes) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
+ "removeStacksInWindowingModes()");
+
+ synchronized (mGlobalLock) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mStackSupervisor.removeStacksInWindowingModes(windowingModes);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ @Override
+ public void removeStacksWithActivityTypes(int[] activityTypes) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
+ "removeStacksWithActivityTypes()");
+
+ synchronized (mGlobalLock) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mStackSupervisor.removeStacksWithActivityTypes(activityTypes);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ @Override
+ public ParceledListSlice<ActivityManager.RecentTaskInfo> getRecentTasks(int maxNum, int flags,
+ int userId) {
+ final int callingUid = Binder.getCallingUid();
+ userId = mAm.mUserController.handleIncomingUser(Binder.getCallingPid(), callingUid, userId,
+ false, ALLOW_FULL_ONLY, "getRecentTasks", null);
+ final boolean allowed = mAm.isGetTasksAllowed("getRecentTasks", Binder.getCallingPid(),
+ callingUid);
+ final boolean detailed = mAm.checkCallingPermission(
+ android.Manifest.permission.GET_DETAILED_TASKS)
+ == PackageManager.PERMISSION_GRANTED;
+
+ synchronized (mGlobalLock) {
+ return mAm.getRecentTasks().getRecentTasks(maxNum, flags, allowed, detailed, userId,
+ callingUid);
+ }
+ }
+
+ @Override
+ public List<ActivityManager.StackInfo> getAllStackInfos() {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "getAllStackInfos()");
+ long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ return mStackSupervisor.getAllStackInfosLocked();
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public ActivityManager.StackInfo getStackInfo(int windowingMode, int activityType) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "getStackInfo()");
+ long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ return mStackSupervisor.getStackInfo(windowingMode, activityType);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void cancelRecentsAnimation(boolean restoreHomeStackPosition) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "cancelRecentsAnimation()");
+ final long callingUid = Binder.getCallingUid();
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ // Cancel the recents animation synchronously (do not hold the WM lock)
+ mAm.mWindowManager.cancelRecentsAnimationSynchronously(restoreHomeStackPosition
+ ? REORDER_MOVE_TO_ORIGINAL_POSITION
+ : REORDER_KEEP_IN_PLACE, "cancelRecentsAnimation/uid=" + callingUid);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
+ public void startLockTaskModeByToken(IBinder token) {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.forTokenLocked(token);
+ if (r == null) {
+ return;
+ }
+ startLockTaskModeLocked(r.getTask(), false /* isSystemCaller */);
+ }
+ }
+
+ @Override
+ public void startSystemLockTaskMode(int taskId) throws RemoteException {
+ mAm.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "startSystemLockTaskMode");
+ // This makes inner call to look as if it was initiated by system.
+ long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
+
+ // When starting lock task mode the stack must be in front and focused
+ task.getStack().moveToFront("startSystemLockTaskMode");
+ startLockTaskModeLocked(task, true /* isSystemCaller */);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void stopLockTaskModeByToken(IBinder token) {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.forTokenLocked(token);
+ if (r == null) {
+ return;
+ }
+ stopLockTaskModeInternal(r.getTask(), false /* isSystemCaller */);
+ }
+ }
+
+ /**
+ * This API should be called by SystemUI only when user perform certain action to dismiss
+ * lock task mode. We should only dismiss pinned lock task mode in this case.
+ */
+ @Override
+ public void stopSystemLockTaskMode() throws RemoteException {
+ mAm.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "stopSystemLockTaskMode");
+ stopLockTaskModeInternal(null, true /* isSystemCaller */);
+ }
+
+ private void startLockTaskModeLocked(@Nullable TaskRecord task, boolean isSystemCaller) {
+ if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "startLockTaskModeLocked: " + task);
+ if (task == null || task.mLockTaskAuth == LOCK_TASK_AUTH_DONT_LOCK) {
+ return;
+ }
+
+ final ActivityStack stack = mStackSupervisor.getFocusedStack();
+ if (stack == null || task != stack.topTask()) {
+ throw new IllegalArgumentException("Invalid task, not in foreground");
+ }
+
+ // {@code isSystemCaller} is used to distinguish whether this request is initiated by the
+ // system or a specific app.
+ // * System-initiated requests will only start the pinned mode (screen pinning)
+ // * App-initiated requests
+ // - will put the device in fully locked mode (LockTask), if the app is whitelisted
+ // - will start the pinned mode, otherwise
+ final int callingUid = Binder.getCallingUid();
+ long ident = Binder.clearCallingIdentity();
+ try {
+ // When a task is locked, dismiss the pinned stack if it exists
+ mStackSupervisor.removeStacksInWindowingModes(WINDOWING_MODE_PINNED);
+
+ mAm.getLockTaskController().startLockTaskMode(task, isSystemCaller, callingUid);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ private void stopLockTaskModeInternal(@Nullable TaskRecord task, boolean isSystemCaller) {
+ final int callingUid = Binder.getCallingUid();
+ long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ mAm.getLockTaskController().stopLockTaskMode(task, isSystemCaller, callingUid);
+ }
+ // Launch in-call UI if a call is ongoing. This is necessary to allow stopping the lock
+ // task and jumping straight into a call in the case of emergency call back.
+ TelecomManager tm = (TelecomManager) mContext.getSystemService(Context.TELECOM_SERVICE);
+ if (tm != null) {
+ tm.showInCallScreen(false);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public boolean isInLockTaskMode() {
+ return getLockTaskModeState() != LOCK_TASK_MODE_NONE;
+ }
+
+ @Override
+ public int getLockTaskModeState() {
+ synchronized (mGlobalLock) {
+ return mAm.getLockTaskController().getLockTaskModeState();
+ }
+ }
+
+ @Override
+ public void setTaskDescription(IBinder token, ActivityManager.TaskDescription td) {
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r != null) {
+ r.setTaskDescription(td);
+ final TaskRecord task = r.getTask();
+ task.updateTaskDescription();
+ mAm.mTaskChangeNotificationController.notifyTaskDescriptionChanged(task.taskId, td);
+ }
+ }
+ }
+
+ @Override
+ public Bundle getActivityOptions(IBinder token) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r != null) {
+ final ActivityOptions activityOptions = r.takeOptionsLocked();
+ return activityOptions == null ? null : activityOptions.toBundle();
+ }
+ return null;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
+ public List<IBinder> getAppTasks(String callingPackage) {
+ int callingUid = Binder.getCallingUid();
+ long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ return mAm.getRecentTasks().getAppTasksList(callingUid, callingPackage);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void finishVoiceTask(IVoiceInteractionSession session) {
+ synchronized (mGlobalLock) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ // TODO: VI Consider treating local voice interactions and voice tasks
+ // differently here
+ mStackSupervisor.finishVoiceTask(session);
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ }
+
+ @Override
+ public boolean isTopOfTask(IBinder token) {
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ throw new IllegalArgumentException();
+ }
+ return r.getTask().getTopActivity() == r;
+ }
+ }
+
+ @Override
+ public void notifyLaunchTaskBehindComplete(IBinder token) {
+ mStackSupervisor.scheduleLaunchTaskBehindComplete(token);
+ }
+
+ @Override
+ public void notifyEnterAnimationComplete(IBinder token) {
+ mAm.mHandler.sendMessage(mAm.mHandler.obtainMessage(ENTER_ANIMATION_COMPLETE_MSG, token));
+ }
+
+ /** Called from an app when assist data is ready. */
+ @Override
+ public void reportAssistContextExtras(IBinder token, Bundle extras, AssistStructure structure,
+ AssistContent content, Uri referrer) {
+ PendingAssistExtras pae = (PendingAssistExtras)token;
+ synchronized (pae) {
+ pae.result = extras;
+ pae.structure = structure;
+ pae.content = content;
+ if (referrer != null) {
+ pae.extras.putParcelable(Intent.EXTRA_REFERRER, referrer);
+ }
+ if (structure != null) {
+ structure.setHomeActivity(pae.isHome);
+ }
+ pae.haveResult = true;
+ pae.notifyAll();
+ if (pae.intent == null && pae.receiver == null) {
+ // Caller is just waiting for the result.
+ return;
+ }
+ }
+ // We are now ready to launch the assist activity.
+ IAssistDataReceiver sendReceiver = null;
+ Bundle sendBundle = null;
+ synchronized (mGlobalLock) {
+ buildAssistBundleLocked(pae, extras);
+ boolean exists = mPendingAssistExtras.remove(pae);
+ mAm.mUiHandler.removeCallbacks(pae);
+ if (!exists) {
+ // Timed out.
+ return;
+ }
+
+ if ((sendReceiver=pae.receiver) != null) {
+ // Caller wants result sent back to them.
+ sendBundle = new Bundle();
+ sendBundle.putBundle(ASSIST_KEY_DATA, pae.extras);
+ sendBundle.putParcelable(ASSIST_KEY_STRUCTURE, pae.structure);
+ sendBundle.putParcelable(ASSIST_KEY_CONTENT, pae.content);
+ sendBundle.putBundle(ASSIST_KEY_RECEIVER_EXTRAS, pae.receiverExtras);
+ }
+ }
+ if (sendReceiver != null) {
+ try {
+ sendReceiver.onHandleAssistData(sendBundle);
+ } catch (RemoteException e) {
+ }
+ return;
+ }
+
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ if (TextUtils.equals(pae.intent.getAction(),
+ android.service.voice.VoiceInteractionService.SERVICE_INTERFACE)) {
+ pae.intent.putExtras(pae.extras);
+ mContext.startServiceAsUser(pae.intent, new UserHandle(pae.userHandle));
+ } else {
+ pae.intent.replaceExtras(pae.extras);
+ pae.intent.setFlags(FLAG_ACTIVITY_NEW_TASK
+ | Intent.FLAG_ACTIVITY_SINGLE_TOP
+ | Intent.FLAG_ACTIVITY_CLEAR_TOP);
+ mAm.closeSystemDialogs("assist");
+
+ try {
+ mContext.startActivityAsUser(pae.intent, new UserHandle(pae.userHandle));
+ } catch (ActivityNotFoundException e) {
+ Slog.w(TAG, "No activity to handle assist action.", e);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public int addAppTask(IBinder activityToken, Intent intent,
+ ActivityManager.TaskDescription description, Bitmap thumbnail) throws RemoteException {
+ final int callingUid = Binder.getCallingUid();
+ final long callingIdent = Binder.clearCallingIdentity();
+
+ try {
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(activityToken);
+ if (r == null) {
+ throw new IllegalArgumentException("Activity does not exist; token="
+ + activityToken);
+ }
+ ComponentName comp = intent.getComponent();
+ if (comp == null) {
+ throw new IllegalArgumentException("Intent " + intent
+ + " must specify explicit component");
+ }
+ if (thumbnail.getWidth() != mAm.mThumbnailWidth
+ || thumbnail.getHeight() != mAm.mThumbnailHeight) {
+ throw new IllegalArgumentException("Bad thumbnail size: got "
+ + thumbnail.getWidth() + "x" + thumbnail.getHeight() + ", require "
+ + mAm.mThumbnailWidth + "x" + mAm.mThumbnailHeight);
+ }
+ if (intent.getSelector() != null) {
+ intent.setSelector(null);
+ }
+ if (intent.getSourceBounds() != null) {
+ intent.setSourceBounds(null);
+ }
+ if ((intent.getFlags()&Intent.FLAG_ACTIVITY_NEW_DOCUMENT) != 0) {
+ if ((intent.getFlags()&Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS) == 0) {
+ // The caller has added this as an auto-remove task... that makes no
+ // sense, so turn off auto-remove.
+ intent.addFlags(Intent.FLAG_ACTIVITY_RETAIN_IN_RECENTS);
+ }
+ }
+ final ActivityInfo ainfo = AppGlobals.getPackageManager().getActivityInfo(comp,
+ STOCK_PM_FLAGS, UserHandle.getUserId(callingUid));
+ if (ainfo.applicationInfo.uid != callingUid) {
+ throw new SecurityException(
+ "Can't add task for another application: target uid="
+ + ainfo.applicationInfo.uid + ", calling uid=" + callingUid);
+ }
+
+ final ActivityStack stack = r.getStack();
+ final TaskRecord task = stack.createTaskRecord(
+ mStackSupervisor.getNextTaskIdForUserLocked(r.userId), ainfo, intent,
+ null /* voiceSession */, null /* voiceInteractor */, !ON_TOP);
+ if (!mAm.getRecentTasks().addToBottom(task)) {
+ // The app has too many tasks already and we can't add any more
+ stack.removeTask(task, "addAppTask", REMOVE_TASK_MODE_DESTROYING);
+ return INVALID_TASK_ID;
+ }
+ task.lastTaskDescription.copyFrom(description);
+
+ // TODO: Send the thumbnail to WM to store it.
+
+ return task.taskId;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(callingIdent);
+ }
+ }
+
+ @Override
+ public Point getAppTaskThumbnailSize() {
+ synchronized (mGlobalLock) {
+ return new Point(mAm.mThumbnailWidth, mAm.mThumbnailHeight);
+ }
+ }
+
+ @Override
+ public void setTaskResizeable(int taskId, int resizeableMode) {
+ synchronized (mGlobalLock) {
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(
+ taskId, MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
+ if (task == null) {
+ Slog.w(TAG, "setTaskResizeable: taskId=" + taskId + " not found");
+ return;
+ }
+ task.setResizeMode(resizeableMode);
+ }
+ }
+
+ @Override
+ public void resizeTask(int taskId, Rect bounds, int resizeMode) {
+ mAm.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "resizeTask()");
+ long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
+ if (task == null) {
+ Slog.w(TAG, "resizeTask: taskId=" + taskId + " not found");
+ return;
+ }
+ // Place the task in the right stack if it isn't there already based on
+ // the requested bounds.
+ // The stack transition logic is:
+ // - a null bounds on a freeform task moves that task to fullscreen
+ // - a non-null bounds on a non-freeform (fullscreen OR docked) task moves
+ // that task to freeform
+ // - otherwise the task is not moved
+ ActivityStack stack = task.getStack();
+ if (!task.getWindowConfiguration().canResizeTask()) {
+ throw new IllegalArgumentException("resizeTask not allowed on task=" + task);
+ }
+ if (bounds == null && stack.getWindowingMode() == WINDOWING_MODE_FREEFORM) {
+ stack = stack.getDisplay().getOrCreateStack(
+ WINDOWING_MODE_FULLSCREEN, stack.getActivityType(), ON_TOP);
+ } else if (bounds != null && stack.getWindowingMode() != WINDOWING_MODE_FREEFORM) {
+ stack = stack.getDisplay().getOrCreateStack(
+ WINDOWING_MODE_FREEFORM, stack.getActivityType(), ON_TOP);
+ }
+
+ // Reparent the task to the right stack if necessary
+ boolean preserveWindow = (resizeMode & RESIZE_MODE_PRESERVE_WINDOW) != 0;
+ if (stack != task.getStack()) {
+ // Defer resume until the task is resized below
+ task.reparent(stack, ON_TOP, REPARENT_KEEP_STACK_AT_FRONT, ANIMATE,
+ DEFER_RESUME, "resizeTask");
+ preserveWindow = false;
+ }
+
+ // After reparenting (which only resizes the task to the stack bounds), resize the
+ // task to the actual bounds provided
+ task.resize(bounds, resizeMode, preserveWindow, !DEFER_RESUME);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public boolean releaseActivityInstance(IBinder token) {
+ synchronized (mGlobalLock) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return false;
+ }
+ return r.getStack().safelyDestroyActivityLocked(r, "app-req");
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ @Override
+ public void releaseSomeActivities(IApplicationThread appInt) {
+ synchronized (mGlobalLock) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ ProcessRecord app = mAm.getRecordForAppLocked(appInt);
+ mStackSupervisor.releaseSomeActivitiesLocked(app, "low-mem");
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ @Override
+ public void setLockScreenShown(boolean keyguardShowing, boolean aodShowing,
+ int secondaryDisplayShowing) {
+ if (mAm.checkCallingPermission(android.Manifest.permission.DEVICE_POWER)
+ != PackageManager.PERMISSION_GRANTED) {
+ throw new SecurityException("Requires permission "
+ + android.Manifest.permission.DEVICE_POWER);
+ }
+
+ synchronized (mGlobalLock) {
+ long ident = Binder.clearCallingIdentity();
+ if (mKeyguardShown != keyguardShowing) {
+ mKeyguardShown = keyguardShowing;
+ reportCurKeyguardUsageEventLocked(keyguardShowing);
+ }
+ try {
+ mAm.mKeyguardController.setKeyguardShown(keyguardShowing, aodShowing,
+ secondaryDisplayShowing);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ mAm.mHandler.obtainMessage(DISPATCH_SCREEN_KEYGUARD_MSG, keyguardShowing ? 1 : 0, 0)
+ .sendToTarget();
+ }
+
+ @Override
+ public Bitmap getTaskDescriptionIcon(String filePath, int userId) {
+ userId = mAm.mUserController.handleIncomingUser(Binder.getCallingPid(),
+ Binder.getCallingUid(), userId, false, ALLOW_FULL_ONLY, "getTaskDescriptionIcon", null);
+
+ final File passedIconFile = new File(filePath);
+ final File legitIconFile = new File(TaskPersister.getUserImagesDir(userId),
+ passedIconFile.getName());
+ if (!legitIconFile.getPath().equals(filePath)
+ || !filePath.contains(ActivityRecord.ACTIVITY_ICON_SUFFIX)) {
+ throw new IllegalArgumentException("Bad file path: " + filePath
+ + " passed for userId " + userId);
+ }
+ return mAm.getRecentTasks().getTaskDescriptionIcon(filePath);
+ }
+
+ @Override
+ public void startInPlaceAnimationOnFrontMostApplication(Bundle opts)
+ throws RemoteException {
+ final SafeActivityOptions safeOptions = SafeActivityOptions.fromBundle(opts);
+ final ActivityOptions activityOptions = safeOptions != null
+ ? safeOptions.getOptions(mStackSupervisor)
+ : null;
+ if (activityOptions == null
+ || activityOptions.getAnimationType() != ActivityOptions.ANIM_CUSTOM_IN_PLACE
+ || activityOptions.getCustomInPlaceResId() == 0) {
+ throw new IllegalArgumentException("Expected in-place ActivityOption " +
+ "with valid animation");
+ }
+ mAm.mWindowManager.prepareAppTransition(TRANSIT_TASK_IN_PLACE, false);
+ mAm.mWindowManager.overridePendingAppTransitionInPlace(activityOptions.getPackageName(),
+ activityOptions.getCustomInPlaceResId());
+ mAm.mWindowManager.executeAppTransition();
+ }
+
+ @Override
+ public void removeStack(int stackId) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "removeStack()");
+ synchronized (mGlobalLock) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final ActivityStack stack = mStackSupervisor.getStack(stackId);
+ if (stack == null) {
+ Slog.w(TAG, "removeStack: No stack with id=" + stackId);
+ return;
+ }
+ if (!stack.isActivityTypeStandardOrUndefined()) {
+ throw new IllegalArgumentException(
+ "Removing non-standard stack is not allowed.");
+ }
+ mStackSupervisor.removeStack(stack);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ @Override
+ public void moveStackToDisplay(int stackId, int displayId) {
+ mAm.enforceCallingPermission(INTERNAL_SYSTEM_WINDOW, "moveStackToDisplay()");
+
+ synchronized (mGlobalLock) {
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ if (DEBUG_STACK) Slog.d(TAG_STACK, "moveStackToDisplay: moving stackId=" + stackId
+ + " to displayId=" + displayId);
+ mStackSupervisor.moveStackToDisplayLocked(stackId, displayId, ON_TOP);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ @Override
+ public int createStackOnDisplay(int displayId) {
+ mAm.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "createStackOnDisplay()");
+ synchronized (mGlobalLock) {
+ final ActivityDisplay display =
+ mStackSupervisor.getActivityDisplayOrCreateLocked(displayId);
+ if (display == null) {
+ return INVALID_STACK_ID;
+ }
+ // TODO(multi-display): Have the caller pass in the windowing mode and activity type.
+ final ActivityStack stack = display.createStack(
+ WINDOWING_MODE_FULLSCREEN_OR_SPLIT_SCREEN_SECONDARY, ACTIVITY_TYPE_STANDARD,
+ ON_TOP);
+ return (stack != null) ? stack.mStackId : INVALID_STACK_ID;
+ }
+ }
+
+ @Override
+ public void exitFreeformMode(IBinder token) {
+ synchronized (mGlobalLock) {
+ long ident = Binder.clearCallingIdentity();
+ try {
+ final ActivityRecord r = ActivityRecord.forTokenLocked(token);
+ if (r == null) {
+ throw new IllegalArgumentException(
+ "exitFreeformMode: No activity record matching token=" + token);
+ }
+
+ final ActivityStack stack = r.getStack();
+ if (stack == null || !stack.inFreeformWindowingMode()) {
+ throw new IllegalStateException(
+ "exitFreeformMode: You can only go fullscreen from freeform.");
+ }
+
+ stack.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ /** Sets the task stack listener that gets callbacks when a task stack changes. */
+ @Override
+ public void registerTaskStackListener(ITaskStackListener listener) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
+ "registerTaskStackListener()");
+ mAm.mTaskChangeNotificationController.registerTaskStackListener(listener);
+ }
+
+ /** Unregister a task stack listener so that it stops receiving callbacks. */
+ @Override
+ public void unregisterTaskStackListener(ITaskStackListener listener) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
+ "unregisterTaskStackListener()");
+ mAm.mTaskChangeNotificationController.unregisterTaskStackListener(listener);
+ }
+
+ private void reportCurKeyguardUsageEventLocked(boolean keyguardShowing) {
+ mAm.reportGlobalUsageEventLocked(keyguardShowing
+ ? UsageEvents.Event.KEYGUARD_SHOWN
+ : UsageEvents.Event.KEYGUARD_HIDDEN);
+ }
+
+ @Override
+ public boolean requestAssistContextExtras(int requestType, IAssistDataReceiver receiver,
+ Bundle receiverExtras, IBinder activityToken, boolean focused, boolean newSessionId) {
+ return enqueueAssistContext(requestType, null, null, receiver, receiverExtras,
+ activityToken, focused, newSessionId, UserHandle.getCallingUserId(), null,
+ PENDING_ASSIST_EXTRAS_LONG_TIMEOUT, 0) != null;
+ }
+
+ @Override
+ public boolean requestAutofillData(IAssistDataReceiver receiver, Bundle receiverExtras,
+ IBinder activityToken, int flags) {
+ return enqueueAssistContext(ActivityManager.ASSIST_CONTEXT_AUTOFILL, null, null,
+ receiver, receiverExtras, activityToken, true, true, UserHandle.getCallingUserId(),
+ null, PENDING_AUTOFILL_ASSIST_STRUCTURE_TIMEOUT, flags) != null;
+ }
+
+ @Override
+ public boolean launchAssistIntent(Intent intent, int requestType, String hint, int userHandle,
+ Bundle args) {
+ return enqueueAssistContext(requestType, intent, hint, null, null, null,
+ true /* focused */, true /* newSessionId */, userHandle, args,
+ PENDING_ASSIST_EXTRAS_TIMEOUT, 0) != null;
+ }
+
+ @Override
+ public Bundle getAssistContextExtras(int requestType) {
+ PendingAssistExtras pae = enqueueAssistContext(requestType, null, null, null,
+ null, null, true /* focused */, true /* newSessionId */,
+ UserHandle.getCallingUserId(), null, PENDING_ASSIST_EXTRAS_TIMEOUT, 0);
+ if (pae == null) {
+ return null;
+ }
+ synchronized (pae) {
+ while (!pae.haveResult) {
+ try {
+ pae.wait();
+ } catch (InterruptedException e) {
+ }
+ }
+ }
+ synchronized (mGlobalLock) {
+ buildAssistBundleLocked(pae, pae.result);
+ mPendingAssistExtras.remove(pae);
+ mAm.mUiHandler.removeCallbacks(pae);
+ }
+ return pae.extras;
+ }
+
+ private PendingAssistExtras enqueueAssistContext(int requestType, Intent intent, String hint,
+ IAssistDataReceiver receiver, Bundle receiverExtras, IBinder activityToken,
+ boolean focused, boolean newSessionId, int userHandle, Bundle args, long timeout,
+ int flags) {
+ mAm.enforceCallingPermission(android.Manifest.permission.GET_TOP_ACTIVITY_INFO,
+ "enqueueAssistContext()");
+
+ synchronized (mGlobalLock) {
+ ActivityRecord activity = mAm.getFocusedStack().getTopActivity();
+ if (activity == null) {
+ Slog.w(TAG, "getAssistContextExtras failed: no top activity");
+ return null;
+ }
+ if (activity.app == null || activity.app.thread == null) {
+ Slog.w(TAG, "getAssistContextExtras failed: no process for " + activity);
+ return null;
+ }
+ if (focused) {
+ if (activityToken != null) {
+ ActivityRecord caller = ActivityRecord.forTokenLocked(activityToken);
+ if (activity != caller) {
+ Slog.w(TAG, "enqueueAssistContext failed: caller " + caller
+ + " is not current top " + activity);
+ return null;
+ }
+ }
+ } else {
+ activity = ActivityRecord.forTokenLocked(activityToken);
+ if (activity == null) {
+ Slog.w(TAG, "enqueueAssistContext failed: activity for token=" + activityToken
+ + " couldn't be found");
+ return null;
+ }
+ if (activity.app == null || activity.app.thread == null) {
+ Slog.w(TAG, "enqueueAssistContext failed: no process for " + activity);
+ return null;
+ }
+ }
+
+ PendingAssistExtras pae;
+ Bundle extras = new Bundle();
+ if (args != null) {
+ extras.putAll(args);
+ }
+ extras.putString(Intent.EXTRA_ASSIST_PACKAGE, activity.packageName);
+ extras.putInt(Intent.EXTRA_ASSIST_UID, activity.app.uid);
+
+ pae = new PendingAssistExtras(activity, extras, intent, hint, receiver, receiverExtras,
+ userHandle);
+ pae.isHome = activity.isActivityTypeHome();
+
+ // Increment the sessionId if necessary
+ if (newSessionId) {
+ mViSessionId++;
+ }
+ try {
+ activity.app.thread.requestAssistContextExtras(activity.appToken, pae, requestType,
+ mViSessionId, flags);
+ mPendingAssistExtras.add(pae);
+ mAm.mUiHandler.postDelayed(pae, timeout);
+ } catch (RemoteException e) {
+ Slog.w(TAG, "getAssistContextExtras failed: crash calling " + activity);
+ return null;
+ }
+ return pae;
+ }
+ }
+
+ private void buildAssistBundleLocked(PendingAssistExtras pae, Bundle result) {
+ if (result != null) {
+ pae.extras.putBundle(Intent.EXTRA_ASSIST_CONTEXT, result);
+ }
+ if (pae.hint != null) {
+ pae.extras.putBoolean(pae.hint, true);
+ }
+ }
+
+ private void pendingAssistExtrasTimedOut(PendingAssistExtras pae) {
+ IAssistDataReceiver receiver;
+ synchronized (mGlobalLock) {
+ mPendingAssistExtras.remove(pae);
+ receiver = pae.receiver;
+ }
+ if (receiver != null) {
+ // Caller wants result sent back to them.
+ Bundle sendBundle = new Bundle();
+ // At least return the receiver extras
+ sendBundle.putBundle(ASSIST_KEY_RECEIVER_EXTRAS, pae.receiverExtras);
+ try {
+ pae.receiver.onHandleAssistData(sendBundle);
+ } catch (RemoteException e) {
+ }
+ }
+ }
+
+ public class PendingAssistExtras extends Binder implements Runnable {
+ public final ActivityRecord activity;
+ public boolean isHome;
+ public final Bundle extras;
+ public final Intent intent;
+ public final String hint;
+ public final IAssistDataReceiver receiver;
+ public final int userHandle;
+ public boolean haveResult = false;
+ public Bundle result = null;
+ public AssistStructure structure = null;
+ public AssistContent content = null;
+ public Bundle receiverExtras;
+
+ public PendingAssistExtras(ActivityRecord _activity, Bundle _extras, Intent _intent,
+ String _hint, IAssistDataReceiver _receiver, Bundle _receiverExtras,
+ int _userHandle) {
+ activity = _activity;
+ extras = _extras;
+ intent = _intent;
+ hint = _hint;
+ receiver = _receiver;
+ receiverExtras = _receiverExtras;
+ userHandle = _userHandle;
+ }
+
+ @Override
+ public void run() {
+ Slog.w(TAG, "getAssistContextExtras failed: timeout retrieving from " + activity);
+ synchronized (this) {
+ haveResult = true;
+ notifyAll();
+ }
+ pendingAssistExtrasTimedOut(this);
+ }
+ }
+
+ @Override
+ public boolean isAssistDataAllowedOnCurrentActivity() {
+ int userId;
+ synchronized (mGlobalLock) {
+ final ActivityStack focusedStack = mAm.getFocusedStack();
+ if (focusedStack == null || focusedStack.isActivityTypeAssistant()) {
+ return false;
+ }
+
+ final ActivityRecord activity = focusedStack.getTopActivity();
+ if (activity == null) {
+ return false;
+ }
+ userId = activity.userId;
+ }
+ return !DevicePolicyCache.getInstance().getScreenCaptureDisabled(userId);
+ }
+
+ @Override
+ public boolean showAssistFromActivity(IBinder token, Bundle args) {
+ long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ ActivityRecord caller = ActivityRecord.forTokenLocked(token);
+ ActivityRecord top = mAm.getFocusedStack().getTopActivity();
+ if (top != caller) {
+ Slog.w(TAG, "showAssistFromActivity failed: caller " + caller
+ + " is not current top " + top);
+ return false;
+ }
+ if (!top.nowVisible) {
+ Slog.w(TAG, "showAssistFromActivity failed: caller " + caller
+ + " is not visible");
+ return false;
+ }
+ }
+ return mAssistUtils.showSessionForActiveService(args, SHOW_SOURCE_APPLICATION, null,
+ token);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public boolean isRootVoiceInteraction(IBinder token) {
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return false;
+ }
+ return r.rootVoiceInteraction;
+ }
+ }
+
+ @Override
+ public ComponentName getActivityClassForToken(IBinder token) {
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return null;
+ }
+ return r.intent.getComponent();
+ }
+ }
+
+ @Override
+ public String getPackageForToken(IBinder token) {
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return null;
+ }
+ return r.packageName;
+ }
+ }
+
+ @Override
+ public void showLockTaskEscapeMessage(IBinder token) {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.forTokenLocked(token);
+ if (r == null) {
+ return;
+ }
+ mAm.getLockTaskController().showLockTaskToast();
+ }
+ }
+
+ @Override
+ public void keyguardGoingAway(int flags) {
+ mAm.enforceNotIsolatedCaller("keyguardGoingAway");
+ final long token = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ mAm.mKeyguardController.keyguardGoingAway(flags);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+ }
+
+ /**
+ * Try to place task to provided position. The final position might be different depending on
+ * current user and stacks state. The task will be moved to target stack if it's currently in
+ * different stack.
+ */
+ @Override
+ public void positionTaskInStack(int taskId, int stackId, int position) {
+ mAm.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "positionTaskInStack()");
+ synchronized (mGlobalLock) {
+ long ident = Binder.clearCallingIdentity();
+ try {
+ if (DEBUG_STACK) Slog.d(TAG_STACK, "positionTaskInStack: positioning task="
+ + taskId + " in stackId=" + stackId + " at position=" + position);
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId);
+ if (task == null) {
+ throw new IllegalArgumentException("positionTaskInStack: no task for id="
+ + taskId);
+ }
+
+ final ActivityStack stack = mStackSupervisor.getStack(stackId);
+
+ if (stack == null) {
+ throw new IllegalArgumentException("positionTaskInStack: no stack for id="
+ + stackId);
+ }
+ if (!stack.isActivityTypeStandardOrUndefined()) {
+ throw new IllegalArgumentException("positionTaskInStack: Attempt to change"
+ + " the position of task " + taskId + " in/to non-standard stack");
+ }
+
+ // TODO: Have the callers of this API call a separate reparent method if that is
+ // what they intended to do vs. having this method also do reparenting.
+ if (task.getStack() == stack) {
+ // Change position in current stack.
+ stack.positionChildAt(task, position);
+ } else {
+ // Reparent to new stack.
+ task.reparent(stack, position, REPARENT_LEAVE_STACK_IN_PLACE, !ANIMATE,
+ !DEFER_RESUME, "positionTaskInStack");
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ @Override
+ public void reportSizeConfigurations(IBinder token, int[] horizontalSizeConfiguration,
+ int[] verticalSizeConfigurations, int[] smallestSizeConfigurations) {
+ if (DEBUG_CONFIGURATION) Slog.v(TAG, "Report configuration: " + token + " "
+ + horizontalSizeConfiguration + " " + verticalSizeConfigurations);
+ synchronized (mGlobalLock) {
+ ActivityRecord record = ActivityRecord.isInStackLocked(token);
+ if (record == null) {
+ throw new IllegalArgumentException("reportSizeConfigurations: ActivityRecord not "
+ + "found for: " + token);
+ }
+ record.setSizeConfigurations(horizontalSizeConfiguration,
+ verticalSizeConfigurations, smallestSizeConfigurations);
+ }
+ }
+
+ /**
+ * Dismisses split-screen multi-window mode.
+ * @param toTop If true the current primary split-screen stack will be placed or left on top.
+ */
+ @Override
+ public void dismissSplitScreenMode(boolean toTop) {
+ mAm.enforceCallerIsRecentsOrHasPermission(
+ MANAGE_ACTIVITY_STACKS, "dismissSplitScreenMode()");
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final ActivityStack stack =
+ mStackSupervisor.getDefaultDisplay().getSplitScreenPrimaryStack();
+ if (stack == null) {
+ Slog.w(TAG, "dismissSplitScreenMode: primary split-screen stack not found.");
+ return;
+ }
+
+ if (toTop) {
+ // Caller wants the current split-screen primary stack to be the top stack after
+ // it goes fullscreen, so move it to the front.
+ stack.moveToFront("dismissSplitScreenMode");
+ } else if (mStackSupervisor.isFocusedStack(stack)) {
+ // In this case the current split-screen primary stack shouldn't be the top
+ // stack after it goes fullscreen, but it current has focus, so we move the
+ // focus to the top-most split-screen secondary stack next to it.
+ final ActivityStack otherStack = stack.getDisplay().getTopStackInWindowingMode(
+ WINDOWING_MODE_SPLIT_SCREEN_SECONDARY);
+ if (otherStack != null) {
+ otherStack.moveToFront("dismissSplitScreenMode_other");
+ }
+ }
+
+ stack.setWindowingMode(WINDOWING_MODE_FULLSCREEN);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ /**
+ * Dismisses Pip
+ * @param animate True if the dismissal should be animated.
+ * @param animationDuration The duration of the resize animation in milliseconds or -1 if the
+ * default animation duration should be used.
+ */
+ @Override
+ public void dismissPip(boolean animate, int animationDuration) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "dismissPip()");
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final PinnedActivityStack stack =
+ mStackSupervisor.getDefaultDisplay().getPinnedStack();
+ if (stack == null) {
+ Slog.w(TAG, "dismissPip: pinned stack not found.");
+ return;
+ }
+ if (stack.getWindowingMode() != WINDOWING_MODE_PINNED) {
+ throw new IllegalArgumentException("Stack: " + stack
+ + " doesn't support animated resize.");
+ }
+ if (animate) {
+ stack.animateResizePinnedStack(null /* sourceHintBounds */,
+ null /* destBounds */, animationDuration, false /* fromFullscreen */);
+ } else {
+ mStackSupervisor.moveTasksToFullscreenStackLocked(stack, true /* onTop */);
+ }
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void suppressResizeConfigChanges(boolean suppress) throws RemoteException {
+ mAm.enforceCallingPermission(MANAGE_ACTIVITY_STACKS, "suppressResizeConfigChanges()");
+ synchronized (mGlobalLock) {
+ mSuppressResizeConfigChanges = suppress;
+ }
+ }
+
+ /**
+ * NOTE: For the pinned stack, this method is usually called after the bounds animation has
+ * animated the stack to the fullscreen, but can also be called if we are relaunching an
+ * activity and clearing the task at the same time.
+ */
+ @Override
+ // TODO: API should just be about changing windowing modes...
+ public void moveTasksToFullscreenStack(int fromStackId, boolean onTop) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
+ "moveTasksToFullscreenStack()");
+ synchronized (mGlobalLock) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ final ActivityStack stack = mStackSupervisor.getStack(fromStackId);
+ if (stack != null){
+ if (!stack.isActivityTypeStandardOrUndefined()) {
+ throw new IllegalArgumentException(
+ "You can't move tasks from non-standard stacks.");
+ }
+ mStackSupervisor.moveTasksToFullscreenStackLocked(stack, onTop);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ /**
+ * Moves the top activity in the input stackId to the pinned stack.
+ *
+ * @param stackId Id of stack to move the top activity to pinned stack.
+ * @param bounds Bounds to use for pinned stack.
+ *
+ * @return True if the top activity of the input stack was successfully moved to the pinned
+ * stack.
+ */
+ @Override
+ public boolean moveTopActivityToPinnedStack(int stackId, Rect bounds) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
+ "moveTopActivityToPinnedStack()");
+ synchronized (mGlobalLock) {
+ if (!mAm.mSupportsPictureInPicture) {
+ throw new IllegalStateException("moveTopActivityToPinnedStack:"
+ + "Device doesn't support picture-in-picture mode");
+ }
+
+ long ident = Binder.clearCallingIdentity();
+ try {
+ return mStackSupervisor.moveTopStackActivityToPinnedStackLocked(stackId, bounds);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+ }
+
+ @Override
+ public boolean isInMultiWindowMode(IBinder token) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return false;
+ }
+ // An activity is consider to be in multi-window mode if its task isn't fullscreen.
+ return r.inMultiWindowMode();
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
+ public boolean isInPictureInPictureMode(IBinder token) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ return isInPictureInPictureMode(ActivityRecord.forTokenLocked(token));
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ private boolean isInPictureInPictureMode(ActivityRecord r) {
+ if (r == null || r.getStack() == null || !r.inPinnedWindowingMode()
+ || r.getStack().isInStackLocked(r) == null) {
+ return false;
+ }
+
+ // If we are animating to fullscreen then we have already dispatched the PIP mode
+ // changed, so we should reflect that check here as well.
+ final PinnedActivityStack stack = r.getStack();
+ final PinnedStackWindowController windowController = stack.getWindowContainerController();
+ return !windowController.isAnimatingBoundsToFullscreen();
+ }
+
+ @Override
+ public boolean enterPictureInPictureMode(IBinder token, final PictureInPictureParams params) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ensureValidPictureInPictureActivityParamsLocked(
+ "enterPictureInPictureMode", token, params);
+
+ // If the activity is already in picture in picture mode, then just return early
+ if (isInPictureInPictureMode(r)) {
+ return true;
+ }
+
+ // Activity supports picture-in-picture, now check that we can enter PiP at this
+ // point, if it is
+ if (!r.checkEnterPictureInPictureState("enterPictureInPictureMode",
+ false /* beforeStopping */)) {
+ return false;
+ }
+
+ final Runnable enterPipRunnable = () -> {
+ // Only update the saved args from the args that are set
+ r.pictureInPictureArgs.copyOnlySet(params);
+ final float aspectRatio = r.pictureInPictureArgs.getAspectRatio();
+ final List<RemoteAction> actions = r.pictureInPictureArgs.getActions();
+ // Adjust the source bounds by the insets for the transition down
+ final Rect sourceBounds = new Rect(r.pictureInPictureArgs.getSourceRectHint());
+ mStackSupervisor.moveActivityToPinnedStackLocked(r, sourceBounds, aspectRatio,
+ "enterPictureInPictureMode");
+ final PinnedActivityStack stack = r.getStack();
+ stack.setPictureInPictureAspectRatio(aspectRatio);
+ stack.setPictureInPictureActions(actions);
+ MetricsLoggerWrapper.logPictureInPictureEnter(mContext, r.appInfo.uid,
+ r.shortComponentName, r.supportsEnterPipOnTaskSwitch);
+ logPictureInPictureArgs(params);
+ };
+
+ if (mAm.isKeyguardLocked()) {
+ // If the keyguard is showing or occluded, then try and dismiss it before
+ // entering picture-in-picture (this will prompt the user to authenticate if the
+ // device is currently locked).
+ dismissKeyguard(token, new KeyguardDismissCallback() {
+ @Override
+ public void onDismissSucceeded() throws RemoteException {
+ mAm.mHandler.post(enterPipRunnable);
+ }
+ }, null /* message */);
+ } else {
+ // Enter picture in picture immediately otherwise
+ enterPipRunnable.run();
+ }
+ return true;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
+ public void setPictureInPictureParams(IBinder token, final PictureInPictureParams params) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ensureValidPictureInPictureActivityParamsLocked(
+ "setPictureInPictureParams", token, params);
+
+ // Only update the saved args from the args that are set
+ r.pictureInPictureArgs.copyOnlySet(params);
+ if (r.inPinnedWindowingMode()) {
+ // If the activity is already in picture-in-picture, update the pinned stack now
+ // if it is not already expanding to fullscreen. Otherwise, the arguments will
+ // be used the next time the activity enters PiP
+ final PinnedActivityStack stack = r.getStack();
+ if (!stack.isAnimatingBoundsToFullscreen()) {
+ stack.setPictureInPictureAspectRatio(
+ r.pictureInPictureArgs.getAspectRatio());
+ stack.setPictureInPictureActions(r.pictureInPictureArgs.getActions());
+ }
+ }
+ logPictureInPictureArgs(params);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+
+ @Override
+ public int getMaxNumPictureInPictureActions(IBinder token) {
+ // Currently, this is a static constant, but later, we may change this to be dependent on
+ // the context of the activity
+ return 3;
+ }
+
+ private void logPictureInPictureArgs(PictureInPictureParams params) {
+ if (params.hasSetActions()) {
+ MetricsLogger.histogram(mContext, "tron_varz_picture_in_picture_actions_count",
+ params.getActions().size());
+ }
+ if (params.hasSetAspectRatio()) {
+ LogMaker lm = new LogMaker(MetricsEvent.ACTION_PICTURE_IN_PICTURE_ASPECT_RATIO_CHANGED);
+ lm.addTaggedData(MetricsEvent.PICTURE_IN_PICTURE_ASPECT_RATIO, params.getAspectRatio());
+ MetricsLogger.action(lm);
+ }
+ }
+
+ /**
+ * Checks the state of the system and the activity associated with the given {@param token} to
+ * verify that picture-in-picture is supported for that activity.
+ *
+ * @return the activity record for the given {@param token} if all the checks pass.
+ */
+ private ActivityRecord ensureValidPictureInPictureActivityParamsLocked(String caller,
+ IBinder token, PictureInPictureParams params) {
+ if (!mAm.mSupportsPictureInPicture) {
+ throw new IllegalStateException(caller
+ + ": Device doesn't support picture-in-picture mode.");
+ }
+
+ final ActivityRecord r = ActivityRecord.forTokenLocked(token);
+ if (r == null) {
+ throw new IllegalStateException(caller
+ + ": Can't find activity for token=" + token);
+ }
+
+ if (!r.supportsPictureInPicture()) {
+ throw new IllegalStateException(caller
+ + ": Current activity does not support picture-in-picture.");
+ }
+
+ if (params.hasSetAspectRatio()
+ && !mAm.mWindowManager.isValidPictureInPictureAspectRatio(r.getStack().mDisplayId,
+ params.getAspectRatio())) {
+ final float minAspectRatio = mContext.getResources().getFloat(
+ com.android.internal.R.dimen.config_pictureInPictureMinAspectRatio);
+ final float maxAspectRatio = mContext.getResources().getFloat(
+ com.android.internal.R.dimen.config_pictureInPictureMaxAspectRatio);
+ throw new IllegalArgumentException(String.format(caller
+ + ": Aspect ratio is too extreme (must be between %f and %f).",
+ minAspectRatio, maxAspectRatio));
+ }
+
+ // Truncate the number of actions if necessary
+ params.truncateActions(getMaxNumPictureInPictureActions(token));
+
+ return r;
+ }
+
+ @Override
+ public IBinder getUriPermissionOwnerForActivity(IBinder activityToken) {
+ mAm.enforceNotIsolatedCaller("getUriPermissionOwnerForActivity");
+ synchronized (mGlobalLock) {
+ ActivityRecord r = ActivityRecord.isInStackLocked(activityToken);
+ if (r == null) {
+ throw new IllegalArgumentException("Activity does not exist; token="
+ + activityToken);
+ }
+ return r.getUriPermissionsLocked().getExternalTokenLocked();
+ }
+ }
+
+ @Override
+ public void resizeDockedStack(Rect dockedBounds, Rect tempDockedTaskBounds,
+ Rect tempDockedTaskInsetBounds,
+ Rect tempOtherTaskBounds, Rect tempOtherTaskInsetBounds) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "resizeDockedStack()");
+ long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ mStackSupervisor.resizeDockedStackLocked(dockedBounds, tempDockedTaskBounds,
+ tempDockedTaskInsetBounds, tempOtherTaskBounds, tempOtherTaskInsetBounds,
+ PRESERVE_WINDOWS);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void setSplitScreenResizing(boolean resizing) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "setSplitScreenResizing()");
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ mStackSupervisor.setSplitScreenResizing(resizing);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public int setVrMode(IBinder token, boolean enabled, ComponentName packageName) {
+ mAm.enforceSystemHasVrFeature();
+
+ final VrManagerInternal vrService = LocalServices.getService(VrManagerInternal.class);
+
+ ActivityRecord r;
+ synchronized (mGlobalLock) {
+ r = ActivityRecord.isInStackLocked(token);
+ }
+
+ if (r == null) {
+ throw new IllegalArgumentException();
+ }
+
+ int err;
+ if ((err = vrService.hasVrPackage(packageName, r.userId)) !=
+ VrManagerInternal.NO_ERROR) {
+ return err;
+ }
+
+ // Clear the binder calling uid since this path may call moveToTask().
+ final long callingId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ r.requestedVrComponent = (enabled) ? packageName : null;
+
+ // Update associated state if this activity is currently focused
+ if (r == mStackSupervisor.getResumedActivityLocked()) {
+ mAm.applyUpdateVrModeLocked(r);
+ }
+ return 0;
+ }
+ } finally {
+ Binder.restoreCallingIdentity(callingId);
+ }
+ }
+
+ @Override
+ public void startLocalVoiceInteraction(IBinder callingActivity, Bundle options) {
+ Slog.i(TAG, "Activity tried to startLocalVoiceInteraction");
+ synchronized (mGlobalLock) {
+ ActivityRecord activity = mAm.getFocusedStack().getTopActivity();
+ if (ActivityRecord.forTokenLocked(callingActivity) != activity) {
+ throw new SecurityException("Only focused activity can call startVoiceInteraction");
+ }
+ if (mAm.mRunningVoice != null || activity.getTask().voiceSession != null
+ || activity.voiceSession != null) {
+ Slog.w(TAG, "Already in a voice interaction, cannot start new voice interaction");
+ return;
+ }
+ if (activity.pendingVoiceInteractionStart) {
+ Slog.w(TAG, "Pending start of voice interaction already.");
+ return;
+ }
+ activity.pendingVoiceInteractionStart = true;
+ }
+ LocalServices.getService(VoiceInteractionManagerInternal.class)
+ .startLocalVoiceInteraction(callingActivity, options);
+ }
+
+ @Override
+ public void stopLocalVoiceInteraction(IBinder callingActivity) {
+ LocalServices.getService(VoiceInteractionManagerInternal.class)
+ .stopLocalVoiceInteraction(callingActivity);
+ }
+
+ @Override
+ public boolean supportsLocalVoiceInteraction() {
+ return LocalServices.getService(VoiceInteractionManagerInternal.class)
+ .supportsLocalVoiceInteraction();
+ }
+
+ /** Notifies all listeners when the pinned stack animation starts. */
+ @Override
+ public void notifyPinnedStackAnimationStarted() {
+ mAm.mTaskChangeNotificationController.notifyPinnedStackAnimationStarted();
+ }
+
+ /** Notifies all listeners when the pinned stack animation ends. */
+ @Override
+ public void notifyPinnedStackAnimationEnded() {
+ mAm.mTaskChangeNotificationController.notifyPinnedStackAnimationEnded();
+ }
+
+ @Override
+ public void resizePinnedStack(Rect pinnedBounds, Rect tempPinnedTaskBounds) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS, "resizePinnedStack()");
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ mStackSupervisor.resizePinnedStackLocked(pinnedBounds, tempPinnedTaskBounds);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public boolean updateDisplayOverrideConfiguration(Configuration values, int displayId) {
+ mAm.enforceCallingPermission(CHANGE_CONFIGURATION, "updateDisplayOverrideConfiguration()");
+
+ synchronized (mGlobalLock) {
+ // Check if display is initialized in AM.
+ if (!mStackSupervisor.isDisplayAdded(displayId)) {
+ // Call might come when display is not yet added or has already been removed.
+ if (DEBUG_CONFIGURATION) {
+ Slog.w(TAG, "Trying to update display configuration for non-existing displayId="
+ + displayId);
+ }
+ return false;
+ }
+
+ if (values == null && mAm.mWindowManager != null) {
+ // sentinel: fetch the current configuration from the window manager
+ values = mAm.mWindowManager.computeNewConfiguration(displayId);
+ }
+
+ if (mAm.mWindowManager != null) {
+ // Update OOM levels based on display size.
+ mAm.mProcessList.applyDisplaySize(mAm.mWindowManager);
+ }
+
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ if (values != null) {
+ Settings.System.clearConfiguration(values);
+ }
+ mAm.updateDisplayOverrideConfigurationLocked(values, null /* starting */,
+ false /* deferResume */, displayId, mTmpUpdateConfigurationResult);
+ return mTmpUpdateConfigurationResult.changes != 0;
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ @Override
+ public boolean updateConfiguration(Configuration values) {
+ mAm.enforceCallingPermission(CHANGE_CONFIGURATION, "updateConfiguration()");
+
+ synchronized (mGlobalLock) {
+ if (values == null && mAm.mWindowManager != null) {
+ // sentinel: fetch the current configuration from the window manager
+ values = mAm.mWindowManager.computeNewConfiguration(DEFAULT_DISPLAY);
+ }
+
+ if (mAm.mWindowManager != null) {
+ // Update OOM levels based on display size.
+ mAm.mProcessList.applyDisplaySize(mAm.mWindowManager);
+ }
+
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ if (values != null) {
+ Settings.System.clearConfiguration(values);
+ }
+ mAm.updateConfigurationLocked(values, null, false, false /* persistent */,
+ UserHandle.USER_NULL, false /* deferResume */,
+ mTmpUpdateConfigurationResult);
+ return mTmpUpdateConfigurationResult.changes != 0;
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ @Override
+ public void dismissKeyguard(IBinder token, IKeyguardDismissCallback callback,
+ CharSequence message) {
+ if (message != null) {
+ mAm.enforceCallingPermission(
+ Manifest.permission.SHOW_KEYGUARD_MESSAGE, "dismissKeyguard()");
+ }
+ final long callingId = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ mAm.mKeyguardController.dismissKeyguard(token, callback, message);
+ }
+ } finally {
+ Binder.restoreCallingIdentity(callingId);
+ }
+ }
+
+ @Override
+ public void cancelTaskWindowTransition(int taskId) {
+ mAm.enforceCallerIsRecentsOrHasPermission(MANAGE_ACTIVITY_STACKS,
+ "cancelTaskWindowTransition()");
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ synchronized (mGlobalLock) {
+ final TaskRecord task = mStackSupervisor.anyTaskForIdLocked(taskId,
+ MATCH_TASK_IN_STACKS_ONLY);
+ if (task == null) {
+ Slog.w(TAG, "cancelTaskWindowTransition: taskId=" + taskId + " not found");
+ return;
+ }
+ task.cancelWindowTransition();
+ }
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public ActivityManager.TaskSnapshot getTaskSnapshot(int taskId, boolean reducedResolution) {
+ mAm.enforceCallerIsRecentsOrHasPermission(READ_FRAME_BUFFER, "getTaskSnapshot()");
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ final TaskRecord task;
+ synchronized (mGlobalLock) {
+ task = mStackSupervisor.anyTaskForIdLocked(taskId,
+ MATCH_TASK_IN_STACKS_OR_RECENT_TASKS);
+ if (task == null) {
+ Slog.w(TAG, "getTaskSnapshot: taskId=" + taskId + " not found");
+ return null;
+ }
+ }
+ // Don't call this while holding the lock as this operation might hit the disk.
+ return task.getSnapshot(reducedResolution);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ @Override
+ public void setDisablePreviewScreenshots(IBinder token, boolean disable) {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ Slog.w(TAG, "setDisablePreviewScreenshots: Unable to find activity for token="
+ + token);
+ return;
+ }
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ r.setDisablePreviewScreenshots(disable);
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ /** Return the user id of the last resumed activity. */
+ @Override
+ public @UserIdInt
+ int getLastResumedActivityUserId() {
+ mAm.enforceCallingPermission(
+ Manifest.permission.INTERACT_ACROSS_USERS_FULL, "getLastResumedActivityUserId()");
+ synchronized (mGlobalLock) {
+ if (mAm.mLastResumedActivity == null) {
+ return mAm.mUserController.getCurrentUserId();
+ }
+ return mAm.mLastResumedActivity.userId;
+ }
+ }
+
+ @Override
+ public void updateLockTaskFeatures(int userId, int flags) {
+ final int callingUid = Binder.getCallingUid();
+ if (callingUid != 0 && callingUid != SYSTEM_UID) {
+ mAm.enforceCallingPermission(android.Manifest.permission.UPDATE_LOCK_TASK_PACKAGES,
+ "updateLockTaskFeatures()");
+ }
+ synchronized (mGlobalLock) {
+ if (DEBUG_LOCKTASK) Slog.w(TAG_LOCKTASK, "Allowing features " + userId + ":0x" +
+ Integer.toHexString(flags));
+ mAm.getLockTaskController().updateLockTaskFeatures(userId, flags);
+ }
+ }
+
+ @Override
+ public void setShowWhenLocked(IBinder token, boolean showWhenLocked) {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return;
+ }
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ r.setShowWhenLocked(showWhenLocked);
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ @Override
+ public void setTurnScreenOn(IBinder token, boolean turnScreenOn) {
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return;
+ }
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ r.setTurnScreenOn(turnScreenOn);
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ @Override
+ public void registerRemoteAnimations(IBinder token, RemoteAnimationDefinition definition) {
+ mAm.enforceCallingPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS,
+ "registerRemoteAnimations");
+ definition.setCallingPid(Binder.getCallingPid());
+ synchronized (mGlobalLock) {
+ final ActivityRecord r = ActivityRecord.isInStackLocked(token);
+ if (r == null) {
+ return;
+ }
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ r.registerRemoteAnimations(definition);
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ @Override
+ public void registerRemoteAnimationForNextActivityStart(String packageName,
+ RemoteAnimationAdapter adapter) {
+ mAm.enforceCallingPermission(CONTROL_REMOTE_APP_TRANSITION_ANIMATIONS,
+ "registerRemoteAnimationForNextActivityStart");
+ adapter.setCallingPid(Binder.getCallingPid());
+ synchronized (mGlobalLock) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ mAm.getActivityStartController().registerRemoteAnimationForNextActivityStart(
+ packageName, adapter);
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+
+ /** @see android.app.ActivityManager#alwaysShowUnsupportedCompileSdkWarning */
+ @Override
+ public void alwaysShowUnsupportedCompileSdkWarning(ComponentName activity) {
+ synchronized (mGlobalLock) {
+ final long origId = Binder.clearCallingIdentity();
+ try {
+ mAm.mAppWarnings.alwaysShowUnsupportedCompileSdkWarning(activity);
+ } finally {
+ Binder.restoreCallingIdentity(origId);
+ }
+ }
+ }
+}
diff --git a/services/core/java/com/android/server/am/AppErrors.java b/services/core/java/com/android/server/am/AppErrors.java
index a6dafbb1db36..75090d4b9f90 100644
--- a/services/core/java/com/android/server/am/AppErrors.java
+++ b/services/core/java/com/android/server/am/AppErrors.java
@@ -471,7 +471,7 @@ class AppErrors {
mService.removeProcessLocked(r, false, true, "crash");
if (task != null) {
try {
- mService.startActivityFromRecents(task.taskId,
+ mService.mActivityTaskManager.startActivityFromRecents(task.taskId,
ActivityOptions.makeBasic().toBundle());
} catch (IllegalArgumentException e) {
// Hmm, that didn't work, app might have crashed before creating a
diff --git a/services/core/java/com/android/server/am/AssistDataRequester.java b/services/core/java/com/android/server/am/AssistDataRequester.java
index 9f7621f2e78e..14d14982bf7d 100644
--- a/services/core/java/com/android/server/am/AssistDataRequester.java
+++ b/services/core/java/com/android/server/am/AssistDataRequester.java
@@ -21,6 +21,7 @@ import static android.app.ActivityManagerInternal.ASSIST_KEY_RECEIVER_EXTRAS;
import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.OP_NONE;
+import android.app.ActivityTaskManager;
import android.app.AppOpsManager;
import android.app.IActivityManager;
import android.app.IAssistDataReceiver;
@@ -163,7 +164,8 @@ public class AssistDataRequester extends IAssistDataReceiver.Stub {
// Ensure that the current activity supports assist data
boolean isAssistDataAllowed = false;
try {
- isAssistDataAllowed = mService.isAssistDataAllowedOnCurrentActivity();
+ isAssistDataAllowed =
+ ActivityTaskManager.getService().isAssistDataAllowedOnCurrentActivity();
} catch (RemoteException e) {
// Should never happen
}
@@ -188,9 +190,9 @@ public class AssistDataRequester extends IAssistDataReceiver.Stub {
Bundle receiverExtras = new Bundle();
receiverExtras.putInt(KEY_RECEIVER_EXTRA_INDEX, i);
receiverExtras.putInt(KEY_RECEIVER_EXTRA_COUNT, numActivities);
- if (mService.requestAssistContextExtras(ASSIST_CONTEXT_FULL, this,
- receiverExtras, topActivity, /* focused= */ i == 0,
- /* newSessionId= */ i == 0)) {
+ if (ActivityTaskManager.getService().requestAssistContextExtras(
+ ASSIST_CONTEXT_FULL, this, receiverExtras, topActivity,
+ /* focused= */ i == 0, /* newSessionId= */ i == 0)) {
mPendingDataCount++;
} else if (i == 0) {
// Wasn't allowed... given that, let's not do the screenshot either.
diff --git a/services/core/java/com/android/server/am/LaunchParamsController.java b/services/core/java/com/android/server/am/LaunchParamsController.java
index 7ab7f987d301..4330d2c6efaf 100644
--- a/services/core/java/com/android/server/am/LaunchParamsController.java
+++ b/services/core/java/com/android/server/am/LaunchParamsController.java
@@ -125,7 +125,7 @@ class LaunchParamsController {
try {
if (mTmpParams.hasPreferredDisplay()
&& mTmpParams.mPreferredDisplayId != task.getStack().getDisplay().mDisplayId) {
- mService.moveStackToDisplay(task.getStackId(), mTmpParams.mPreferredDisplayId);
+ mService.mActivityTaskManager.moveStackToDisplay(task.getStackId(), mTmpParams.mPreferredDisplayId);
}
if (mTmpParams.hasWindowingMode()
diff --git a/services/core/java/com/android/server/am/LockTaskController.java b/services/core/java/com/android/server/am/LockTaskController.java
index 151ef4942432..4fd01cdeaa3b 100644
--- a/services/core/java/com/android/server/am/LockTaskController.java
+++ b/services/core/java/com/android/server/am/LockTaskController.java
@@ -361,7 +361,7 @@ public class LockTaskController {
* @param task the task that requested the end of lock task mode ({@code null} for quitting app
* pinning mode)
* @param isSystemCaller indicates whether this request comes from the system via
- * {@link ActivityManagerService#stopSystemLockTaskMode()}. If
+ * {@link ActivityTaskManagerService#stopSystemLockTaskMode()}. If
* {@code true}, it means the user intends to stop pinned mode through UI;
* otherwise, it's called by an app and we need to stop locked or pinned
* mode, subject to checks.
@@ -509,7 +509,7 @@ public class LockTaskController {
*
* @param task the task that should be locked.
* @param isSystemCaller indicates whether this request was initiated by the system via
- * {@link ActivityManagerService#startSystemLockTaskMode(int)}. If
+ * {@link ActivityTaskManagerService#startSystemLockTaskMode(int)}. If
* {@code true}, this intends to start pinned mode; otherwise, we look
* at the calling task's mLockTaskAuth to decide which mode to start.
* @param callingUid the caller that requested the launch of lock task mode.
diff --git a/services/core/java/com/android/server/am/PinnedActivityStack.java b/services/core/java/com/android/server/am/PinnedActivityStack.java
index 27269791f568..4062f45b2ef7 100644
--- a/services/core/java/com/android/server/am/PinnedActivityStack.java
+++ b/services/core/java/com/android/server/am/PinnedActivityStack.java
@@ -55,7 +55,7 @@ class PinnedActivityStack extends ActivityStack<PinnedStackWindowController>
void animateResizePinnedStack(Rect sourceHintBounds, Rect toBounds, int animationDuration,
boolean fromFullscreen) {
if (skipResizeAnimation(toBounds == null /* toFullscreen */)) {
- mService.moveTasksToFullscreenStack(mStackId, true /* onTop */);
+ mService.mActivityTaskManager.moveTasksToFullscreenStack(mStackId, true /* onTop */);
} else {
getWindowContainerController().animateResizePinnedStack(toBounds, sourceHintBounds,
animationDuration, fromFullscreen);
diff --git a/services/core/java/com/android/server/am/RecentTasks.java b/services/core/java/com/android/server/am/RecentTasks.java
index 06a30780e9ea..810b9fd38f39 100644
--- a/services/core/java/com/android/server/am/RecentTasks.java
+++ b/services/core/java/com/android/server/am/RecentTasks.java
@@ -41,6 +41,7 @@ import static com.android.server.am.ActivityStackSupervisor.REMOVE_FROM_RECENTS;
import static com.android.server.am.TaskRecord.INVALID_TASK_ID;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.AppGlobals;
import android.content.ComponentName;
import android.content.Intent;
@@ -184,7 +185,7 @@ class RecentTasks {
mService = service;
mUserController = userController;
mTaskPersister = taskPersister;
- mGlobalMaxNumTasks = ActivityManager.getMaxRecentTasksStatic();
+ mGlobalMaxNumTasks = ActivityTaskManager.getMaxRecentTasksStatic();
mHasVisibleRecentTasks = true;
}
@@ -194,7 +195,7 @@ class RecentTasks {
mService = service;
mUserController = service.mUserController;
mTaskPersister = new TaskPersister(systemDir, stackSupervisor, service, this);
- mGlobalMaxNumTasks = ActivityManager.getMaxRecentTasksStatic();
+ mGlobalMaxNumTasks = ActivityTaskManager.getMaxRecentTasksStatic();
mHasVisibleRecentTasks = res.getBoolean(com.android.internal.R.bool.config_hasRecents);
loadParametersFromResources(res);
}
diff --git a/services/core/java/com/android/server/am/TaskRecord.java b/services/core/java/com/android/server/am/TaskRecord.java
index d3ac7cb15824..0ea49b26bf17 100644
--- a/services/core/java/com/android/server/am/TaskRecord.java
+++ b/services/core/java/com/android/server/am/TaskRecord.java
@@ -16,9 +16,9 @@
package com.android.server.am;
-import static android.app.ActivityManager.RESIZE_MODE_FORCED;
-import static android.app.ActivityManager.RESIZE_MODE_SYSTEM;
-import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
+import static android.app.ActivityTaskManager.RESIZE_MODE_FORCED;
+import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM;
+import static android.app.ActivityTaskManager.INVALID_STACK_ID;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
@@ -85,6 +85,7 @@ import android.app.ActivityManager;
import android.app.ActivityManager.TaskDescription;
import android.app.ActivityManager.TaskSnapshot;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.app.AppGlobals;
import android.app.IActivityManager;
import android.content.ComponentName;
@@ -364,7 +365,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi
isPersistable = true;
// Clamp to [1, max].
maxRecents = Math.min(Math.max(info.maxRecents, 1),
- ActivityManager.getMaxAppRecentsLimitStatic());
+ ActivityTaskManager.getMaxAppRecentsLimitStatic());
lastTaskDescription = _taskDescription;
touchActiveTime();
@@ -485,7 +486,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi
// TODO: Consolidate this with the resize() method below.
@Override
public void requestResize(Rect bounds, int resizeMode) {
- mService.resizeTask(taskId, bounds, resizeMode);
+ mService.mActivityTaskManager.resizeTask(taskId, bounds, resizeMode);
}
boolean resize(Rect bounds, int resizeMode, boolean preserveWindow, boolean deferResume) {
@@ -1233,7 +1234,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi
mCallingPackage = r.launchedFromPackage;
// Clamp to [1, max].
maxRecents = Math.min(Math.max(r.info.maxRecents, 1),
- ActivityManager.getMaxAppRecentsLimitStatic());
+ ActivityTaskManager.getMaxAppRecentsLimitStatic());
} else {
// Otherwise make all added activities match this one.
r.setActivityType(getActivityType());
@@ -1744,7 +1745,7 @@ class TaskRecord extends ConfigurationContainer implements TaskWindowContainerLi
* @param bounds The bounds of the task.
* @param insetBounds The bounds used to calculate the system insets, which is used here to
* subtract the navigation bar/status bar size from the screen size reported
- * to the application. See {@link IActivityManager#resizeDockedStack}.
+ * to the application. See {@link IActivityTaskManager#resizeDockedStack}.
* @return True if the override configuration was updated.
*/
boolean updateOverrideConfiguration(Rect bounds, @Nullable Rect insetBounds) {
diff --git a/services/core/java/com/android/server/audio/AudioService.java b/services/core/java/com/android/server/audio/AudioService.java
index 9c0d4e00b3c3..2a5249b31c26 100644
--- a/services/core/java/com/android/server/audio/AudioService.java
+++ b/services/core/java/com/android/server/audio/AudioService.java
@@ -2636,6 +2636,7 @@ public class AudioService extends IAudioService.Stub
broadcastRingerMode(AudioManager.RINGER_MODE_CHANGED_ACTION, ringerMode);
}
+ @GuardedBy("mSettingsLock")
private void muteRingerModeStreams() {
// Mute stream if not previously muted by ringer mode and (ringer mode
// is not RINGER_MODE_NORMAL OR stream is zen muted) and stream is affected by ringer mode.
@@ -2723,10 +2724,9 @@ public class AudioService extends IAudioService.Stub
synchronized(mSettingsLock) {
change = mRingerMode != ringerMode;
mRingerMode = ringerMode;
+ muteRingerModeStreams();
}
- muteRingerModeStreams();
-
// Post a persist ringer mode msg
if (persist) {
sendMsg(mAudioHandler, MSG_PERSIST_RINGER_MODE,
diff --git a/services/core/java/com/android/server/connectivity/PacManager.java b/services/core/java/com/android/server/connectivity/PacManager.java
index 3a27fcb352aa..19b61e6fc739 100644
--- a/services/core/java/com/android/server/connectivity/PacManager.java
+++ b/services/core/java/com/android/server/connectivity/PacManager.java
@@ -90,7 +90,7 @@ public class PacManager {
private volatile boolean mHasDownloaded;
private Handler mConnectivityHandler;
- private int mProxyMessage;
+ private final int mProxyMessage;
/**
* Used for locking when setting mProxyService and all references to mCurrentPac.
@@ -99,7 +99,7 @@ public class PacManager {
/**
* Runnable to download PAC script.
- * The behavior relies on the assamption it always run on mNetThread to guarantee that the
+ * The behavior relies on the assumption it always runs on mNetThread to guarantee that the
* latest data fetched from mPacUrl is stored in mProxyService.
*/
private Runnable mPacDownloader = new Runnable() {
@@ -133,8 +133,6 @@ public class PacManager {
}
};
- private final HandlerThread mNetThread = new HandlerThread("android.pacmanager",
- android.os.Process.THREAD_PRIORITY_DEFAULT);
private final Handler mNetThreadHandler;
class PacRefreshIntentReceiver extends BroadcastReceiver {
@@ -146,8 +144,10 @@ public class PacManager {
public PacManager(Context context, Handler handler, int proxyMessage) {
mContext = context;
mLastPort = -1;
- mNetThread.start();
- mNetThreadHandler = new Handler(mNetThread.getLooper());
+ final HandlerThread netThread = new HandlerThread("android.pacmanager",
+ android.os.Process.THREAD_PRIORITY_DEFAULT);
+ netThread.start();
+ mNetThreadHandler = new Handler(netThread.getLooper());
mPacRefreshIntent = PendingIntent.getBroadcast(
context, 0, new Intent(ACTION_PAC_REFRESH), 0);
@@ -208,7 +208,7 @@ public class PacManager {
/**
* Does a post and reports back the status code.
*
- * @throws IOException
+ * @throws IOException if the URL is malformed, or the PAC file is too big.
*/
private static String get(Uri pacUri) throws IOException {
URL url = new URL(pacUri.toString());
@@ -254,7 +254,7 @@ public class PacManager {
private String getPacChangeDelay() {
final ContentResolver cr = mContext.getContentResolver();
- /** Check system properties for the default value then use secure settings value, if any. */
+ // Check system properties for the default value then use secure settings value, if any.
String defaultDelay = SystemProperties.get(
"conn." + Settings.Global.PAC_CHANGE_DELAY,
DEFAULT_DELAYS);
@@ -276,10 +276,9 @@ public class PacManager {
getAlarmManager().set(AlarmManager.ELAPSED_REALTIME, timeTillTrigger, mPacRefreshIntent);
}
- private boolean setCurrentProxyScript(String script) {
+ private void setCurrentProxyScript(String script) {
if (mProxyService == null) {
Log.e(TAG, "setCurrentProxyScript: no proxy service");
- return false;
}
try {
mProxyService.setPacFile(script);
@@ -287,7 +286,6 @@ public class PacManager {
} catch (RemoteException e) {
Log.e(TAG, "Unable to set PAC file", e);
}
- return true;
}
private void bind() {
@@ -351,7 +349,7 @@ public class PacManager {
try {
callbackService.getProxyPort(new IProxyPortListener.Stub() {
@Override
- public void setProxyPort(int port) throws RemoteException {
+ public void setProxyPort(int port) {
if (mLastPort != -1) {
// Always need to send if port changed
mHasSentBroadcast = false;
diff --git a/services/core/java/com/android/server/connectivity/ProxyTracker.java b/services/core/java/com/android/server/connectivity/ProxyTracker.java
new file mode 100644
index 000000000000..daaedd813163
--- /dev/null
+++ b/services/core/java/com/android/server/connectivity/ProxyTracker.java
@@ -0,0 +1,184 @@
+/**
+ * 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.server.connectivity;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.content.ContentResolver;
+import android.content.Context;
+import android.content.Intent;
+import android.net.Proxy;
+import android.net.ProxyInfo;
+import android.net.Uri;
+import android.os.Binder;
+import android.os.Handler;
+import android.os.UserHandle;
+import android.provider.Settings;
+import android.text.TextUtils;
+import android.util.Slog;
+
+import com.android.internal.annotations.GuardedBy;
+
+import java.util.Objects;
+
+/**
+ * A class to handle proxy for ConnectivityService.
+ *
+ * @hide
+ */
+public class ProxyTracker {
+ private static final String TAG = ProxyTracker.class.getSimpleName();
+ private static final boolean DBG = true;
+
+ @NonNull
+ private final Context mContext;
+
+ // TODO : make this private and import as much managing logic from ConnectivityService as
+ // possible
+ @NonNull
+ public final Object mProxyLock = new Object();
+ @Nullable
+ @GuardedBy("mProxyLock")
+ public ProxyInfo mGlobalProxy = null;
+ @Nullable
+ @GuardedBy("mProxyLock")
+ public volatile ProxyInfo mDefaultProxy = null;
+ @GuardedBy("mProxyLock")
+ public boolean mDefaultProxyDisabled = false;
+
+ @NonNull
+ private final PacManager mPacManager;
+
+ public ProxyTracker(@NonNull final Context context,
+ @NonNull final Handler connectivityServiceInternalHandler, final int pacChangedEvent) {
+ mContext = context;
+ mPacManager = new PacManager(context, connectivityServiceInternalHandler, pacChangedEvent);
+ }
+
+ // Convert empty ProxyInfo's to null as null-checks are used to determine if proxies are present
+ // (e.g. if mGlobalProxy==null fall back to network-specific proxy, if network-specific
+ // proxy is null then there is no proxy in place).
+ @Nullable
+ private static ProxyInfo canonicalizeProxyInfo(@Nullable final ProxyInfo proxy) {
+ if (proxy != null && TextUtils.isEmpty(proxy.getHost())
+ && (proxy.getPacFileUrl() == null || Uri.EMPTY.equals(proxy.getPacFileUrl()))) {
+ return null;
+ }
+ return proxy;
+ }
+
+ // ProxyInfo equality functions with a couple modifications over ProxyInfo.equals() to make it
+ // better for determining if a new proxy broadcast is necessary:
+ // 1. Canonicalize empty ProxyInfos to null so an empty proxy compares equal to null so as to
+ // avoid unnecessary broadcasts.
+ // 2. Make sure all parts of the ProxyInfo's compare true, including the host when a PAC URL
+ // is in place. This is important so legacy PAC resolver (see com.android.proxyhandler)
+ // changes aren't missed. The legacy PAC resolver pretends to be a simple HTTP proxy but
+ // actually uses the PAC to resolve; this results in ProxyInfo's with PAC URL, host and port
+ // all set.
+ public static boolean proxyInfoEqual(@Nullable final ProxyInfo a, @Nullable final ProxyInfo b) {
+ final ProxyInfo pa = canonicalizeProxyInfo(a);
+ final ProxyInfo pb = canonicalizeProxyInfo(b);
+ // ProxyInfo.equals() doesn't check hosts when PAC URLs are present, but we need to check
+ // hosts even when PAC URLs are present to account for the legacy PAC resolver.
+ return Objects.equals(pa, pb) && (pa == null || Objects.equals(pa.getHost(), pb.getHost()));
+ }
+
+ @Nullable
+ public ProxyInfo getDefaultProxy() {
+ // This information is already available as a world read/writable jvm property.
+ synchronized (mProxyLock) {
+ final ProxyInfo ret = mGlobalProxy;
+ if ((ret == null) && !mDefaultProxyDisabled) return mDefaultProxy;
+ return ret;
+ }
+ }
+
+ @Nullable
+ public ProxyInfo getGlobalProxy() {
+ // This information is already available as a world read/writable jvm property.
+ synchronized (mProxyLock) {
+ return mGlobalProxy;
+ }
+ }
+
+ public boolean setCurrentProxyScriptUrl(@NonNull final ProxyInfo proxy) {
+ return mPacManager.setCurrentProxyScriptUrl(proxy);
+ }
+
+ // TODO : make the argument NonNull final
+ public void sendProxyBroadcast(@Nullable ProxyInfo proxy) {
+ if (proxy == null) proxy = new ProxyInfo("", 0, "");
+ if (setCurrentProxyScriptUrl(proxy)) return;
+ if (DBG) Slog.d(TAG, "sending Proxy Broadcast for " + proxy);
+ Intent intent = new Intent(Proxy.PROXY_CHANGE_ACTION);
+ intent.addFlags(Intent.FLAG_RECEIVER_REPLACE_PENDING |
+ Intent.FLAG_RECEIVER_REGISTERED_ONLY_BEFORE_BOOT);
+ intent.putExtra(Proxy.EXTRA_PROXY_INFO, proxy);
+ final long ident = Binder.clearCallingIdentity();
+ try {
+ mContext.sendStickyBroadcastAsUser(intent, UserHandle.ALL);
+ } finally {
+ Binder.restoreCallingIdentity(ident);
+ }
+ }
+
+ public void setGlobalProxy(@Nullable ProxyInfo proxyProperties) {
+ synchronized (mProxyLock) {
+ if (proxyProperties == mGlobalProxy) return;
+ if (proxyProperties != null && proxyProperties.equals(mGlobalProxy)) return;
+ if (mGlobalProxy != null && mGlobalProxy.equals(proxyProperties)) return;
+
+ String host = "";
+ int port = 0;
+ String exclList = "";
+ String pacFileUrl = "";
+ if (proxyProperties != null && (!TextUtils.isEmpty(proxyProperties.getHost()) ||
+ !Uri.EMPTY.equals(proxyProperties.getPacFileUrl()))) {
+ if (!proxyProperties.isValid()) {
+ if (DBG) Slog.d(TAG, "Invalid proxy properties, ignoring: " + proxyProperties);
+ return;
+ }
+ mGlobalProxy = new ProxyInfo(proxyProperties);
+ host = mGlobalProxy.getHost();
+ port = mGlobalProxy.getPort();
+ exclList = mGlobalProxy.getExclusionListAsString();
+ if (!Uri.EMPTY.equals(proxyProperties.getPacFileUrl())) {
+ pacFileUrl = proxyProperties.getPacFileUrl().toString();
+ }
+ } else {
+ mGlobalProxy = null;
+ }
+ final ContentResolver res = mContext.getContentResolver();
+ final long token = Binder.clearCallingIdentity();
+ try {
+ Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_HOST, host);
+ Settings.Global.putInt(res, Settings.Global.GLOBAL_HTTP_PROXY_PORT, port);
+ Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_EXCLUSION_LIST,
+ exclList);
+ Settings.Global.putString(res, Settings.Global.GLOBAL_HTTP_PROXY_PAC, pacFileUrl);
+ } finally {
+ Binder.restoreCallingIdentity(token);
+ }
+
+ if (mGlobalProxy == null) {
+ proxyProperties = mDefaultProxy;
+ }
+ sendProxyBroadcast(proxyProperties);
+ }
+ }
+}
diff --git a/services/core/java/com/android/server/display/BrightnessTracker.java b/services/core/java/com/android/server/display/BrightnessTracker.java
index a568fe336f37..c473ef23db3e 100644
--- a/services/core/java/com/android/server/display/BrightnessTracker.java
+++ b/services/core/java/com/android/server/display/BrightnessTracker.java
@@ -19,6 +19,7 @@ package com.android.server.display;
import android.annotation.Nullable;
import android.annotation.UserIdInt;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.content.BroadcastReceiver;
import android.content.ContentResolver;
import android.content.Context;
@@ -937,7 +938,7 @@ public class BrightnessTracker {
}
public ActivityManager.StackInfo getFocusedStack() throws RemoteException {
- return ActivityManager.getService().getFocusedStackInfo();
+ return ActivityTaskManager.getService().getFocusedStackInfo();
}
public void scheduleIdleJob(Context context) {
diff --git a/services/core/java/com/android/server/display/DisplayTransformManager.java b/services/core/java/com/android/server/display/DisplayTransformManager.java
index 57a4f0dd526d..d6931e006479 100644
--- a/services/core/java/com/android/server/display/DisplayTransformManager.java
+++ b/services/core/java/com/android/server/display/DisplayTransformManager.java
@@ -17,6 +17,7 @@
package com.android.server.display;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.opengl.Matrix;
import android.os.IBinder;
import android.os.Parcel;
@@ -309,7 +310,7 @@ public class DisplayTransformManager {
private void updateConfiguration() {
try {
- ActivityManager.getService().updateConfiguration(null);
+ ActivityTaskManager.getService().updateConfiguration(null);
} catch (RemoteException e) {
Log.e(TAG, "Could not update configuration", e);
}
diff --git a/services/core/java/com/android/server/fingerprint/FingerprintService.java b/services/core/java/com/android/server/fingerprint/FingerprintService.java
index 06329e571b43..8e7782015691 100644
--- a/services/core/java/com/android/server/fingerprint/FingerprintService.java
+++ b/services/core/java/com/android/server/fingerprint/FingerprintService.java
@@ -25,9 +25,11 @@ import static android.app.ActivityManager.RunningAppProcessInfo.IMPORTANCE_FOREG
import android.app.ActivityManager;
import android.app.ActivityManager.RunningAppProcessInfo;
+import android.app.ActivityTaskManager;
import android.app.AlarmManager;
import android.app.AppOpsManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.PendingIntent;
import android.app.SynchronousUserSwitchObserver;
import android.app.TaskStackListener;
@@ -140,6 +142,7 @@ public class FingerprintService extends SystemService implements IHwBinder.Death
private IBiometricsFingerprint mDaemon;
private IStatusBarService mStatusBarService;
private final IActivityManager mActivityManager;
+ private final IActivityTaskManager mActivityTaskManager;
private final PowerManager mPowerManager;
private final AlarmManager mAlarmManager;
private final UserManager mUserManager;
@@ -229,7 +232,8 @@ public class FingerprintService extends SystemService implements IHwBinder.Death
if (isKeyguard(currentClient)) {
return; // Keyguard is always allowed
}
- List<ActivityManager.RunningTaskInfo> runningTasks = mActivityManager.getTasks(1);
+ List<ActivityManager.RunningTaskInfo> runningTasks =
+ mActivityTaskManager.getTasks(1);
if (!runningTasks.isEmpty()) {
final String topPackage = runningTasks.get(0).topActivity.getPackageName();
if (!topPackage.contentEquals(currentClient)) {
@@ -261,6 +265,8 @@ public class FingerprintService extends SystemService implements IHwBinder.Death
ServiceManager.getService(Context.STATUS_BAR_SERVICE));
mActivityManager = ((ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE))
.getService();
+ mActivityTaskManager = ((ActivityTaskManager) context.getSystemService(
+ Context.ACTIVITY_TASK_SERVICE)).getService();
}
@Override
@@ -871,7 +877,7 @@ public class FingerprintService extends SystemService implements IHwBinder.Death
@Override
public void onStart() {
try {
- mActivityManager.registerTaskStackListener(mTaskStackListener);
+ mActivityTaskManager.registerTaskStackListener(mTaskStackListener);
} catch (RemoteException e) {
Slog.e(TAG, "Could not register task stack listener", e);
}
@@ -880,7 +886,7 @@ public class FingerprintService extends SystemService implements IHwBinder.Death
@Override
public void onStop() {
try {
- mActivityManager.unregisterTaskStackListener(mTaskStackListener);
+ mActivityTaskManager.unregisterTaskStackListener(mTaskStackListener);
} catch (RemoteException e) {
Slog.e(TAG, "Could not unregister task stack listener", e);
}
diff --git a/services/core/java/com/android/server/location/GnssLocationProvider.java b/services/core/java/com/android/server/location/GnssLocationProvider.java
index b90c12a72047..d515ce679179 100644
--- a/services/core/java/com/android/server/location/GnssLocationProvider.java
+++ b/services/core/java/com/android/server/location/GnssLocationProvider.java
@@ -253,8 +253,8 @@ public class GnssLocationProvider implements LocationProviderInterface, InjectNt
// 1 second, or 1 Hz frequency.
private static final long LOCATION_UPDATE_MIN_TIME_INTERVAL_MILLIS = 1000;
- // 30 seconds.
- private static final long LOCATION_UPDATE_DURATION_MILLIS = 30 * 1000;
+ // Default update duration in milliseconds for REQUEST_LOCATION.
+ private static final long LOCATION_UPDATE_DURATION_MILLIS = 0;
/** simpler wrapper for ProviderRequest + Worksource */
private static class GpsRequest {
diff --git a/services/core/java/com/android/server/media/MediaSessionService.java b/services/core/java/com/android/server/media/MediaSessionService.java
index 6fff3676ac8d..68b2a583e020 100644
--- a/services/core/java/com/android/server/media/MediaSessionService.java
+++ b/services/core/java/com/android/server/media/MediaSessionService.java
@@ -781,6 +781,9 @@ public class MediaSessionService extends SystemService implements Monitor {
}
private void dispatchVolumeKeyLongPressLocked(KeyEvent keyEvent) {
+ if (mCurrentFullUserRecord.mOnVolumeKeyLongPressListener == null) {
+ return;
+ }
try {
mCurrentFullUserRecord.mOnVolumeKeyLongPressListener.onVolumeKeyLongPress(keyEvent);
} catch (RemoteException e) {
diff --git a/services/core/java/com/android/server/notification/NotificationManagerService.java b/services/core/java/com/android/server/notification/NotificationManagerService.java
index 2cad829261f0..0897b8a52ad6 100644
--- a/services/core/java/com/android/server/notification/NotificationManagerService.java
+++ b/services/core/java/com/android/server/notification/NotificationManagerService.java
@@ -617,7 +617,7 @@ public class NotificationManagerService extends SystemService {
{
final int pid;
final String pkg;
- ITransientNotification callback;
+ final ITransientNotification callback;
int duration;
Binder token;
@@ -634,10 +634,6 @@ public class NotificationManagerService extends SystemService {
this.duration = duration;
}
- void update(ITransientNotification callback) {
- this.callback = callback;
- }
-
void dump(PrintWriter pw, String prefix, DumpFilter filter) {
if (filter != null && !filter.matches(pkg)) return;
pw.println(prefix + this);
@@ -1993,32 +1989,38 @@ public class NotificationManagerService extends SystemService {
long callingId = Binder.clearCallingIdentity();
try {
ToastRecord record;
- int index;
- // All packages aside from the android package can enqueue one toast at a time
- if (!isSystemToast) {
- index = indexOfToastPackageLocked(pkg);
- } else {
- index = indexOfToastLocked(pkg, callback);
- }
-
- // If the package already has a toast, we update its toast
- // in the queue, we don't move it to the end of the queue.
+ int index = indexOfToastLocked(pkg, callback);
+ // If it's already in the queue, we update it in place, we don't
+ // move it to the end of the queue.
if (index >= 0) {
record = mToastQueue.get(index);
record.update(duration);
- try {
- record.callback.hide();
- } catch (RemoteException e) {
- }
- record.update(callback);
} else {
+ // Limit the number of toasts that any given package except the android
+ // package can enqueue. Prevents DOS attacks and deals with leaks.
+ if (!isSystemToast) {
+ int count = 0;
+ final int N = mToastQueue.size();
+ for (int i=0; i<N; i++) {
+ final ToastRecord r = mToastQueue.get(i);
+ if (r.pkg.equals(pkg)) {
+ count++;
+ if (count >= MAX_PACKAGE_NOTIFICATIONS) {
+ Slog.e(TAG, "Package has already posted " + count
+ + " toasts. Not showing more. Package=" + pkg);
+ return;
+ }
+ }
+ }
+ }
+
Binder token = new Binder();
mWindowManagerInternal.addWindowToken(token, TYPE_TOAST, DEFAULT_DISPLAY);
record = new ToastRecord(callingPid, pkg, callback, duration, token);
mToastQueue.add(record);
index = mToastQueue.size() - 1;
+ keepProcessAliveIfNeededLocked(callingPid);
}
- keepProcessAliveIfNeededLocked(callingPid);
// If it's at index 0, it's the current toast. It doesn't matter if it's
// new or just been updated. Call back and tell it to show itself.
// If the callback fails, this will remove it from the list, so don't
@@ -5098,21 +5100,7 @@ public class NotificationManagerService extends SystemService {
int len = list.size();
for (int i=0; i<len; i++) {
ToastRecord r = list.get(i);
- if (r.pkg.equals(pkg) && r.callback.asBinder().equals(cbak)) {
- return i;
- }
- }
- return -1;
- }
-
- @GuardedBy("mToastQueue")
- int indexOfToastPackageLocked(String pkg)
- {
- ArrayList<ToastRecord> list = mToastQueue;
- int len = list.size();
- for (int i=0; i<len; i++) {
- ToastRecord r = list.get(i);
- if (r.pkg.equals(pkg)) {
+ if (r.pkg.equals(pkg) && r.callback.asBinder() == cbak) {
return i;
}
}
diff --git a/services/core/java/com/android/server/pm/InstantAppResolver.java b/services/core/java/com/android/server/pm/InstantAppResolver.java
index 9a5dd5e04b07..19cefb8a6ceb 100644
--- a/services/core/java/com/android/server/pm/InstantAppResolver.java
+++ b/services/core/java/com/android/server/pm/InstantAppResolver.java
@@ -265,13 +265,9 @@ public abstract class InstantAppResolver {
| Intent.FLAG_ACTIVITY_NO_HISTORY
| Intent.FLAG_ACTIVITY_EXCLUDE_FROM_RECENTS);
if (token != null) {
- // TODO(b/72700831): remove populating old extra
- intent.putExtra(Intent.EXTRA_EPHEMERAL_TOKEN, token);
intent.putExtra(Intent.EXTRA_INSTANT_APP_TOKEN, token);
}
if (origIntent.getData() != null) {
- // TODO(b/72700831): remove populating old extra
- intent.putExtra(Intent.EXTRA_EPHEMERAL_HOSTNAME, origIntent.getData().getHost());
intent.putExtra(Intent.EXTRA_INSTANT_APP_HOSTNAME, origIntent.getData().getHost());
}
intent.putExtra(Intent.EXTRA_INSTANT_APP_ACTION, origIntent.getAction());
@@ -308,7 +304,6 @@ public abstract class InstantAppResolver {
null /*bOptions*/, userId);
IntentSender failureSender = new IntentSender(failureIntentTarget);
// TODO(b/72700831): remove populating old extra
- intent.putExtra(Intent.EXTRA_EPHEMERAL_FAILURE, failureSender);
intent.putExtra(Intent.EXTRA_INSTANT_APP_FAILURE, failureSender);
} catch (RemoteException ignore) { /* ignore; same process */ }
}
@@ -327,8 +322,6 @@ public abstract class InstantAppResolver {
| PendingIntent.FLAG_IMMUTABLE,
null /*bOptions*/, userId);
IntentSender successSender = new IntentSender(successIntentTarget);
- // TODO(b/72700831): remove populating old extra
- intent.putExtra(Intent.EXTRA_EPHEMERAL_SUCCESS, successSender);
intent.putExtra(Intent.EXTRA_INSTANT_APP_SUCCESS, successSender);
} catch (RemoteException ignore) { /* ignore; same process */ }
if (verificationBundle != null) {
diff --git a/services/core/java/com/android/server/pm/PackageManagerService.java b/services/core/java/com/android/server/pm/PackageManagerService.java
index b5f3a9401d80..8ffe1200e9ea 100644
--- a/services/core/java/com/android/server/pm/PackageManagerService.java
+++ b/services/core/java/com/android/server/pm/PackageManagerService.java
@@ -14009,43 +14009,6 @@ public class PackageManagerService extends IPackageManager.Stub
return false;
}
- @Override
- public boolean setSystemAppInstallState(String packageName, boolean installed, int userId) {
- enforceSystemOrPhoneCaller("setSystemAppInstallState");
- PackageSetting pkgSetting = mSettings.mPackages.get(packageName);
- // The target app should always be in system
- if (pkgSetting == null || !pkgSetting.isSystem()) {
- return false;
- }
- // Check if the install state is the same
- if (pkgSetting.getInstalled(userId) == installed) {
- return false;
- }
-
- long callingId = Binder.clearCallingIdentity();
- try {
- if (installed) {
- // install the app from uninstalled state
- installExistingPackageAsUser(
- packageName,
- userId,
- 0 /*installFlags*/,
- PackageManager.INSTALL_REASON_DEVICE_SETUP);
- return true;
- }
-
- // uninstall the app from installed state
- deletePackageVersioned(
- new VersionedPackage(packageName, PackageManager.VERSION_CODE_HIGHEST),
- new LegacyPackageDeleteObserver(null).getBinder(),
- userId,
- PackageManager.DELETE_SYSTEM_APP);
- return true;
- } finally {
- Binder.restoreCallingIdentity(callingId);
- }
- }
-
private void sendApplicationHiddenForUser(String packageName, PackageSetting pkgSetting,
int userId) {
final PackageRemovedInfo info = new PackageRemovedInfo(this);
@@ -14110,16 +14073,10 @@ public class PackageManagerService extends IPackageManager.Stub
@Override
public int installExistingPackageAsUser(String packageName, int userId, int installFlags,
int installReason) {
- final int callingUid = Binder.getCallingUid();
- if (mContext.checkCallingOrSelfPermission(android.Manifest.permission.INSTALL_PACKAGES)
- != PackageManager.PERMISSION_GRANTED
- && mContext.checkCallingOrSelfPermission(
- android.Manifest.permission.INSTALL_EXISTING_PACKAGES)
- != PackageManager.PERMISSION_GRANTED) {
- throw new SecurityException("Neither user " + callingUid + " nor current process has "
- + android.Manifest.permission.INSTALL_PACKAGES + ".");
- }
+ mContext.enforceCallingOrSelfPermission(android.Manifest.permission.INSTALL_PACKAGES,
+ null);
PackageSetting pkgSetting;
+ final int callingUid = Binder.getCallingUid();
mPermissionManager.enforceCrossUserPermission(callingUid, userId,
true /* requireFullPermission */, true /* checkShell */,
"installExistingPackage for user " + userId);
@@ -14263,7 +14220,7 @@ public class PackageManagerService extends IPackageManager.Stub
unactionedPackages.add(packageName);
continue;
}
- if (!canSuspendPackageForUserLocked(packageName, userId)) {
+ if (suspended && !canSuspendPackageForUserLocked(packageName, userId)) {
unactionedPackages.add(packageName);
continue;
}
@@ -14418,44 +14375,44 @@ public class PackageManagerService extends IPackageManager.Stub
@GuardedBy("mPackages")
private boolean canSuspendPackageForUserLocked(String packageName, int userId) {
if (isPackageDeviceAdmin(packageName, userId)) {
- Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
+ Slog.w(TAG, "Cannot suspend package \"" + packageName
+ "\": has an active device admin");
return false;
}
String activeLauncherPackageName = getActiveLauncherPackageName(userId);
if (packageName.equals(activeLauncherPackageName)) {
- Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
+ Slog.w(TAG, "Cannot suspend package \"" + packageName
+ "\": contains the active launcher");
return false;
}
if (packageName.equals(mRequiredInstallerPackage)) {
- Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
+ Slog.w(TAG, "Cannot suspend package \"" + packageName
+ "\": required for package installation");
return false;
}
if (packageName.equals(mRequiredUninstallerPackage)) {
- Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
+ Slog.w(TAG, "Cannot suspend package \"" + packageName
+ "\": required for package uninstallation");
return false;
}
if (packageName.equals(mRequiredVerifierPackage)) {
- Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
+ Slog.w(TAG, "Cannot suspend package \"" + packageName
+ "\": required for package verification");
return false;
}
if (packageName.equals(getDefaultDialerPackageName(userId))) {
- Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
+ Slog.w(TAG, "Cannot suspend package \"" + packageName
+ "\": is the default dialer");
return false;
}
if (mProtectedPackages.isPackageStateProtected(userId, packageName)) {
- Slog.w(TAG, "Cannot suspend/un-suspend package \"" + packageName
+ Slog.w(TAG, "Cannot suspend package \"" + packageName
+ "\": protected package");
return false;
}
@@ -17930,17 +17887,19 @@ public class PackageManagerService extends IPackageManager.Stub
final int uid = Binder.getCallingUid();
if (!isOrphaned(internalPackageName)
&& !isCallerAllowedToSilentlyUninstall(uid, internalPackageName)) {
- try {
- final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
- intent.setData(Uri.fromParts(PACKAGE_SCHEME, packageName, null));
- intent.putExtra(PackageInstaller.EXTRA_CALLBACK, observer.asBinder());
- observer.onUserActionRequired(intent);
- } catch (RemoteException re) {
- }
+ mHandler.post(() -> {
+ try {
+ final Intent intent = new Intent(Intent.ACTION_UNINSTALL_PACKAGE);
+ intent.setData(Uri.fromParts(PACKAGE_SCHEME, packageName, null));
+ intent.putExtra(PackageInstaller.EXTRA_CALLBACK, observer.asBinder());
+ observer.onUserActionRequired(intent);
+ } catch (RemoteException re) {
+ }
+ });
return;
}
final boolean deleteAllUsers = (deleteFlags & PackageManager.DELETE_ALL_USERS) != 0;
- final int[] users = deleteAllUsers ? sUserManager.getUserIds() : new int[]{ userId };
+ final int[] users = deleteAllUsers ? sUserManager.getUserIds() : new int[]{userId};
if (UserHandle.getUserId(uid) != userId || (deleteAllUsers && users.length > 1)) {
mContext.enforceCallingOrSelfPermission(
android.Manifest.permission.INTERACT_ACROSS_USERS_FULL,
@@ -17948,20 +17907,24 @@ public class PackageManagerService extends IPackageManager.Stub
}
if (isUserRestricted(userId, UserManager.DISALLOW_UNINSTALL_APPS)) {
- try {
- observer.onPackageDeleted(packageName,
- PackageManager.DELETE_FAILED_USER_RESTRICTED, null);
- } catch (RemoteException re) {
- }
+ mHandler.post(() -> {
+ try {
+ observer.onPackageDeleted(packageName,
+ PackageManager.DELETE_FAILED_USER_RESTRICTED, null);
+ } catch (RemoteException re) {
+ }
+ });
return;
}
if (!deleteAllUsers && getBlockUninstallForUser(internalPackageName, userId)) {
- try {
- observer.onPackageDeleted(packageName,
- PackageManager.DELETE_FAILED_OWNER_BLOCKED, null);
- } catch (RemoteException re) {
- }
+ mHandler.post(() -> {
+ try {
+ observer.onPackageDeleted(packageName,
+ PackageManager.DELETE_FAILED_OWNER_BLOCKED, null);
+ } catch (RemoteException re) {
+ }
+ });
return;
}
@@ -17972,56 +17935,53 @@ public class PackageManagerService extends IPackageManager.Stub
? "VERSION_CODE_HIGHEST" : versionCode));
}
// Queue up an async operation since the package deletion may take a little while.
- mHandler.post(new Runnable() {
- public void run() {
- mHandler.removeCallbacks(this);
- int returnCode;
- final PackageSetting ps = mSettings.mPackages.get(internalPackageName);
- boolean doDeletePackage = true;
- if (ps != null) {
- final boolean targetIsInstantApp =
- ps.getInstantApp(UserHandle.getUserId(callingUid));
- doDeletePackage = !targetIsInstantApp
- || canViewInstantApps;
- }
- if (doDeletePackage) {
- if (!deleteAllUsers) {
+ mHandler.post(() -> {
+ int returnCode;
+ final PackageSetting ps = mSettings.mPackages.get(internalPackageName);
+ boolean doDeletePackage = true;
+ if (ps != null) {
+ final boolean targetIsInstantApp =
+ ps.getInstantApp(UserHandle.getUserId(callingUid));
+ doDeletePackage = !targetIsInstantApp
+ || canViewInstantApps;
+ }
+ if (doDeletePackage) {
+ if (!deleteAllUsers) {
+ returnCode = deletePackageX(internalPackageName, versionCode,
+ userId, deleteFlags);
+ } else {
+ int[] blockUninstallUserIds = getBlockUninstallForUsers(
+ internalPackageName, users);
+ // If nobody is blocking uninstall, proceed with delete for all users
+ if (ArrayUtils.isEmpty(blockUninstallUserIds)) {
returnCode = deletePackageX(internalPackageName, versionCode,
userId, deleteFlags);
} else {
- int[] blockUninstallUserIds = getBlockUninstallForUsers(
- internalPackageName, users);
- // If nobody is blocking uninstall, proceed with delete for all users
- if (ArrayUtils.isEmpty(blockUninstallUserIds)) {
- returnCode = deletePackageX(internalPackageName, versionCode,
- userId, deleteFlags);
- } else {
- // Otherwise uninstall individually for users with blockUninstalls=false
- final int userFlags = deleteFlags & ~PackageManager.DELETE_ALL_USERS;
- for (int userId : users) {
- if (!ArrayUtils.contains(blockUninstallUserIds, userId)) {
- returnCode = deletePackageX(internalPackageName, versionCode,
- userId, userFlags);
- if (returnCode != PackageManager.DELETE_SUCCEEDED) {
- Slog.w(TAG, "Package delete failed for user " + userId
- + ", returnCode " + returnCode);
- }
+ // Otherwise uninstall individually for users with blockUninstalls=false
+ final int userFlags = deleteFlags & ~PackageManager.DELETE_ALL_USERS;
+ for (int userId1 : users) {
+ if (!ArrayUtils.contains(blockUninstallUserIds, userId1)) {
+ returnCode = deletePackageX(internalPackageName, versionCode,
+ userId1, userFlags);
+ if (returnCode != PackageManager.DELETE_SUCCEEDED) {
+ Slog.w(TAG, "Package delete failed for user " + userId1
+ + ", returnCode " + returnCode);
}
}
- // The app has only been marked uninstalled for certain users.
- // We still need to report that delete was blocked
- returnCode = PackageManager.DELETE_FAILED_OWNER_BLOCKED;
}
+ // The app has only been marked uninstalled for certain users.
+ // We still need to report that delete was blocked
+ returnCode = PackageManager.DELETE_FAILED_OWNER_BLOCKED;
}
- } else {
- returnCode = PackageManager.DELETE_FAILED_INTERNAL_ERROR;
}
- try {
- observer.onPackageDeleted(packageName, returnCode, null);
- } catch (RemoteException e) {
- Log.i(TAG, "Observer no longer exists.");
- } //end catch
- } //end run
+ } else {
+ returnCode = PackageManager.DELETE_FAILED_INTERNAL_ERROR;
+ }
+ try {
+ observer.onPackageDeleted(packageName, returnCode, null);
+ } catch (RemoteException e) {
+ Log.i(TAG, "Observer no longer exists.");
+ } //end catch
});
}
@@ -21107,6 +21067,9 @@ Slog.v(TAG, ":: stepped forward, applying functor at tag " + parser.getName());
public boolean isOrphaned(String packageName) {
// reader
synchronized (mPackages) {
+ if (!mPackages.containsKey(packageName)) {
+ return false;
+ }
return mSettings.isOrphaned(packageName);
}
}
diff --git a/services/core/java/com/android/server/pm/ShortcutService.java b/services/core/java/com/android/server/pm/ShortcutService.java
index 599e5a573437..b9c304890420 100644
--- a/services/core/java/com/android/server/pm/ShortcutService.java
+++ b/services/core/java/com/android/server/pm/ShortcutService.java
@@ -132,6 +132,7 @@ import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Consumer;
import java.util.function.Predicate;
@@ -1573,6 +1574,24 @@ public class ShortcutService extends IShortcutService.Stub {
"Ephemeral apps can't use ShortcutManager");
}
+ private void verifyShortcutInfoPackage(String callerPackage, ShortcutInfo si) {
+ if (si == null) {
+ return;
+ }
+ if (!Objects.equals(callerPackage, si.getPackage())) {
+ android.util.EventLog.writeEvent(0x534e4554, "109824443", -1, "");
+ throw new SecurityException("Shortcut package name mismatch");
+ }
+ }
+
+ private void verifyShortcutInfoPackages(
+ String callerPackage, List<ShortcutInfo> list) {
+ final int size = list.size();
+ for (int i = 0; i < size; i++) {
+ verifyShortcutInfoPackage(callerPackage, list.get(i));
+ }
+ }
+
// Overridden in unit tests to execute r synchronously.
void injectPostToHandler(Runnable r) {
mHandler.post(r);
@@ -1720,6 +1739,7 @@ public class ShortcutService extends IShortcutService.Stub {
verifyCaller(packageName, userId);
final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList();
+ verifyShortcutInfoPackages(packageName, newShortcuts);
final int size = newShortcuts.size();
final boolean unlimited = injectHasUnlimitedShortcutsApiCallsPermission(
@@ -1774,6 +1794,7 @@ public class ShortcutService extends IShortcutService.Stub {
verifyCaller(packageName, userId);
final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList();
+ verifyShortcutInfoPackages(packageName, newShortcuts);
final int size = newShortcuts.size();
final boolean unlimited = injectHasUnlimitedShortcutsApiCallsPermission(
@@ -1859,6 +1880,7 @@ public class ShortcutService extends IShortcutService.Stub {
verifyCaller(packageName, userId);
final List<ShortcutInfo> newShortcuts = (List<ShortcutInfo>) shortcutInfoList.getList();
+ verifyShortcutInfoPackages(packageName, newShortcuts);
final int size = newShortcuts.size();
final boolean unlimited = injectHasUnlimitedShortcutsApiCallsPermission(
@@ -1921,6 +1943,7 @@ public class ShortcutService extends IShortcutService.Stub {
Preconditions.checkNotNull(shortcut);
Preconditions.checkArgument(shortcut.isEnabled(), "Shortcut must be enabled");
verifyCaller(packageName, userId);
+ verifyShortcutInfoPackage(packageName, shortcut);
final Intent ret;
synchronized (mLock) {
@@ -1942,6 +1965,7 @@ public class ShortcutService extends IShortcutService.Stub {
private boolean requestPinItem(String packageName, int userId, ShortcutInfo shortcut,
AppWidgetProviderInfo appWidget, Bundle extras, IntentSender resultIntent) {
verifyCaller(packageName, userId);
+ verifyShortcutInfoPackage(packageName, shortcut);
final boolean ret;
synchronized (mLock) {
diff --git a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
index c9aa1ef1c007..1ae59cbea452 100644
--- a/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
+++ b/services/core/java/com/android/server/pm/permission/DefaultPermissionGrantPolicy.java
@@ -833,11 +833,11 @@ public final class DefaultPermissionGrantPolicy {
getSystemPackage(textClassifierPackageName);
if (textClassifierPackage != null
&& doesPackageSupportRuntimePermissions(textClassifierPackage)) {
- grantRuntimePermissions(textClassifierPackage, PHONE_PERMISSIONS, true, userId);
- grantRuntimePermissions(textClassifierPackage, SMS_PERMISSIONS, true, userId);
- grantRuntimePermissions(textClassifierPackage, CALENDAR_PERMISSIONS, true, userId);
- grantRuntimePermissions(textClassifierPackage, LOCATION_PERMISSIONS, true, userId);
- grantRuntimePermissions(textClassifierPackage, CONTACTS_PERMISSIONS, true, userId);
+ grantRuntimePermissions(textClassifierPackage, PHONE_PERMISSIONS, false, userId);
+ grantRuntimePermissions(textClassifierPackage, SMS_PERMISSIONS, false, userId);
+ grantRuntimePermissions(textClassifierPackage, CALENDAR_PERMISSIONS, false, userId);
+ grantRuntimePermissions(textClassifierPackage, LOCATION_PERMISSIONS, false, userId);
+ grantRuntimePermissions(textClassifierPackage, CONTACTS_PERMISSIONS, false, userId);
}
}
diff --git a/services/core/java/com/android/server/policy/PhoneWindowManager.java b/services/core/java/com/android/server/policy/PhoneWindowManager.java
index bd4e4ded818c..32825f74fee9 100644
--- a/services/core/java/com/android/server/policy/PhoneWindowManager.java
+++ b/services/core/java/com/android/server/policy/PhoneWindowManager.java
@@ -156,6 +156,7 @@ import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
import android.app.ActivityManagerInternal.SleepToken;
+import android.app.ActivityTaskManager;
import android.app.ActivityThread;
import android.app.AppOpsManager;
import android.app.IUiModeManager;
@@ -5761,12 +5762,6 @@ public class PhoneWindowManager implements WindowManagerPolicy {
mStatusBarController.updateVisibilityLw(false /*transientAllowed*/,
mLastSystemUiFlags, mLastSystemUiFlags);
}
- final boolean isKeyguardShowing = isStatusBarKeyguard() && !mKeyguardOccluded;
- if (statusBarExpanded && !isKeyguardShowing && mNavigationBar != null) {
- if (mNavigationBarController.setBarShowingLw(true)) {
- changes |= FINISH_LAYOUT_REDO_LAYOUT;
- }
- }
} else if (mTopFullscreenOpaqueWindowState != null) {
topIsFullscreen = topAppHidesStatusBar;
// The subtle difference between the window for mTopFullscreenOpaqueWindowState
@@ -7993,7 +7988,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
sendCloseSystemWindows();
Intent dock = createHomeDockIntent();
if (dock != null) {
- int result = ActivityManager.getService()
+ int result = ActivityTaskManager.getService()
.startActivityAsUser(null, null, dock,
dock.resolveTypeIfNeeded(mContext.getContentResolver()),
null, null, 0,
@@ -8004,7 +7999,7 @@ public class PhoneWindowManager implements WindowManagerPolicy {
}
}
}
- int result = ActivityManager.getService()
+ int result = ActivityTaskManager.getService()
.startActivityAsUser(null, null, mHomeIntent,
mHomeIntent.resolveTypeIfNeeded(mContext.getContentResolver()),
null, null, 0,
diff --git a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java
index 81a8c55c5aea..1e0b52adb2f4 100644
--- a/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java
+++ b/services/core/java/com/android/server/policy/keyguard/KeyguardServiceDelegate.java
@@ -8,6 +8,7 @@ import static com.android.server.wm.KeyguardServiceDelegateProto.SECURE;
import static com.android.server.wm.KeyguardServiceDelegateProto.SHOWING;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
@@ -213,7 +214,7 @@ public class KeyguardServiceDelegate {
// There are no longer any keyguard windows on secondary displays, so pass
// INVALID_DISPLAY. All that means is that showWhenLocked activities on
// secondary displays now get to show.
- ActivityManager.getService().setLockScreenShown(true /* keyguardShowing */,
+ ActivityTaskManager.getService().setLockScreenShown(true /* keyguardShowing */,
false /* aodShowing */, INVALID_DISPLAY);
} catch (RemoteException e) {
// Local call.
diff --git a/services/core/java/com/android/server/power/PowerManagerService.java b/services/core/java/com/android/server/power/PowerManagerService.java
index 697801f7787a..9468dd754619 100644
--- a/services/core/java/com/android/server/power/PowerManagerService.java
+++ b/services/core/java/com/android/server/power/PowerManagerService.java
@@ -219,8 +219,8 @@ public final class PowerManagerService extends SystemService
private static final int HALT_MODE_REBOOT = 1;
private static final int HALT_MODE_REBOOT_SAFE_MODE = 2;
- // Persistent property for last reboot reason
- private static final String LAST_REBOOT_PROPERTY = "persist.sys.boot.reason";
+ // property for last reboot reason
+ private static final String REBOOT_PROPERTY = "sys.boot.reason";
private final Context mContext;
private final ServiceThread mHandlerThread;
@@ -4398,7 +4398,7 @@ public final class PowerManagerService extends SystemService
final long ident = Binder.clearCallingIdentity();
try {
- return getLastShutdownReasonInternal(LAST_REBOOT_PROPERTY);
+ return getLastShutdownReasonInternal(REBOOT_PROPERTY);
} finally {
Binder.restoreCallingIdentity(ident);
}
diff --git a/services/core/java/com/android/server/search/SearchManagerService.java b/services/core/java/com/android/server/search/SearchManagerService.java
index c3fa82344941..bc1a12fac393 100644
--- a/services/core/java/com/android/server/search/SearchManagerService.java
+++ b/services/core/java/com/android/server/search/SearchManagerService.java
@@ -17,7 +17,9 @@
package com.android.server.search;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.ISearchManager;
import android.app.SearchManager;
import android.app.SearchableInfo;
@@ -307,7 +309,7 @@ public class SearchManagerService extends ISearchManager.Stub {
Intent intent = new Intent(VoiceInteractionService.SERVICE_INTERFACE);
intent.setComponent(comp);
- IActivityManager am = ActivityManager.getService();
+ IActivityTaskManager am = ActivityTaskManager.getService();
if (args != null) {
args.putInt(Intent.EXTRA_KEY_EVENT, android.view.KeyEvent.KEYCODE_ASSIST);
}
diff --git a/services/core/java/com/android/server/timedetector/SimpleTimeDetectorStrategy.java b/services/core/java/com/android/server/timedetector/SimpleTimeDetectorStrategy.java
new file mode 100644
index 000000000000..e5207cb81495
--- /dev/null
+++ b/services/core/java/com/android/server/timedetector/SimpleTimeDetectorStrategy.java
@@ -0,0 +1,57 @@
+/*
+ * 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.server.timedetector;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.app.AlarmManager;
+import android.app.timedetector.TimeSignal;
+import android.util.Slog;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
+/**
+ * A placeholder implementation of TimeDetectorStrategy that passes NITZ suggestions immediately
+ * to {@link AlarmManager}.
+ */
+public final class SimpleTimeDetectorStrategy implements TimeDetectorStrategy {
+
+ private final static String TAG = "timedetector.SimpleTimeDetectorStrategy";
+
+ private Callback mHelper;
+
+ @Override
+ public void initialize(@NonNull Callback callback) {
+ mHelper = callback;
+ }
+
+ @Override
+ public void suggestTime(@NonNull TimeSignal timeSignal) {
+ if (!TimeSignal.SOURCE_ID_NITZ.equals(timeSignal.getSourceId())) {
+ Slog.w(TAG, "Ignoring signal from unknown source: " + timeSignal);
+ return;
+ }
+
+ mHelper.setTime(timeSignal.getUtcTime());
+ }
+
+ @Override
+ public void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @Nullable String[] args) {
+ // No state to dump.
+ }
+}
diff --git a/services/core/java/com/android/server/timedetector/TimeDetectorService.java b/services/core/java/com/android/server/timedetector/TimeDetectorService.java
index 0b63e29e149a..efd49b5a2c45 100644
--- a/services/core/java/com/android/server/timedetector/TimeDetectorService.java
+++ b/services/core/java/com/android/server/timedetector/TimeDetectorService.java
@@ -16,15 +16,19 @@
package com.android.server.timedetector;
-import com.android.internal.util.DumpUtils;
-import com.android.server.SystemService;
-
+import android.annotation.NonNull;
+import android.annotation.Nullable;
import android.app.timedetector.ITimeDetectorService;
+import android.app.timedetector.TimeSignal;
import android.content.Context;
-import android.util.Slog;
+
+import com.android.internal.annotations.VisibleForTesting;
+import com.android.internal.util.DumpUtils;
+import com.android.server.SystemService;
import java.io.FileDescriptor;
import java.io.PrintWriter;
+import java.util.Objects;
public final class TimeDetectorService extends ITimeDetectorService.Stub {
@@ -47,26 +51,36 @@ public final class TimeDetectorService extends ITimeDetectorService.Stub {
}
private final Context mContext;
+ private final TimeDetectorStrategy mTimeDetectorStrategy;
private static TimeDetectorService create(Context context) {
- return new TimeDetectorService(context);
+ TimeDetectorStrategy timeDetector = new SimpleTimeDetectorStrategy();
+ timeDetector.initialize(new TimeDetectorStrategyCallbackImpl(context));
+ return new TimeDetectorService(context, timeDetector);
}
- public TimeDetectorService(Context context) {
- mContext = context;
+ @VisibleForTesting
+ public TimeDetectorService(@NonNull Context context,
+ @NonNull TimeDetectorStrategy timeDetectorStrategy) {
+ mContext = Objects.requireNonNull(context);
+ mTimeDetectorStrategy = Objects.requireNonNull(timeDetectorStrategy);
}
@Override
- public void stubbedCall() {
- // Empty call for initial tests.
- Slog.d(TAG, "stubbedCall() called");
- // TODO(nfuller): Remove when there are real methods.
+ public void suggestTime(@NonNull TimeSignal timeSignal) {
+ enforceSetTimePermission();
+ mTimeDetectorStrategy.suggestTime(timeSignal);
}
@Override
- protected void dump(FileDescriptor fd, PrintWriter pw, String[] args) {
+ protected void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw,
+ @Nullable String[] args) {
if (!DumpUtils.checkDumpPermission(mContext, TAG, pw)) return;
- // TODO(nfuller): Implement when there is state.
+ mTimeDetectorStrategy.dump(fd, pw, args);
+ }
+
+ private void enforceSetTimePermission() {
+ mContext.enforceCallingPermission(android.Manifest.permission.SET_TIME, "set time");
}
} \ No newline at end of file
diff --git a/services/core/java/com/android/server/timedetector/TimeDetectorStrategy.java b/services/core/java/com/android/server/timedetector/TimeDetectorStrategy.java
new file mode 100644
index 000000000000..5cb2eed0932e
--- /dev/null
+++ b/services/core/java/com/android/server/timedetector/TimeDetectorStrategy.java
@@ -0,0 +1,53 @@
+/*
+ * 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.server.timedetector;
+
+import android.annotation.NonNull;
+import android.annotation.Nullable;
+import android.app.timedetector.TimeSignal;
+import android.util.TimestampedValue;
+
+import java.io.FileDescriptor;
+import java.io.PrintWriter;
+
+/**
+ * The interface for classes that implement the time detection algorithm used by the
+ * TimeDetectorService.
+ *
+ * @hide
+ */
+public interface TimeDetectorStrategy {
+
+ interface Callback {
+ void setTime(TimestampedValue<Long> time);
+ }
+
+ void initialize(@NonNull Callback callback);
+ void suggestTime(@NonNull TimeSignal timeSignal);
+ void dump(@NonNull FileDescriptor fd, @NonNull PrintWriter pw, @Nullable String[] args);
+
+ // Utility methods below are to be moved to a better home when one becomes more obvious.
+
+ /**
+ * Adjusts the supplied time value by applying the difference between the reference time
+ * supplied and the reference time associated with the time.
+ */
+ static long getTimeAt(@NonNull TimestampedValue<Long> timeValue, long referenceClockMillisNow) {
+ return (referenceClockMillisNow - timeValue.getReferenceTimeMillis())
+ + timeValue.getValue();
+ }
+}
diff --git a/services/core/java/com/android/server/timedetector/TimeDetectorStrategyCallbackImpl.java b/services/core/java/com/android/server/timedetector/TimeDetectorStrategyCallbackImpl.java
new file mode 100644
index 000000000000..568d73aed50d
--- /dev/null
+++ b/services/core/java/com/android/server/timedetector/TimeDetectorStrategyCallbackImpl.java
@@ -0,0 +1,58 @@
+/*
+ * 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.server.timedetector;
+
+import android.annotation.NonNull;
+import android.app.AlarmManager;
+import android.content.Context;
+import android.os.PowerManager;
+import android.os.SystemClock;
+import android.util.Slog;
+import android.util.TimestampedValue;
+
+/**
+ * The real implementation of {@link TimeDetectorStrategy.Callback} used on device.
+ */
+public class TimeDetectorStrategyCallbackImpl implements TimeDetectorStrategy.Callback {
+
+ private final static String TAG = "timedetector.TimeDetectorStrategyCallbackImpl";
+
+ @NonNull private PowerManager.WakeLock mWakeLock;
+ @NonNull private AlarmManager mAlarmManager;
+
+ public TimeDetectorStrategyCallbackImpl(Context context) {
+ PowerManager powerManager = context.getSystemService(PowerManager.class);
+
+ mWakeLock = powerManager.newWakeLock(PowerManager.PARTIAL_WAKE_LOCK, TAG);
+
+ mAlarmManager = context.getSystemService(AlarmManager.class);
+ }
+
+ @Override
+ public void setTime(TimestampedValue<Long> time) {
+ mWakeLock.acquire();
+ try {
+ long elapsedRealtimeMillis = SystemClock.elapsedRealtime();
+ long currentTimeMillis = TimeDetectorStrategy.getTimeAt(time, elapsedRealtimeMillis);
+ Slog.d(TAG, "Setting system clock using time=" + time
+ + ", elapsedRealtimeMillis=" + elapsedRealtimeMillis);
+ mAlarmManager.setTime(currentTimeMillis);
+ } finally {
+ mWakeLock.release();
+ }
+ }
+}
diff --git a/services/core/java/com/android/server/wm/AppWindowToken.java b/services/core/java/com/android/server/wm/AppWindowToken.java
index e45de459b0a7..08d0ae9dcdd8 100644
--- a/services/core/java/com/android/server/wm/AppWindowToken.java
+++ b/services/core/java/com/android/server/wm/AppWindowToken.java
@@ -1334,8 +1334,20 @@ class AppWindowToken extends WindowToken implements WindowManagerService.AppFree
// for the next re-entry into PiP (assuming the activity is not hidden or destroyed)
final TaskStack pinnedStack = mDisplayContent.getPinnedStack();
if (pinnedStack != null) {
+ final Rect stackBounds;
+ if (pinnedStack.lastAnimatingBoundsWasToFullscreen()) {
+ // We are animating the bounds, use the pre-animation bounds to save the snap
+ // fraction
+ stackBounds = pinnedStack.mPreAnimationBounds;
+ } else {
+ // We skip the animation if the fullscreen configuration is not compatible, so
+ // use the current bounds to calculate the saved snap fraction instead
+ // (see PinnedActivityStack.skipResizeAnimation())
+ stackBounds = mTmpRect;
+ pinnedStack.getBounds(stackBounds);
+ }
mDisplayContent.mPinnedStackControllerLocked.saveReentrySnapFraction(this,
- pinnedStack.mPreAnimationBounds);
+ stackBounds);
}
}
}
diff --git a/services/core/java/com/android/server/wm/DisplayContent.java b/services/core/java/com/android/server/wm/DisplayContent.java
index b0e6208fdff3..599cdcfb2754 100644
--- a/services/core/java/com/android/server/wm/DisplayContent.java
+++ b/services/core/java/com/android/server/wm/DisplayContent.java
@@ -16,7 +16,7 @@
package com.android.server.wm;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
import static android.app.WindowConfiguration.WINDOWING_MODE_FREEFORM;
diff --git a/services/core/java/com/android/server/wm/DragAndDropPermissionsHandler.java b/services/core/java/com/android/server/wm/DragAndDropPermissionsHandler.java
index 70478fe677ed..51d5eea14b44 100644
--- a/services/core/java/com/android/server/wm/DragAndDropPermissionsHandler.java
+++ b/services/core/java/com/android/server/wm/DragAndDropPermissionsHandler.java
@@ -17,6 +17,7 @@
package com.android.server.wm;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.content.ClipData;
import android.net.Uri;
import android.os.Binder;
@@ -61,7 +62,7 @@ class DragAndDropPermissionsHandler extends IDragAndDropPermissions.Stub
mActivityToken = activityToken;
// Will throw if Activity is not found.
- IBinder permissionOwner = ActivityManager.getService().
+ IBinder permissionOwner = ActivityTaskManager.getService().
getUriPermissionOwnerForActivity(mActivityToken);
doTake(permissionOwner);
@@ -101,7 +102,7 @@ class DragAndDropPermissionsHandler extends IDragAndDropPermissions.Stub
IBinder permissionOwner = null;
if (mActivityToken != null) {
try {
- permissionOwner = ActivityManager.getService().
+ permissionOwner = ActivityTaskManager.getService().
getUriPermissionOwnerForActivity(mActivityToken);
} catch (Exception e) {
// Activity is destroyed, permissions already revoked.
diff --git a/services/core/java/com/android/server/wm/PinnedStackController.java b/services/core/java/com/android/server/wm/PinnedStackController.java
index 5f1916d4e523..278d2b81991e 100644
--- a/services/core/java/com/android/server/wm/PinnedStackController.java
+++ b/services/core/java/com/android/server/wm/PinnedStackController.java
@@ -589,6 +589,7 @@ class PinnedStackController {
pw.println(prefix + " mImeHeight=" + mImeHeight);
pw.println(prefix + " mIsShelfShowing=" + mIsShelfShowing);
pw.println(prefix + " mShelfHeight=" + mShelfHeight);
+ pw.println(prefix + " mReentrySnapFraction=" + mReentrySnapFraction);
pw.println(prefix + " mIsMinimized=" + mIsMinimized);
if (mActions.isEmpty()) {
pw.println(prefix + " mActions=[]");
@@ -601,6 +602,7 @@ class PinnedStackController {
}
pw.println(prefix + " ]");
}
+ pw.println(prefix + " mDisplayInfo=" + mDisplayInfo);
}
void writeToProto(ProtoOutputStream proto, long fieldId) {
diff --git a/services/core/java/com/android/server/wm/Task.java b/services/core/java/com/android/server/wm/Task.java
index f87538a2a890..2da77a15b956 100644
--- a/services/core/java/com/android/server/wm/Task.java
+++ b/services/core/java/com/android/server/wm/Task.java
@@ -16,7 +16,7 @@
package com.android.server.wm;
-import static android.app.ActivityManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION;
+import static android.app.ActivityTaskManager.RESIZE_MODE_SYSTEM_SCREEN_ROTATION;
import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_LANDSCAPE_ONLY;
import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PORTRAIT_ONLY;
import static android.content.pm.ActivityInfo.RESIZE_MODE_FORCE_RESIZABLE_PRESERVE_ORIENTATION;
@@ -218,7 +218,7 @@ class Task extends WindowContainer<AppWindowToken> {
}
}
- /** @see com.android.server.am.ActivityManagerService#positionTaskInStack(int, int, int). */
+ /** @see com.android.server.am.ActivityTaskManagerService#positionTaskInStack(int, int, int). */
void positionAt(int position) {
mStack.positionChildAt(position, this, false /* includingParents */);
}
@@ -298,7 +298,7 @@ class Task extends WindowContainer<AppWindowToken> {
/**
* Sets the bounds used to calculate the insets. See
- * {@link android.app.IActivityManager#resizeDockedStack} why this is needed.
+ * {@link android.app.IActivityTaskManager#resizeDockedStack} why this is needed.
*/
void setTempInsetBounds(Rect tempInsetBounds) {
if (tempInsetBounds != null) {
@@ -310,7 +310,7 @@ class Task extends WindowContainer<AppWindowToken> {
/**
* Gets the bounds used to calculate the insets. See
- * {@link android.app.IActivityManager#resizeDockedStack} why this is needed.
+ * {@link android.app.IActivityTaskManager#resizeDockedStack} why this is needed.
*/
void getTempInsetBounds(Rect out) {
out.set(mTempInsetBounds);
diff --git a/services/core/java/com/android/server/wm/TaskPositioner.java b/services/core/java/com/android/server/wm/TaskPositioner.java
index c85e1f9ca90f..30f46a05cb72 100644
--- a/services/core/java/com/android/server/wm/TaskPositioner.java
+++ b/services/core/java/com/android/server/wm/TaskPositioner.java
@@ -16,8 +16,8 @@
package com.android.server.wm;
-import static android.app.ActivityManager.RESIZE_MODE_USER;
-import static android.app.ActivityManager.RESIZE_MODE_USER_FORCED;
+import static android.app.ActivityTaskManager.RESIZE_MODE_USER;
+import static android.app.ActivityTaskManager.RESIZE_MODE_USER_FORCED;
import static android.os.Trace.TRACE_TAG_WINDOW_MANAGER;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_ORIENTATION;
import static com.android.server.wm.WindowManagerDebugConfig.DEBUG_TASK_POSITIONING;
@@ -30,6 +30,7 @@ import static com.android.server.wm.WindowState.MINIMUM_VISIBLE_WIDTH_IN_DP;
import android.annotation.IntDef;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.graphics.Point;
import android.graphics.Rect;
import android.os.Looper;
@@ -94,7 +95,7 @@ class TaskPositioner {
static final float MIN_ASPECT = 1.2f;
private final WindowManagerService mService;
- private final IActivityManager mActivityManager;
+ private final IActivityTaskManager mActivityManager;
private WindowPositionerEventReceiver mInputEventReceiver;
private Display mDisplay;
private final DisplayMetrics mDisplayMetrics = new DisplayMetrics();
@@ -219,14 +220,14 @@ class TaskPositioner {
}
@VisibleForTesting
- TaskPositioner(WindowManagerService service, IActivityManager activityManager) {
+ TaskPositioner(WindowManagerService service, IActivityTaskManager activityManager) {
mService = service;
mActivityManager = activityManager;
}
/** Use {@link #create(WindowManagerService)} instead **/
TaskPositioner(WindowManagerService service) {
- this(service, service.mActivityManager);
+ this(service, service.mActivityTaskManager);
}
@VisibleForTesting
diff --git a/services/core/java/com/android/server/wm/TaskPositioningController.java b/services/core/java/com/android/server/wm/TaskPositioningController.java
index a3f4ee80dfcb..7d36650f375b 100644
--- a/services/core/java/com/android/server/wm/TaskPositioningController.java
+++ b/services/core/java/com/android/server/wm/TaskPositioningController.java
@@ -21,6 +21,7 @@ import static com.android.server.wm.WindowManagerDebugConfig.TAG_WM;
import android.annotation.Nullable;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.os.RemoteException;
import android.os.Handler;
import android.os.Looper;
@@ -38,7 +39,7 @@ class TaskPositioningController {
private final WindowManagerService mService;
private final InputManagerService mInputManager;
private final InputMonitor mInputMonitor;
- private final IActivityManager mActivityManager;
+ private final IActivityTaskManager mActivityManager;
private final Handler mHandler;
@GuardedBy("WindowManagerSerivce.mWindowMap")
@@ -53,7 +54,7 @@ class TaskPositioningController {
}
TaskPositioningController(WindowManagerService service, InputManagerService inputManager,
- InputMonitor inputMonitor, IActivityManager activityManager, Looper looper) {
+ InputMonitor inputMonitor, IActivityTaskManager activityManager, Looper looper) {
mService = service;
mInputMonitor = inputMonitor;
mInputManager = inputManager;
diff --git a/services/core/java/com/android/server/wm/TaskSnapshotController.java b/services/core/java/com/android/server/wm/TaskSnapshotController.java
index f17bbb95cfe1..733a2486215d 100644
--- a/services/core/java/com/android/server/wm/TaskSnapshotController.java
+++ b/services/core/java/com/android/server/wm/TaskSnapshotController.java
@@ -28,6 +28,7 @@ import android.app.ActivityManager.TaskSnapshot;
import android.content.pm.PackageManager;
import android.graphics.Bitmap;
import android.graphics.GraphicBuffer;
+import android.graphics.PixelFormat;
import android.graphics.Rect;
import android.os.Environment;
import android.os.Handler;
@@ -266,7 +267,7 @@ class TaskSnapshotController {
final GraphicBuffer buffer = SurfaceControl.captureLayers(
task.getSurfaceControl().getHandle(), mTmpRect, scaleFraction);
-
+ final boolean isWindowTranslucent = mainWindow.getAttrs().format != PixelFormat.OPAQUE;
if (buffer == null || buffer.getWidth() <= 1 || buffer.getHeight() <= 1) {
if (DEBUG_SCREENSHOT) {
Slog.w(TAG_WM, "Failed to take screenshot for " + task);
@@ -276,7 +277,7 @@ class TaskSnapshotController {
return new TaskSnapshot(buffer, top.getConfiguration().orientation,
getInsets(mainWindow), isLowRamDevice /* reduced */, scaleFraction /* scale */,
true /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task),
- !top.fillsParent());
+ !top.fillsParent() || isWindowTranslucent);
}
private boolean shouldDisableSnapshots() {
@@ -363,11 +364,13 @@ class TaskSnapshotController {
if (hwBitmap == null) {
return null;
}
+ // Note, the app theme snapshot is never translucent because we enforce a non-translucent
+ // color above
return new TaskSnapshot(hwBitmap.createGraphicBufferHandle(),
topChild.getConfiguration().orientation, mainWindow.mStableInsets,
ActivityManager.isLowRamDeviceStatic() /* reduced */, 1.0f /* scale */,
false /* isRealSnapshot */, task.getWindowingMode(), getSystemUiVisibility(task),
- !topChild.fillsParent());
+ false);
}
/**
diff --git a/services/core/java/com/android/server/wm/TaskStack.java b/services/core/java/com/android/server/wm/TaskStack.java
index 76c9c262cd76..e6db6d9919e8 100644
--- a/services/core/java/com/android/server/wm/TaskStack.java
+++ b/services/core/java/com/android/server/wm/TaskStack.java
@@ -16,8 +16,8 @@
package com.android.server.wm;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_BOTTOM_OR_RIGHT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_RECENTS;
@@ -1614,7 +1614,7 @@ public class TaskStack extends WindowContainer<Task> implements
}
try {
- mService.mActivityManager.resizePinnedStack(stackBounds, tempTaskBounds);
+ mService.mActivityTaskManager.resizePinnedStack(stackBounds, tempTaskBounds);
} catch (RemoteException e) {
// I don't believe you.
}
@@ -1647,7 +1647,7 @@ public class TaskStack extends WindowContainer<Task> implements
if (inPinnedWindowingMode()) {
try {
- mService.mActivityManager.notifyPinnedStackAnimationStarted();
+ mService.mActivityTaskManager.notifyPinnedStackAnimationStarted();
} catch (RemoteException e) {
// I don't believe you...
}
@@ -1689,9 +1689,9 @@ public class TaskStack extends WindowContainer<Task> implements
}
try {
- mService.mActivityManager.notifyPinnedStackAnimationEnded();
+ mService.mActivityTaskManager.notifyPinnedStackAnimationEnded();
if (moveToFullscreen) {
- mService.mActivityManager.moveTasksToFullscreenStack(mStackId,
+ mService.mActivityTaskManager.moveTasksToFullscreenStack(mStackId,
true /* onTop */);
}
} catch (RemoteException e) {
diff --git a/services/core/java/com/android/server/wm/WindowManagerService.java b/services/core/java/com/android/server/wm/WindowManagerService.java
index 947c937f52ec..c1753c0cc1d3 100644
--- a/services/core/java/com/android/server/wm/WindowManagerService.java
+++ b/services/core/java/com/android/server/wm/WindowManagerService.java
@@ -21,7 +21,7 @@ import static android.Manifest.permission.MANAGE_APP_TOKENS;
import static android.Manifest.permission.READ_FRAME_BUFFER;
import static android.Manifest.permission.REGISTER_WINDOW_MANAGER_LISTENERS;
import static android.Manifest.permission.RESTRICTED_VR_ACCESS;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.app.AppOpsManager.OP_SYSTEM_ALERT_WINDOW;
import static android.app.StatusBarManager.DISABLE_MASK;
import static android.app.admin.DevicePolicyManager.ACTION_DEVICE_POLICY_MANAGER_STATE_CHANGED;
@@ -116,9 +116,11 @@ import android.annotation.Nullable;
import android.app.ActivityManager;
import android.app.ActivityManager.TaskSnapshot;
import android.app.ActivityManagerInternal;
+import android.app.ActivityTaskManager;
import android.app.ActivityThread;
import android.app.AppOpsManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.IAssistDataReceiver;
import android.app.admin.DevicePolicyCache;
import android.content.BroadcastReceiver;
@@ -427,6 +429,8 @@ public class WindowManagerService extends IWindowManager.Stub
final WindowManagerPolicy mPolicy;
final IActivityManager mActivityManager;
+ // TODO: Probably not needed once activities are fully in WM.
+ final IActivityTaskManager mActivityTaskManager;
final ActivityManagerInternal mAmInternal;
final AppOpsManager mAppOps;
@@ -859,7 +863,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
if (atoken.mLaunchTaskBehind) {
try {
- mActivityManager.notifyLaunchTaskBehindComplete(atoken.token);
+ mActivityTaskManager.notifyLaunchTaskBehindComplete(atoken.token);
} catch (RemoteException e) {
}
atoken.mLaunchTaskBehind = false;
@@ -876,7 +880,7 @@ public class WindowManagerService extends IWindowManager.Stub
} else {
atoken.mEnteringAnimation = false;
try {
- mActivityManager.notifyEnterAnimationComplete(atoken.token);
+ mActivityTaskManager.notifyEnterAnimationComplete(atoken.token);
} catch (RemoteException e) {
}
}
@@ -1009,6 +1013,7 @@ public class WindowManagerService extends IWindowManager.Stub
AnimationThread.getHandler(), animationHandler);
mActivityManager = ActivityManager.getService();
+ mActivityTaskManager = ActivityTaskManager.getService();
mAmInternal = LocalServices.getService(ActivityManagerInternal.class);
mAppOps = (AppOpsManager)context.getSystemService(Context.APP_OPS_SERVICE);
AppOpsManager.OnOpChangedInternalListener opListener =
@@ -1066,7 +1071,7 @@ public class WindowManagerService extends IWindowManager.Stub
com.android.internal.R.bool.config_allowTheaterModeWakeFromWindowLayout);
mTaskPositioningController = new TaskPositioningController(
- this, mInputManager, mInputMonitor, mActivityManager, mH.getLooper());
+ this, mInputManager, mInputMonitor, mActivityTaskManager, mH.getLooper());
mDragDropController = new DragDropController(this, mH.getLooper());
LocalServices.addService(WindowManagerInternal.class, new LocalService());
@@ -4372,7 +4377,7 @@ public class WindowManagerService extends IWindowManager.Stub
*/
void sendNewConfiguration(int displayId) {
try {
- final boolean configUpdated = mActivityManager.updateDisplayOverrideConfiguration(
+ final boolean configUpdated = mActivityTaskManager.updateDisplayOverrideConfiguration(
null /* values */, displayId);
if (!configUpdated) {
// Something changed (E.g. device rotation), but no configuration update is needed.
@@ -4527,7 +4532,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
try {
- mActivityManager.updateConfiguration(null);
+ mActivityTaskManager.updateConfiguration(null);
} catch (RemoteException e) {
}
@@ -4538,7 +4543,7 @@ public class WindowManagerService extends IWindowManager.Stub
}
try {
- mActivityManager.updateConfiguration(null);
+ mActivityTaskManager.updateConfiguration(null);
} catch (RemoteException e) {
}
@@ -4893,7 +4898,7 @@ public class WindowManagerService extends IWindowManager.Stub
case NOTIFY_ACTIVITY_DRAWN:
try {
- mActivityManager.notifyActivityDrawn((IBinder) msg.obj);
+ mActivityTaskManager.notifyActivityDrawn((IBinder) msg.obj);
} catch (RemoteException e) {
}
break;
diff --git a/services/core/java/com/android/server/wm/WindowState.java b/services/core/java/com/android/server/wm/WindowState.java
index 0154e0aad8d4..cbe30cf65c94 100644
--- a/services/core/java/com/android/server/wm/WindowState.java
+++ b/services/core/java/com/android/server/wm/WindowState.java
@@ -16,7 +16,7 @@
package com.android.server.wm;
-import static android.app.ActivityManager.StackId.INVALID_STACK_ID;
+import static android.app.ActivityTaskManager.INVALID_STACK_ID;
import static android.app.AppOpsManager.MODE_ALLOWED;
import static android.app.AppOpsManager.MODE_DEFAULT;
import static android.app.AppOpsManager.OP_NONE;
@@ -445,7 +445,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
/**
* Usually empty. Set to the task's tempInsetFrame. See
- *{@link android.app.IActivityManager#resizeDockedStack}.
+ *{@link android.app.IActivityTaskManager#resizeDockedStack}.
*/
private final Rect mInsetFrame = new Rect();
@@ -2448,7 +2448,7 @@ class WindowState extends WindowContainer<WindowState> implements WindowManagerP
try {
// Note: this calls into ActivityManager, so we must *not* hold the window
// manager lock while calling this.
- mService.mActivityManager.setSplitScreenResizing(false);
+ mService.mActivityTaskManager.setSplitScreenResizing(false);
} catch (RemoteException e) {
// Local call, shouldn't return RemoteException.
throw e.rethrowAsRuntimeException();
diff --git a/services/core/jni/com_android_server_AlarmManagerService.cpp b/services/core/jni/com_android_server_AlarmManagerService.cpp
index 47350c11f958..921eed98d0a8 100644
--- a/services/core/jni/com_android_server_AlarmManagerService.cpp
+++ b/services/core/jni/com_android_server_AlarmManagerService.cpp
@@ -81,6 +81,7 @@ public:
int set(int type, struct timespec *ts);
int setTime(struct timeval *tv);
int waitForAlarm();
+ int getTime(int type, struct itimerspec *spec);
private:
const TimerFds fds;
@@ -118,6 +119,16 @@ int AlarmImpl::set(int type, struct timespec *ts)
return timerfd_settime(fds[type], TFD_TIMER_ABSTIME, &spec, NULL);
}
+int AlarmImpl::getTime(int type, struct itimerspec *spec)
+{
+ if (static_cast<size_t>(type) > ANDROID_ALARM_TYPE_COUNT) {
+ errno = EINVAL;
+ return -1;
+ }
+
+ return timerfd_gettime(fds[type], spec);
+}
+
int AlarmImpl::setTime(struct timeval *tv)
{
struct rtc_time rtc;
@@ -379,6 +390,23 @@ static jlong android_server_AlarmManagerService_init(JNIEnv*, jobject)
return reinterpret_cast<jlong>(ret);
}
+static jlong android_server_AlarmManagerService_getNextAlarm(JNIEnv*, jobject, jlong nativeData, jint type)
+{
+ AlarmImpl *impl = reinterpret_cast<AlarmImpl *>(nativeData);
+ struct itimerspec spec;
+ memset(&spec, 0, sizeof(spec));
+ const int result = impl->getTime(type, &spec);
+ if (result < 0)
+ {
+ ALOGE("timerfd_gettime() failed for fd %d: %s\n", static_cast<int>(type), strerror(errno));
+ return result;
+ }
+ struct timespec nextTimespec = spec.it_value;
+ long long millis = nextTimespec.tv_sec * 1000LL;
+ millis += (nextTimespec.tv_nsec / 1000000LL);
+ return static_cast<jlong>(millis);
+}
+
static void android_server_AlarmManagerService_close(JNIEnv*, jobject, jlong nativeData)
{
AlarmImpl *impl = reinterpret_cast<AlarmImpl *>(nativeData);
@@ -429,6 +457,7 @@ static const JNINativeMethod sMethods[] = {
{"waitForAlarm", "(J)I", (void*)android_server_AlarmManagerService_waitForAlarm},
{"setKernelTime", "(JJ)I", (void*)android_server_AlarmManagerService_setKernelTime},
{"setKernelTimezone", "(JI)I", (void*)android_server_AlarmManagerService_setKernelTimezone},
+ {"getNextAlarm", "(JI)J", (void*)android_server_AlarmManagerService_getNextAlarm},
};
int register_android_server_AlarmManagerService(JNIEnv* env)
diff --git a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
index 288a54411088..414cf478f84d 100644
--- a/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
+++ b/services/devicepolicy/java/com/android/server/devicepolicy/DevicePolicyManagerService.java
@@ -90,10 +90,12 @@ import android.annotation.UserIdInt;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManagerInternal;
+import android.app.ActivityTaskManager;
import android.app.ActivityThread;
import android.app.AlarmManager;
import android.app.AppGlobals;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.IApplicationThread;
import android.app.IServiceConnection;
import android.app.Notification;
@@ -1865,6 +1867,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
return ActivityManager.getService();
}
+ IActivityTaskManager getIActivityTaskManager() {
+ return ActivityTaskManager.getService();
+ }
+
ActivityManagerInternal getActivityManagerInternal() {
return LocalServices.getService(ActivityManagerInternal.class);
}
@@ -2354,8 +2360,12 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
final String value = Boolean.toString(hasDeviceOwner);
mInjector.systemPropertiesSet(PROPERTY_DEVICE_OWNER_PRESENT, value);
Slog.i(LOG_TAG, "Set ro.device_owner property to " + value);
+ }
+ }
- if (hasDeviceOwner && mInjector.securityLogGetLoggingEnabledProperty()) {
+ private void maybeStartSecurityLogMonitorOnActivityManagerReady() {
+ synchronized (getLockObject()) {
+ if (mInjector.securityLogIsLoggingEnabled()) {
mSecurityLogMonitor.start();
mInjector.runCryptoSelfTest();
maybePauseDeviceWideLoggingLocked();
@@ -3282,8 +3292,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
private void updateLockTaskFeaturesLocked(int flags, int userId) {
long ident = mInjector.binderClearCallingIdentity();
try {
- mInjector.getIActivityManager()
- .updateLockTaskFeatures(userId, flags);
+ mInjector.getIActivityTaskManager().updateLockTaskFeatures(userId, flags);
} catch (RemoteException e) {
// Not gonna happen.
} finally {
@@ -3354,6 +3363,9 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
loadAdminDataAsync();
mOwners.systemReady();
break;
+ case SystemService.PHASE_ACTIVITY_MANAGER_READY:
+ maybeStartSecurityLogMonitorOnActivityManagerReady();
+ break;
case SystemService.PHASE_BOOT_COMPLETED:
ensureDeviceOwnerUserStarted(); // TODO Consider better place to do this.
break;
@@ -5183,6 +5195,12 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
}
+ private void enforceDeviceOwner(ComponentName who) {
+ synchronized (getLockObject()) {
+ getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
+ }
+ }
+
private void enforceProfileOrDeviceOwner(ComponentName who) {
synchronized (getLockObject()) {
getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
@@ -5357,9 +5375,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
} else {
// Caller provided - check it is the device owner.
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
}
}
@@ -6367,9 +6383,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setRecommendedGlobalProxy(ComponentName who, ProxyInfo proxyInfo) {
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
long token = mInjector.binderClearCallingIdentity();
try {
ConnectivityManager connectivityManager = (ConnectivityManager)
@@ -7722,11 +7736,10 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setProfileName(ComponentName who, String profileName) {
Preconditions.checkNotNull(who, "ComponentName is null");
- int userId = UserHandle.getCallingUserId();
- // Check if this is the profile owner (includes device owner).
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
+ enforceProfileOrDeviceOwner(who);
- long id = mInjector.binderClearCallingIdentity();
+ final int userId = UserHandle.getCallingUserId();
+ final long id = mInjector.binderClearCallingIdentity();
try {
mUserManager.setUserName(userId, profileName);
} finally {
@@ -8191,9 +8204,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public void setDefaultSmsApplication(ComponentName admin, String packageName) {
Preconditions.checkNotNull(admin, "ComponentName is null");
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(admin);
mInjector.binderWithCleanCallingIdentity(() ->
SmsApplication.setDefaultApplication(packageName, mContext));
}
@@ -8980,10 +8991,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
public boolean removeUser(ComponentName who, UserHandle userHandle) {
Preconditions.checkNotNull(who, "ComponentName is null");
Preconditions.checkNotNull(userHandle, "UserHandle is null");
-
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
final int callingUserId = mInjector.userHandleGetCallingUserId();
final long id = mInjector.binderClearCallingIdentity();
@@ -9043,10 +9051,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
public int startUserInBackground(ComponentName who, UserHandle userHandle) {
Preconditions.checkNotNull(who, "ComponentName is null");
Preconditions.checkNotNull(userHandle, "UserHandle is null");
-
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
final int userId = userHandle.getIdentifier();
if (isManagedProfile(userId)) {
@@ -9078,10 +9083,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
public int stopUser(ComponentName who, UserHandle userHandle) {
Preconditions.checkNotNull(who, "ComponentName is null");
Preconditions.checkNotNull(userHandle, "UserHandle is null");
-
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
final int userId = userHandle.getIdentifier();
if (isManagedProfile(userId)) {
@@ -9149,9 +9151,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public List<UserHandle> getSecondaryUsers(ComponentName who) {
Preconditions.checkNotNull(who, "ComponentName is null");
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
final long id = mInjector.binderClearCallingIdentity();
try {
@@ -9173,9 +9173,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public boolean isEphemeralUser(ComponentName who) {
Preconditions.checkNotNull(who, "ComponentName is null");
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
- }
+ enforceProfileOrDeviceOwner(who);
final int callingUserId = mInjector.userHandleGetCallingUserId();
final long id = mInjector.binderClearCallingIdentity();
@@ -9994,7 +9992,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public boolean setTime(ComponentName who, long millis) {
Preconditions.checkNotNull(who, "ComponentName is null in setTime");
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
+ enforceDeviceOwner(who);
// Don't allow set time when auto time is on.
if (mInjector.settingsGlobalGetInt(Global.AUTO_TIME, 0) == 1) {
return false;
@@ -10006,7 +10004,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public boolean setTimeZone(ComponentName who, String timeZone) {
Preconditions.checkNotNull(who, "ComponentName is null in setTimeZone");
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
+ enforceDeviceOwner(who);
// Don't allow set timezone when auto timezone is on.
if (mInjector.settingsGlobalGetInt(Global.AUTO_TIME_ZONE, 0) == 1) {
return false;
@@ -10162,7 +10160,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
if (policy.mStatusBarDisabled != disabled) {
boolean isLockTaskMode = false;
try {
- isLockTaskMode = mInjector.getIActivityManager().getLockTaskModeState()
+ isLockTaskMode = mInjector.getIActivityTaskManager().getLockTaskModeState()
!= LOCK_TASK_MODE_NONE;
} catch (RemoteException e) {
Slog.e(LOG_TAG, "Failed to get LockTask mode");
@@ -11107,9 +11105,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public String getWifiMacAddress(ComponentName admin) {
// Make sure caller has DO.
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(admin);
final long ident = mInjector.binderClearCallingIdentity();
try {
@@ -11147,9 +11143,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
@Override
public boolean isSystemOnlyUser(ComponentName admin) {
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(admin);
final int callingUserId = mInjector.userHandleGetCallingUserId();
return UserManager.isSplitSystemUser() && callingUserId == UserHandle.USER_SYSTEM;
}
@@ -11158,9 +11152,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
public void reboot(ComponentName admin) {
Preconditions.checkNotNull(admin);
// Make sure caller has DO.
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(admin);
long ident = mInjector.binderClearCallingIdentity();
try {
// Make sure there are no ongoing calls on the device.
@@ -11979,9 +11971,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
return false;
}
Preconditions.checkNotNull(admin);
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(admin);
final int callingUid = mInjector.binderGetCallingUid();
final AtomicBoolean success = new AtomicBoolean(false);
@@ -12594,9 +12584,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
Preconditions.checkNotNull(admin, "ComponentName is null");
Preconditions.checkNotNull(packageName, "packageName is null");
Preconditions.checkNotNull(callback, "callback is null");
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(admin, DeviceAdminInfo.USES_POLICY_PROFILE_OWNER);
- }
+ enforceProfileOrDeviceOwner(admin);
final int userId = UserHandle.getCallingUserId();
long ident = mInjector.binderClearCallingIdentity();
@@ -12904,9 +12892,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
Preconditions.checkNotNull(who, "ComponentName is null in addOverrideApn");
Preconditions.checkNotNull(apnSetting, "ApnSetting is null in addOverrideApn");
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
int operatedId = -1;
Uri resultUri;
@@ -12935,9 +12921,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
}
Preconditions.checkNotNull(who, "ComponentName is null in updateOverrideApn");
Preconditions.checkNotNull(apnSetting, "ApnSetting is null in updateOverrideApn");
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
if (apnId < 0) {
return false;
@@ -12958,9 +12942,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
return false;
}
Preconditions.checkNotNull(who, "ComponentName is null in removeOverrideApn");
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
return removeOverrideApnUnchecked(apnId);
}
@@ -12986,9 +12968,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
return Collections.emptyList();
}
Preconditions.checkNotNull(who, "ComponentName is null in getOverrideApns");
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
return getOverrideApnsUnchecked();
}
@@ -13024,9 +13004,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
return;
}
Preconditions.checkNotNull(who, "ComponentName is null in setOverrideApnEnabled");
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
setOverrideApnsEnabledUnchecked(enabled);
}
@@ -13049,9 +13027,7 @@ public class DevicePolicyManagerService extends BaseIDevicePolicyManager {
return false;
}
Preconditions.checkNotNull(who, "ComponentName is null in isOverrideApnEnabled");
- synchronized (getLockObject()) {
- getActiveAdminForCallerLocked(who, DeviceAdminInfo.USES_POLICY_DEVICE_OWNER);
- }
+ enforceDeviceOwner(who);
Cursor enforceCursor;
final long id = mInjector.binderClearCallingIdentity();
diff --git a/services/java/com/android/server/SystemServer.java b/services/java/com/android/server/SystemServer.java
index c864190bb34b..2c0120b30e63 100644
--- a/services/java/com/android/server/SystemServer.java
+++ b/services/java/com/android/server/SystemServer.java
@@ -63,6 +63,7 @@ import com.android.internal.util.EmergencyAffordanceManager;
import com.android.internal.widget.ILockSettings;
import com.android.server.accessibility.AccessibilityManagerService;
import com.android.server.am.ActivityManagerService;
+import com.android.server.am.ActivityTaskManagerService;
import com.android.server.audio.AudioService;
import com.android.server.broadcastradio.BroadcastRadioService;
import com.android.server.camera.CameraServiceProxy;
@@ -201,6 +202,8 @@ public final class SystemServer {
"com.google.android.clockwork.ThermalObserver";
private static final String WEAR_CONNECTIVITY_SERVICE_CLASS =
"com.android.clockwork.connectivity.WearConnectivityService";
+ private static final String WEAR_POWER_SERVICE_CLASS =
+ "com.android.clockwork.power.WearPowerService";
private static final String WEAR_SIDEKICK_SERVICE_CLASS =
"com.google.android.clockwork.sidekick.SidekickService";
private static final String WEAR_DISPLAY_SERVICE_CLASS =
@@ -560,6 +563,10 @@ public final class SystemServer {
ActivityManagerService.Lifecycle.class).getService();
mActivityManagerService.setSystemServiceManager(mSystemServiceManager);
mActivityManagerService.setInstaller(installer);
+ // TODO: Might need to move after migration to WM.
+ ActivityTaskManagerService atm = mSystemServiceManager.startService(
+ ActivityTaskManagerService.Lifecycle.class).getService();
+ mActivityManagerService.setActivityTaskManager(atm);
traceEnd();
// Power manager needs to be started early because other services need it.
@@ -1549,12 +1556,20 @@ public final class SystemServer {
}
if (isWatch) {
+ // Must be started before services that depend it, e.g. WearConnectivityService
+ traceBeginAndSlog("StartWearPowerService");
+ mSystemServiceManager.startService(WEAR_POWER_SERVICE_CLASS);
+ traceEnd();
+
traceBeginAndSlog("StartWearConnectivityService");
mSystemServiceManager.startService(WEAR_CONNECTIVITY_SERVICE_CLASS);
traceEnd();
- traceBeginAndSlog("StartWearTimeService");
+ traceBeginAndSlog("StartWearDisplayService");
mSystemServiceManager.startService(WEAR_DISPLAY_SERVICE_CLASS);
+ traceEnd();
+
+ traceBeginAndSlog("StartWearTimeService");
mSystemServiceManager.startService(WEAR_TIME_SERVICE_CLASS);
traceEnd();
diff --git a/services/robotests/src/com/android/server/backup/internal/PerformInitializeTaskTest.java b/services/robotests/src/com/android/server/backup/internal/PerformInitializeTaskTest.java
index 5810c30acbf5..646367e5a8ba 100644
--- a/services/robotests/src/com/android/server/backup/internal/PerformInitializeTaskTest.java
+++ b/services/robotests/src/com/android/server/backup/internal/PerformInitializeTaskTest.java
@@ -19,6 +19,7 @@ package com.android.server.backup.internal;
import static android.app.backup.BackupTransport.TRANSPORT_ERROR;
import static android.app.backup.BackupTransport.TRANSPORT_OK;
+import static com.android.server.backup.testing.TestUtils.assertLogcatContains;
import static com.android.server.backup.testing.TransportData.backupTransport;
import static com.android.server.backup.testing.TransportData.d2dTransport;
import static com.android.server.backup.testing.TransportData.localTransport;
@@ -40,6 +41,7 @@ import android.app.PendingIntent;
import android.app.backup.IBackupObserver;
import android.os.DeadObjectException;
import android.platform.test.annotations.Presubmit;
+import android.util.Log;
import com.android.internal.backup.IBackupTransport;
import com.android.server.backup.BackupManagerService;
@@ -50,6 +52,8 @@ import com.android.server.backup.testing.TransportTestUtils.TransportMock;
import com.android.server.backup.transport.TransportClient;
import com.android.server.testing.FrameworkRobolectricTestRunner;
import com.android.server.testing.SystemLoaderPackages;
+import com.android.server.testing.shadows.ShadowSlog;
+
import org.junit.Before;
import org.junit.Test;
@@ -66,7 +70,7 @@ import java.util.List;
import java.util.stream.Stream;
@RunWith(FrameworkRobolectricTestRunner.class)
-@Config(manifest = Config.NONE, sdk = 26)
+@Config(manifest = Config.NONE, sdk = 26, shadows = ShadowSlog.class)
@SystemLoaderPackages({"com.android.server.backup"})
@Presubmit
public class PerformInitializeTaskTest {
@@ -202,6 +206,32 @@ public class PerformInitializeTaskTest {
}
@Test
+ public void testRun_whenFinishBackupFails_logs() throws Exception {
+ setUpTransport(mTransport);
+ configureTransport(mTransportBinder, TRANSPORT_OK, TRANSPORT_ERROR);
+ PerformInitializeTask performInitializeTask = createPerformInitializeTask(mTransportName);
+
+ performInitializeTask.run();
+
+ assertLogcatContains(
+ BackupManagerService.TAG,
+ log -> log.msg.contains("finishBackup()") && log.type >= Log.ERROR);
+ }
+
+ @Test
+ public void testRun_whenInitializeDeviceFails_logs() throws Exception {
+ setUpTransport(mTransport);
+ configureTransport(mTransportBinder, TRANSPORT_ERROR, 0);
+ PerformInitializeTask performInitializeTask = createPerformInitializeTask(mTransportName);
+
+ performInitializeTask.run();
+
+ assertLogcatContains(
+ BackupManagerService.TAG,
+ log -> log.msg.contains("initializeDevice()") && log.type >= Log.ERROR);
+ }
+
+ @Test
public void testRun_whenFinishBackupFails_schedulesAlarm() throws Exception {
setUpTransport(mTransport);
configureTransport(mTransportBinder, TRANSPORT_OK, TRANSPORT_ERROR);
diff --git a/services/robotests/src/com/android/server/backup/testing/TestUtils.java b/services/robotests/src/com/android/server/backup/testing/TestUtils.java
index 3db41622dffd..3c84424c9630 100644
--- a/services/robotests/src/com/android/server/backup/testing/TestUtils.java
+++ b/services/robotests/src/com/android/server/backup/testing/TestUtils.java
@@ -21,6 +21,7 @@ import static com.google.common.truth.Truth.assertThat;
import org.robolectric.shadows.ShadowLog;
import java.util.concurrent.Callable;
+import java.util.function.Predicate;
public class TestUtils {
/** Reset logcat with {@link ShadowLog#reset()} before the test case */
@@ -35,6 +36,10 @@ public class TestUtils {
.isTrue();
}
+ public static void assertLogcatContains(String tag, Predicate<ShadowLog.LogItem> predicate) {
+ assertThat(ShadowLog.getLogsForTag(tag).stream().anyMatch(predicate)).isTrue();
+ }
+
/**
* Calls {@link Runnable#run()} and returns if no exception is thrown. Otherwise, if the
* exception is unchecked, rethrow it; if it's checked wrap in a {@link RuntimeException} and
diff --git a/services/robotests/src/com/android/server/testing/shadows/ShadowSlog.java b/services/robotests/src/com/android/server/testing/shadows/ShadowSlog.java
index bf4b61e7aa09..737b0c85d861 100644
--- a/services/robotests/src/com/android/server/testing/shadows/ShadowSlog.java
+++ b/services/robotests/src/com/android/server/testing/shadows/ShadowSlog.java
@@ -26,6 +26,86 @@ import org.robolectric.shadows.ShadowLog;
@Implements(Slog.class)
public class ShadowSlog {
@Implementation
+ public static int v(String tag, String msg) {
+ return Log.v(tag, msg);
+ }
+
+ @Implementation
+ public static int v(String tag, String msg, Throwable tr) {
+ return Log.v(tag, msg, tr);
+ }
+
+ @Implementation
+ public static int d(String tag, String msg) {
+ return Log.d(tag, msg);
+ }
+
+ @Implementation
+ public static int d(String tag, String msg, Throwable tr) {
+ return Log.d(tag, msg, tr);
+ }
+
+ @Implementation
+ public static int i(String tag, String msg) {
+ return Log.i(tag, msg);
+ }
+
+ @Implementation
+ public static int i(String tag, String msg, Throwable tr) {
+ return Log.i(tag, msg, tr);
+ }
+
+ @Implementation
+ public static int w(String tag, String msg) {
+ return Log.w(tag, msg);
+ }
+
+ @Implementation
+ public static int w(String tag, String msg, Throwable tr) {
+ return Log.w(tag, msg, tr);
+ }
+
+ @Implementation
+ public static int w(String tag, Throwable tr) {
+ return Log.w(tag, tr);
+ }
+
+ @Implementation
+ public static int e(String tag, String msg) {
+ return Log.e(tag, msg);
+ }
+
+ @Implementation
+ public static int e(String tag, String msg, Throwable tr) {
+ return Log.e(tag, msg, tr);
+ }
+
+ @Implementation
+ public static int wtf(String tag, String msg) {
+ return Log.wtf(tag, msg);
+ }
+
+ @Implementation
+ public static void wtfQuiet(String tag, String msg) {
+ Log.wtf(tag, msg);
+ }
+
+ @Implementation
+ public static int wtfStack(String tag, String msg) {
+ return Log.wtf(tag, msg);
+ }
+
+ @Implementation
+ public static int wtf(String tag, Throwable tr) {
+ return Log.wtf(tag, tr);
+ }
+
+ @Implementation
+ public static int wtf(String tag, String msg, Throwable tr) {
+ return Log.wtf(tag, msg, tr);
+ }
+
+ @Implementation
public static int println(int priority, String tag, String msg) {
return Log.println(priority, tag, msg);
}
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java
index 1520859d4aac..74e5816d4a1b 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityStarterTests.java
@@ -134,7 +134,7 @@ public class ActivityStarterTests extends ActivityTestsBase {
assertTrue(task2.getStack() instanceof PinnedActivityStack);
mStarter.updateBounds(task2, bounds);
- verify(mService, times(1)).resizeStack(eq(task2.getStack().mStackId),
+ verify(mService.mActivityTaskManager, times(1)).resizeStack(eq(task2.getStack().mStackId),
eq(bounds), anyBoolean(), anyBoolean(), anyBoolean(), anyInt());
// In the case of no animation, the stack and task bounds should be set immediately.
diff --git a/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
index 1cd111fce0ec..0154d36bf3bb 100644
--- a/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
+++ b/services/tests/servicestests/src/com/android/server/am/ActivityTestsBase.java
@@ -110,6 +110,12 @@ public class ActivityTestsBase {
protected ActivityManagerService setupActivityManagerService(ActivityManagerService service) {
service = spy(service);
+ // Makes sure the supervisor is using with the spy object.
+ service.mStackSupervisor.setService(service);
+ // Makes sure activity task is created with the spy object.
+ TestActivityTaskManagerService atm =
+ spy(new TestActivityTaskManagerService(service.mContext));
+ service.setActivityTaskManager(atm);
doReturn(mock(IPackageManager.class)).when(service).getPackageManager();
doNothing().when(service).grantEphemeralAccessLocked(anyInt(), any(), anyInt(), anyInt());
service.mWindowManager = prepareMockWindowManager();
@@ -333,6 +339,12 @@ public class ActivityTestsBase {
}
}
+ protected static class TestActivityTaskManagerService extends ActivityTaskManagerService {
+ TestActivityTaskManagerService(Context context) {
+ super(context);
+ }
+ }
+
/**
* An {@link ActivityManagerService} subclass which provides a test
* {@link ActivityStackSupervisor}.
@@ -367,10 +379,6 @@ public class ActivityTestsBase {
return mLockTaskController;
}
- void setLifecycleManager(ClientLifecycleManager manager) {
- mLifecycleManager = manager;
- }
-
@Override
final protected ActivityStackSupervisor createStackSupervisor() {
final ActivityStackSupervisor supervisor = spy(createTestSupervisor());
diff --git a/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java b/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java
index ce88d849a1d4..0a436b956abc 100644
--- a/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/AssistDataRequesterTest.java
@@ -35,6 +35,7 @@ import static org.mockito.Mockito.mock;
import android.app.AppOpsManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.content.Context;
import android.graphics.Bitmap;
import android.os.Bundle;
@@ -87,6 +88,7 @@ public class AssistDataRequesterTest extends ActivityTestsBase {
private Object mCallbacksLock;
private Handler mHandler;
private IActivityManager mAm;
+ private IActivityTaskManager mAtm;
private IWindowManager mWm;
private AppOpsManager mAppOpsManager;
@@ -104,6 +106,7 @@ public class AssistDataRequesterTest extends ActivityTestsBase {
public void setUp() throws Exception {
super.setUp();
mAm = mock(IActivityManager.class);
+ mAtm = mock(IActivityTaskManager.class);
mWm = mock(IWindowManager.class);
mAppOpsManager = mock(AppOpsManager.class);
mContext = InstrumentationRegistry.getContext();
@@ -125,7 +128,7 @@ public class AssistDataRequesterTest extends ActivityTestsBase {
}
});
return true;
- }).when(mAm).requestAssistContextExtras(anyInt(), any(), any(), any(), anyBoolean(),
+ }).when(mAtm).requestAssistContextExtras(anyInt(), any(), any(), any(), anyBoolean(),
anyBoolean());
doAnswer(invocation -> {
mHandler.post(() -> {
@@ -142,7 +145,7 @@ public class AssistDataRequesterTest extends ActivityTestsBase {
private void setupMocks(boolean currentActivityAssistAllowed, boolean assistStructureAllowed,
boolean assistScreenshotAllowed) throws Exception {
- doReturn(currentActivityAssistAllowed).when(mAm).isAssistDataAllowedOnCurrentActivity();
+ doReturn(currentActivityAssistAllowed).when(mAtm).isAssistDataAllowedOnCurrentActivity();
doReturn(assistStructureAllowed ? MODE_ALLOWED : MODE_ERRORED).when(mAppOpsManager)
.checkOpNoThrow(eq(OP_ASSIST_STRUCTURE), anyInt(), anyString());
doReturn(assistScreenshotAllowed ? MODE_ALLOWED : MODE_ERRORED).when(mAppOpsManager)
@@ -240,7 +243,7 @@ public class AssistDataRequesterTest extends ActivityTestsBase {
public void testDisallowAssistContextExtras_expectNullDataCallbacks() throws Exception {
setupMocks(CURRENT_ACTIVITY_ASSIST_ALLOWED, CALLER_ASSIST_STRUCTURE_ALLOWED,
CALLER_ASSIST_SCREENSHOT_ALLOWED);
- doReturn(false).when(mAm).requestAssistContextExtras(anyInt(), any(), any(), any(),
+ doReturn(false).when(mAtm).requestAssistContextExtras(anyInt(), any(), any(), any(),
anyBoolean(), anyBoolean());
mDataRequester.requestAssistData(createActivityList(5), FETCH_DATA, FETCH_SCREENSHOTS,
@@ -371,4 +374,4 @@ public class AssistDataRequesterTest extends ActivityTestsBase {
});
}
}
-} \ No newline at end of file
+}
diff --git a/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java b/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java
index 161c2875bf49..93e0b5aa9082 100644
--- a/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java
+++ b/services/tests/servicestests/src/com/android/server/am/LaunchParamsControllerTests.java
@@ -200,9 +200,9 @@ public class LaunchParamsControllerTests extends ActivityTestsBase {
mController.registerModifier(positioner);
- doNothing().when(mService).moveStackToDisplay(anyInt(), anyInt());
+ doNothing().when(mService.mActivityTaskManager).moveStackToDisplay(anyInt(), anyInt());
mController.layoutTask(task, null /* windowLayout */);
- verify(mService, times(1)).moveStackToDisplay(eq(task.getStackId()),
+ verify(mService.mActivityTaskManager, times(1)).moveStackToDisplay(eq(task.getStackId()),
eq(params.mPreferredDisplayId));
}
diff --git a/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java b/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java
index b73ac8934cb0..af6686f00113 100644
--- a/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/RecentTasksTest.java
@@ -16,7 +16,7 @@
package com.android.server.am;
-import static android.app.ActivityManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
+import static android.app.ActivityTaskManager.SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_HOME;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_STANDARD;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_UNDEFINED;
@@ -40,11 +40,9 @@ import static org.mockito.Mockito.spy;
import static java.lang.Integer.MAX_VALUE;
-import android.annotation.TestApi;
-import android.app.ActivityManager;
import android.app.ActivityManager.RecentTaskInfo;
import android.app.ActivityManager.RunningTaskInfo;
-import android.app.WindowConfiguration;
+import android.app.ActivityTaskManager;
import android.content.ComponentName;
import android.content.Context;
import android.content.pm.PackageManager;
@@ -698,65 +696,58 @@ public class RecentTasksTest extends ActivityTestsBase {
}
private void testRecentTasksApis(boolean expectCallable) {
- assertSecurityException(expectCallable, () -> mService.removeStack(INVALID_STACK_ID));
+ assertSecurityException(expectCallable, () -> mService.mActivityTaskManager.removeStack(INVALID_STACK_ID));
assertSecurityException(expectCallable,
- () -> mService.removeStacksInWindowingModes(new int[] {WINDOWING_MODE_UNDEFINED}));
+ () -> mService.mActivityTaskManager.removeStacksInWindowingModes(
+ new int[] {WINDOWING_MODE_UNDEFINED}));
assertSecurityException(expectCallable,
- () -> mService.removeStacksWithActivityTypes(new int[] {ACTIVITY_TYPE_UNDEFINED}));
+ () -> mService.mActivityTaskManager.removeStacksWithActivityTypes(
+ new int[] {ACTIVITY_TYPE_UNDEFINED}));
assertSecurityException(expectCallable, () -> mService.removeTask(0));
assertSecurityException(expectCallable,
- () -> mService.setTaskWindowingMode(0, WINDOWING_MODE_UNDEFINED, true));
+ () -> mService.mActivityTaskManager.setTaskWindowingMode(
+ 0, WINDOWING_MODE_UNDEFINED, true));
assertSecurityException(expectCallable,
() -> mService.moveTaskToStack(0, INVALID_STACK_ID, true));
assertSecurityException(expectCallable,
- () -> mService.setTaskWindowingModeSplitScreenPrimary(0,
+ () -> mService.mActivityTaskManager.setTaskWindowingModeSplitScreenPrimary(0,
SPLIT_SCREEN_CREATE_MODE_TOP_OR_LEFT, true, true, new Rect(), true));
- assertSecurityException(expectCallable, () -> mService.dismissSplitScreenMode(true));
- assertSecurityException(expectCallable, () -> mService.dismissPip(true, 0));
+ assertSecurityException(expectCallable, () -> mService.mActivityTaskManager.dismissSplitScreenMode(true));
+ assertSecurityException(expectCallable, () -> mService.mActivityTaskManager.dismissPip(true, 0));
assertSecurityException(expectCallable,
- () -> mService.moveTopActivityToPinnedStack(INVALID_STACK_ID, new Rect()));
+ () -> mService.mActivityTaskManager.moveTopActivityToPinnedStack(INVALID_STACK_ID, new Rect()));
assertSecurityException(expectCallable,
() -> mService.resizeStack(INVALID_STACK_ID, new Rect(), true, true, true, 0));
assertSecurityException(expectCallable,
- () -> mService.resizeDockedStack(new Rect(), new Rect(), new Rect(), new Rect(),
+ () -> mService.mActivityTaskManager.resizeDockedStack(new Rect(), new Rect(), new Rect(), new Rect(),
new Rect()));
assertSecurityException(expectCallable,
- () -> mService.resizePinnedStack(new Rect(), new Rect()));
- assertSecurityException(expectCallable, () -> mService.getAllStackInfos());
+ () -> mService.mActivityTaskManager.resizePinnedStack(new Rect(), new Rect()));
+ assertSecurityException(expectCallable, () -> mService.mActivityTaskManager.getAllStackInfos());
assertSecurityException(expectCallable,
- () -> mService.getStackInfo(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_UNDEFINED));
+ () -> mService.mActivityTaskManager.getStackInfo(WINDOWING_MODE_UNDEFINED, ACTIVITY_TYPE_UNDEFINED));
assertSecurityException(expectCallable, () -> {
try {
- mService.getFocusedStackInfo();
+ mService.mActivityTaskManager.getFocusedStackInfo();
} catch (RemoteException e) {
// Ignore
}
});
assertSecurityException(expectCallable,
- () -> mService.moveTasksToFullscreenStack(INVALID_STACK_ID, true));
+ () -> mService.mActivityTaskManager.moveTasksToFullscreenStack(INVALID_STACK_ID, true));
assertSecurityException(expectCallable,
- () -> mService.startActivityFromRecents(0, new Bundle()));
+ () -> mService.mActivityTaskManager.startActivityFromRecents(0, new Bundle()));
assertSecurityException(expectCallable,
- () -> mService.getTaskSnapshot(0, true));
- assertSecurityException(expectCallable, () -> {
- try {
- mService.registerTaskStackListener(null);
- } catch (RemoteException e) {
- // Ignore
- }
- });
- assertSecurityException(expectCallable, () -> {
- try {
- mService.unregisterTaskStackListener(null);
- } catch (RemoteException e) {
- // Ignore
- }
- });
- assertSecurityException(expectCallable, () -> mService.getTaskDescription(0));
- assertSecurityException(expectCallable, () -> mService.cancelTaskWindowTransition(0));
- assertSecurityException(expectCallable, () -> mService.startRecentsActivity(null, null,
+ () -> mService.mActivityTaskManager.getTaskSnapshot(0, true));
+ assertSecurityException(expectCallable,
+ () -> mService.mActivityTaskManager.registerTaskStackListener(null));
+ assertSecurityException(expectCallable,
+ () -> mService.mActivityTaskManager.unregisterTaskStackListener(null));
+ assertSecurityException(expectCallable, () -> mService.mActivityTaskManager.getTaskDescription(0));
+ assertSecurityException(expectCallable, () -> mService.mActivityTaskManager.cancelTaskWindowTransition(0));
+ assertSecurityException(expectCallable, () -> mService.mActivityTaskManager.startRecentsActivity(null, null,
null));
- assertSecurityException(expectCallable, () -> mService.cancelRecentsAnimation(true));
+ assertSecurityException(expectCallable, () -> mService.mActivityTaskManager.cancelRecentsAnimation(true));
assertSecurityException(expectCallable, () -> mService.stopAppSwitches());
assertSecurityException(expectCallable, () -> mService.resumeAppSwitches());
}
@@ -794,7 +785,7 @@ public class RecentTasksTest extends ActivityTestsBase {
.setFlags(FLAG_ACTIVITY_NEW_DOCUMENT | flags)
.build();
task.affinity = null;
- task.maxRecents = ActivityManager.getMaxAppRecentsLimitStatic();
+ task.maxRecents = ActivityTaskManager.getMaxAppRecentsLimitStatic();
return task;
}
diff --git a/services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java b/services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java
index 0359096892bb..8e87a5f2b689 100644
--- a/services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java
+++ b/services/tests/servicestests/src/com/android/server/am/TaskStackChangedListenerTest.java
@@ -24,6 +24,7 @@ import static org.junit.Assert.assertTrue;
import android.app.Activity;
import android.app.ActivityManager;
import android.app.ActivityManager.TaskDescription;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
import android.app.ITaskStackListener;
import android.app.Instrumentation.ActivityMonitor;
@@ -68,7 +69,7 @@ public class TaskStackChangedListenerTest {
@After
public void tearDown() throws Exception {
- mService.unregisterTaskStackListener(mTaskStackListener);
+ ActivityTaskManager.getService().unregisterTaskStackListener(mTaskStackListener);
mTaskStackListener = null;
}
@@ -227,7 +228,7 @@ public class TaskStackChangedListenerTest {
private void registerTaskStackChangedListener(ITaskStackListener listener) throws Exception {
mTaskStackListener = listener;
- mService.registerTaskStackListener(listener);
+ ActivityTaskManager.getService().registerTaskStackListener(listener);
}
private void waitForCallback(CountDownLatch latch) {
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceTestable.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceTestable.java
index cd3928558c4b..2b5b812af4c7 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceTestable.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerServiceTestable.java
@@ -18,6 +18,7 @@ package com.android.server.devicepolicy;
import android.app.ActivityManagerInternal;
import android.app.AlarmManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.NotificationManager;
import android.app.PendingIntent;
import android.app.backup.IBackupManager;
@@ -181,6 +182,11 @@ public class DevicePolicyManagerServiceTestable extends DevicePolicyManagerServi
}
@Override
+ IActivityTaskManager getIActivityTaskManager() {
+ return services.iactivityTaskManager;
+ }
+
+ @Override
ActivityManagerInternal getActivityManagerInternal() {
return services.activityManagerInternal;
}
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
index 1acecfc8cb05..a23636ca20dc 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/DevicePolicyManagerTest.java
@@ -3726,7 +3726,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
private void verifyLockTaskState(int userId, String[] packages, int flags) throws Exception {
verify(getServices().iactivityManager).updateLockTaskPackages(userId, packages);
- verify(getServices().iactivityManager).updateLockTaskFeatures(userId, flags);
+ verify(getServices().iactivityTaskManager).updateLockTaskFeatures(userId, flags);
}
private void verifyCanSetLockTask(int uid, int userId, ComponentName who, String[] packages,
@@ -3819,7 +3819,7 @@ public class DevicePolicyManagerTest extends DpmTestBase {
// Lock task packages cleared when loading user data and when the user becomes unaffiliated.
verify(getServices().iactivityManager, times(2)).updateLockTaskPackages(
MANAGED_PROFILE_USER_ID, new String[0]);
- verify(getServices().iactivityManager, times(2)).updateLockTaskFeatures(
+ verify(getServices().iactivityTaskManager, times(2)).updateLockTaskFeatures(
MANAGED_PROFILE_USER_ID, DevicePolicyManager.LOCK_TASK_FEATURE_NONE);
// Verify that lock task packages were not cleared for the DO
diff --git a/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java b/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
index e753df1f30ec..4724f1cdd324 100644
--- a/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
+++ b/services/tests/servicestests/src/com/android/server/devicepolicy/MockSystemServices.java
@@ -28,6 +28,7 @@ import android.accounts.AccountManager;
import android.app.ActivityManagerInternal;
import android.app.AlarmManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.NotificationManager;
import android.app.backup.IBackupManager;
import android.app.usage.UsageStatsManagerInternal;
@@ -91,6 +92,7 @@ public class MockSystemServices {
public final IIpConnectivityMetrics iipConnectivityMetrics;
public final IWindowManager iwindowManager;
public final IActivityManager iactivityManager;
+ public final IActivityTaskManager iactivityTaskManager;
public ActivityManagerInternal activityManagerInternal;
public final IPackageManager ipackageManager;
public final IBackupManager ibackupManager;
@@ -129,6 +131,7 @@ public class MockSystemServices {
iipConnectivityMetrics = mock(IIpConnectivityMetrics.class);
iwindowManager = mock(IWindowManager.class);
iactivityManager = mock(IActivityManager.class);
+ iactivityTaskManager = mock(IActivityTaskManager.class);
activityManagerInternal = mock(ActivityManagerInternal.class);
ipackageManager = mock(IPackageManager.class);
ibackupManager = mock(IBackupManager.class);
diff --git a/services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeZoneDetectorStrategyTest.java b/services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeZoneDetectorStrategyTest.java
new file mode 100644
index 000000000000..e4b3b131b409
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/timedetector/SimpleTimeZoneDetectorStrategyTest.java
@@ -0,0 +1,68 @@
+/*
+ * 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.server.timedetector;
+
+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 android.app.timedetector.TimeSignal;
+import android.support.test.runner.AndroidJUnit4;
+import android.util.TimestampedValue;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class SimpleTimeZoneDetectorStrategyTest {
+
+ private TimeDetectorStrategy.Callback mMockCallback;
+
+ private SimpleTimeDetectorStrategy mSimpleTimeZoneDetectorStrategy;
+
+ @Before
+ public void setUp() {
+ mMockCallback = mock(TimeDetectorStrategy.Callback.class);
+ mSimpleTimeZoneDetectorStrategy = new SimpleTimeDetectorStrategy();
+ mSimpleTimeZoneDetectorStrategy.initialize(mMockCallback);
+ }
+
+ @Test
+ public void testSuggestTime_nitz() {
+ TimestampedValue<Long> utcTime = createUtcTime();
+ TimeSignal timeSignal = new TimeSignal(TimeSignal.SOURCE_ID_NITZ, utcTime);
+
+ mSimpleTimeZoneDetectorStrategy.suggestTime(timeSignal);
+
+ verify(mMockCallback).setTime(utcTime);
+ }
+
+ @Test
+ public void testSuggestTime_unknownSource() {
+ TimestampedValue<Long> utcTime = createUtcTime();
+ TimeSignal timeSignal = new TimeSignal("unknown", utcTime);
+ mSimpleTimeZoneDetectorStrategy.suggestTime(timeSignal);
+
+ verify(mMockCallback, never()).setTime(any());
+ }
+
+ private static TimestampedValue<Long> createUtcTime() {
+ return new TimestampedValue<>(321L, 123456L);
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java b/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java
index dc17eeb299f3..22dea92cc0b2 100644
--- a/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java
+++ b/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorServiceTest.java
@@ -16,31 +16,73 @@
package com.android.server.timedetector;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.anyString;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.doNothing;
+import static org.mockito.Mockito.doThrow;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.verifyNoMoreInteractions;
+
+import android.app.timedetector.TimeSignal;
import android.content.Context;
-import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
+import android.util.TimestampedValue;
+import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
-/**
- * Unit tests for the {@link TimeDetectorService}.
- */
@RunWith(AndroidJUnit4.class)
public class TimeDetectorServiceTest {
private TimeDetectorService mTimeDetectorService;
+ private Context mMockContext;
+ private TimeDetectorStrategy mMockTimeDetectorStrategy;
+
@Before
public void setUp() {
- final Context context = InstrumentationRegistry.getContext();
- mTimeDetectorService = new TimeDetectorService(context);
+ mMockContext = mock(Context.class);
+ mMockTimeDetectorStrategy = mock(TimeDetectorStrategy.class);
+ mTimeDetectorService = new TimeDetectorService(mMockContext, mMockTimeDetectorStrategy);
+ }
+
+ @After
+ public void tearDown() {
+ verifyNoMoreInteractions(mMockContext, mMockTimeDetectorStrategy);
+ }
+
+ @Test(expected=SecurityException.class)
+ public void testStubbedCall_withoutPermission() {
+ doThrow(new SecurityException("Mock"))
+ .when(mMockContext).enforceCallingPermission(anyString(), any());
+ TimeSignal timeSignal = createNitzTimeSignal();
+
+ try {
+ mTimeDetectorService.suggestTime(timeSignal);
+ } finally {
+ verify(mMockContext).enforceCallingPermission(
+ eq(android.Manifest.permission.SET_TIME), anyString());
+ }
}
@Test
- public void testStubbedCall() {
- mTimeDetectorService.stubbedCall();
+ public void testSuggestTime() {
+ doNothing().when(mMockContext).enforceCallingPermission(anyString(), any());
+
+ TimeSignal timeSignal = createNitzTimeSignal();
+ mTimeDetectorService.suggestTime(timeSignal);
+
+ verify(mMockContext)
+ .enforceCallingPermission(eq(android.Manifest.permission.SET_TIME), anyString());
+ verify(mMockTimeDetectorStrategy).suggestTime(timeSignal);
}
+ private static TimeSignal createNitzTimeSignal() {
+ TimestampedValue<Long> timeValue = new TimestampedValue<>(100L, 1_000_000L);
+ return new TimeSignal(TimeSignal.SOURCE_ID_NITZ, timeValue);
+ }
}
diff --git a/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorStrategyTest.java b/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorStrategyTest.java
new file mode 100644
index 000000000000..301ded47ee0b
--- /dev/null
+++ b/services/tests/servicestests/src/com/android/server/timedetector/TimeDetectorStrategyTest.java
@@ -0,0 +1,46 @@
+/*
+ * 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.server.timedetector;
+
+import static org.junit.Assert.assertEquals;
+
+import android.support.test.runner.AndroidJUnit4;
+import android.util.TimestampedValue;
+
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+@RunWith(AndroidJUnit4.class)
+public class TimeDetectorStrategyTest {
+
+ @Test
+ public void testGetTimeAt() {
+ long timeMillis = 1000L;
+ int referenceTimeMillis = 100;
+ TimestampedValue<Long> timestampedValue =
+ new TimestampedValue<>(referenceTimeMillis, timeMillis);
+ // Reference time is after the timestamp.
+ assertEquals(
+ timeMillis + (125 - referenceTimeMillis),
+ TimeDetectorStrategy.getTimeAt(timestampedValue, 125));
+
+ // Reference time is before the timestamp.
+ assertEquals(
+ timeMillis + (75 - referenceTimeMillis),
+ TimeDetectorStrategy.getTimeAt(timestampedValue, 75));
+ }
+}
diff --git a/services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java b/services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java
index 4447b26ac2d1..dc6bbbfe5285 100644
--- a/services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java
+++ b/services/tests/servicestests/src/com/android/server/wm/TaskPositionerTests.java
@@ -22,6 +22,7 @@ import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
+import android.app.IActivityTaskManager;
import android.graphics.Rect;
import android.support.test.filters.SmallTest;
import android.support.test.runner.AndroidJUnit4;
@@ -75,7 +76,7 @@ public class TaskPositionerTests extends WindowTestsBase {
mMinVisibleWidth = dipToPixel(MINIMUM_VISIBLE_WIDTH_IN_DP, dm);
mMinVisibleHeight = dipToPixel(MINIMUM_VISIBLE_HEIGHT_IN_DP, dm);
- mPositioner = new TaskPositioner(sWm, Mockito.mock(IActivityManager.class));
+ mPositioner = new TaskPositioner(sWm, Mockito.mock(IActivityTaskManager.class));
mPositioner.register(mDisplayContent);
mWindow = Mockito.spy(createWindow(null, TYPE_BASE_APPLICATION, "window"));
diff --git a/services/usage/java/com/android/server/usage/UsageStatsService.java b/services/usage/java/com/android/server/usage/UsageStatsService.java
index e6584c51ebd6..1d5eeced44b9 100644
--- a/services/usage/java/com/android/server/usage/UsageStatsService.java
+++ b/services/usage/java/com/android/server/usage/UsageStatsService.java
@@ -207,8 +207,8 @@ public class UsageStatsService extends SystemService implements
@Override
public void onBootPhase(int phase) {
+ mAppStandby.onBootPhase(phase);
if (phase == PHASE_SYSTEM_SERVICES_READY) {
- mAppStandby.onBootPhase(phase);
// initialize mDpmInternal
getDpmInternal();
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
index 7541b92dbe2c..ba94afe4de06 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionManagerServiceImpl.java
@@ -23,10 +23,11 @@ import static android.app.ActivityManager.START_VOICE_NOT_ACTIVE_SESSION;
import static android.app.WindowConfiguration.ACTIVITY_TYPE_ASSISTANT;
import android.app.ActivityManager;
-import android.app.ActivityManager.StackId;
import android.app.ActivityManagerInternal;
import android.app.ActivityOptions;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.content.BroadcastReceiver;
import android.content.ComponentName;
import android.content.Context;
@@ -71,6 +72,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
final int mUser;
final ComponentName mComponent;
final IActivityManager mAm;
+ final IActivityTaskManager mAtm;
final VoiceInteractionServiceInfo mInfo;
final ComponentName mSessionComponentName;
final IWindowManager mIWindowManager;
@@ -126,6 +128,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
mUser = userHandle;
mComponent = service;
mAm = ActivityManager.getService();
+ mAtm = ActivityTaskManager.getService();
VoiceInteractionServiceInfo info;
try {
info = new VoiceInteractionServiceInfo(context.getPackageManager(), service, mUser);
@@ -206,7 +209,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
intent = new Intent(intent);
intent.addCategory(Intent.CATEGORY_VOICE);
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_MULTIPLE_TASK);
- return mAm.startVoiceActivity(mComponent.getPackageName(), callingPid, callingUid,
+ return mAtm.startVoiceActivity(mComponent.getPackageName(), callingPid, callingUid,
intent, resolvedType, mActiveSession.mSession, mActiveSession.mInteractor,
0, null, null, mUser);
} catch (RemoteException e) {
@@ -229,7 +232,7 @@ class VoiceInteractionManagerServiceImpl implements VoiceInteractionSessionConne
intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
final ActivityOptions options = ActivityOptions.makeBasic();
options.setLaunchActivityType(ACTIVITY_TYPE_ASSISTANT);
- return mAm.startAssistantActivity(mComponent.getPackageName(), callingPid, callingUid,
+ return mAtm.startAssistantActivity(mComponent.getPackageName(), callingPid, callingUid,
intent, resolvedType, options.toBundle(), mUser);
} catch (RemoteException e) {
throw new IllegalStateException("Unexpected remote error", e);
diff --git a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
index e0d9c7397748..457bfcdf5a30 100644
--- a/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
+++ b/services/voiceinteraction/java/com/android/server/voiceinteraction/VoiceInteractionSessionConnection.java
@@ -27,6 +27,7 @@ import static android.view.Display.DEFAULT_DISPLAY;
import static android.view.WindowManager.LayoutParams.TYPE_VOICE_INTERACTION;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.AppOpsManager;
import android.app.IActivityManager;
import android.app.assist.AssistContent;
@@ -359,7 +360,7 @@ final class VoiceInteractionSessionConnection implements ServiceConnection,
}
if (mSession != null) {
try {
- mAm.finishVoiceTask(mSession);
+ ActivityTaskManager.getService().finishVoiceTask(mSession);
} catch (RemoteException e) {
}
}
@@ -387,7 +388,7 @@ final class VoiceInteractionSessionConnection implements ServiceConnection,
}
if (finishTask && mSession != null) {
try {
- mAm.finishVoiceTask(mSession);
+ ActivityTaskManager.getService().finishVoiceTask(mSession);
} catch (RemoteException e) {
}
}
diff --git a/telecomm/java/android/telecom/ConnectionService.java b/telecomm/java/android/telecom/ConnectionService.java
index 9d784907a87f..2291090f9daf 100644
--- a/telecomm/java/android/telecom/ConnectionService.java
+++ b/telecomm/java/android/telecom/ConnectionService.java
@@ -1531,6 +1531,14 @@ public abstract class ConnectionService extends Service {
new DisconnectCause(DisconnectCause.ERROR, "IMPL_RETURNED_NULL_CONNECTION"));
}
+ boolean isSelfManaged =
+ (connection.getConnectionProperties() & Connection.PROPERTY_SELF_MANAGED)
+ == Connection.PROPERTY_SELF_MANAGED;
+ // Self-managed Connections should always use voip audio mode; we default here so that the
+ // local state within the ConnectionService matches the default we assume in Telecom.
+ if (isSelfManaged) {
+ connection.setAudioModeIsVoip(true);
+ }
connection.setTelecomCallId(callId);
if (connection.getState() != Connection.STATE_DISCONNECTED) {
addConnection(request.getAccountHandle(), callId, connection);
@@ -1570,9 +1578,7 @@ public abstract class ConnectionService extends Service {
createIdList(connection.getConferenceables()),
connection.getExtras()));
- if (isIncoming && request.shouldShowIncomingCallUi() &&
- (connection.getConnectionProperties() & Connection.PROPERTY_SELF_MANAGED) ==
- Connection.PROPERTY_SELF_MANAGED) {
+ if (isIncoming && request.shouldShowIncomingCallUi() && isSelfManaged) {
// Tell ConnectionService to show its incoming call UX.
connection.onShowIncomingCallUi();
}
diff --git a/telephony/java/android/telephony/data/ApnSetting.java b/telephony/java/android/telephony/data/ApnSetting.java
index 145ed7eeabdd..f875a9868198 100644
--- a/telephony/java/android/telephony/data/ApnSetting.java
+++ b/telephony/java/android/telephony/data/ApnSetting.java
@@ -24,12 +24,14 @@ import android.net.Uri;
import android.os.Parcel;
import android.os.Parcelable;
import android.provider.Telephony;
+import android.provider.Telephony.Carriers;
import android.telephony.Rlog;
import android.telephony.ServiceState;
import android.telephony.TelephonyManager;
import android.text.TextUtils;
import android.util.ArrayMap;
import android.util.Log;
+
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.net.InetAddress;
@@ -40,27 +42,40 @@ import java.util.Map;
import java.util.Objects;
/**
- * A class representing an APN configuration.
+ * An Access Point Name (APN) configuration for a carrier data connection.
+ *
+ * <p>The APN provides configuration to connect a cellular network device to an IP data network. A
+ * carrier uses the name, type and other configuration in an {@code APNSetting} to decide which IP
+ * address to assign, any security methods to apply, and how the device might be connected to
+ * private networks.
+ *
+ * <p>Use {@link ApnSetting.Builder} to create new instances.
*/
public class ApnSetting implements Parcelable {
private static final String LOG_TAG = "ApnSetting";
private static final boolean VDBG = false;
- private static final Map<String, Integer> APN_TYPE_STRING_MAP;
- private static final Map<Integer, String> APN_TYPE_INT_MAP;
- private static final Map<String, Integer> PROTOCOL_STRING_MAP;
- private static final Map<Integer, String> PROTOCOL_INT_MAP;
- private static final Map<String, Integer> MVNO_TYPE_STRING_MAP;
- private static final Map<Integer, String> MVNO_TYPE_INT_MAP;
- private static final int NOT_IN_MAP_INT = -1;
- private static final int NO_PORT_SPECIFIED = -1;
+ private static final String V2_FORMAT_REGEX = "^\\[ApnSettingV2\\]\\s*";
+ private static final String V3_FORMAT_REGEX = "^\\[ApnSettingV3\\]\\s*";
+ private static final String V4_FORMAT_REGEX = "^\\[ApnSettingV4\\]\\s*";
+ private static final String V5_FORMAT_REGEX = "^\\[ApnSettingV5\\]\\s*";
- /** All APN types except IA. */
- private static final int TYPE_ALL_BUT_IA = ApnTypes.ALL & (~ApnTypes.IA);
+ /**
+ * Default value for mtu if it's not set. Moved from PhoneConstants.
+ * @hide
+ */
+ public static final int UNSET_MTU = 0;
+ private static final int UNSPECIFIED_INT = -1;
+ private static final String UNSPECIFIED_STRING = "";
- /** APN type for default data traffic and HiPri traffic. */
- public static final int TYPE_DEFAULT = ApnTypes.DEFAULT | ApnTypes.HIPRI;
+ /**
+ * All APN types.
+ * @hide
+ */
+ public static final int TYPE_ALL = ApnTypes.ALL;
+ /** APN type for default data traffic. */
+ public static final int TYPE_DEFAULT = ApnTypes.DEFAULT;
/** APN type for MMS traffic. */
public static final int TYPE_MMS = ApnTypes.MMS;
/** APN type for SUPL assisted GPS. */
@@ -159,9 +174,16 @@ public class ApnSetting implements Parcelable {
@Retention(RetentionPolicy.SOURCE)
public @interface MvnoType {}
+ private static final Map<String, Integer> APN_TYPE_STRING_MAP;
+ private static final Map<Integer, String> APN_TYPE_INT_MAP;
+ private static final Map<String, Integer> PROTOCOL_STRING_MAP;
+ private static final Map<Integer, String> PROTOCOL_INT_MAP;
+ private static final Map<String, Integer> MVNO_TYPE_STRING_MAP;
+ private static final Map<Integer, String> MVNO_TYPE_INT_MAP;
+
static {
APN_TYPE_STRING_MAP = new ArrayMap<String, Integer>();
- APN_TYPE_STRING_MAP.put("*", TYPE_ALL_BUT_IA);
+ APN_TYPE_STRING_MAP.put("*", TYPE_ALL);
APN_TYPE_STRING_MAP.put("default", TYPE_DEFAULT);
APN_TYPE_STRING_MAP.put("mms", TYPE_MMS);
APN_TYPE_STRING_MAP.put("supl", TYPE_SUPL);
@@ -209,10 +231,10 @@ public class ApnSetting implements Parcelable {
private final String mEntryName;
private final String mApnName;
- private final InetAddress mProxyAddress;
+ private final String mProxyAddress;
private final int mProxyPort;
private final Uri mMmsc;
- private final InetAddress mMmsProxyAddress;
+ private final String mMmsProxyAddress;
private final int mMmsProxyPort;
private final String mUser;
private final String mPassword;
@@ -238,6 +260,8 @@ public class ApnSetting implements Parcelable {
private final int mMvnoType;
private final String mMvnoMatchData;
+ private final int mApnSetId;
+
private boolean mPermanentFailed = false;
/**
@@ -315,6 +339,21 @@ public class ApnSetting implements Parcelable {
}
/**
+ * Returns the APN set id.
+ *
+ * APNs that are part of the same set should be preferred together, e.g. if the
+ * user selects a default APN with apnSetId=1, then we will prefer all APNs with apnSetId = 1.
+ *
+ * If the apnSetId = Carriers.NO_SET_SET(=0) then the APN is not part of a set.
+ *
+ * @return the APN set id
+ * @hide
+ */
+ public int getApnSetId() {
+ return mApnSetId;
+ }
+
+ /**
* Indicates this APN setting is permanently failed and cannot be
* retried by the retry manager anymore.
*
@@ -336,7 +375,7 @@ public class ApnSetting implements Parcelable {
}
/**
- * Returns the entry name of the APN.
+ * Gets the human-readable name that describes the APN.
*
* @return the entry name for the APN
*/
@@ -354,18 +393,32 @@ public class ApnSetting implements Parcelable {
}
/**
+ * Gets the HTTP proxy address configured for the APN. The proxy address might be an IP address
+ * or hostname. This method returns {@code null} if system networking (typically DNS) isn’t
+ * available to resolve a hostname value—values set as IP addresses don’t have this restriction.
+ * This is a known problem and will be addressed in a future release.
+ *
+ * @return the HTTP proxy address or {@code null} if DNS isn’t available to resolve a hostname
+ * @deprecated use {@link #getProxyAddressAsString()} instead.
+ */
+ @Deprecated
+ public InetAddress getProxyAddress() {
+ return inetAddressFromString(mProxyAddress);
+ }
+
+ /**
* Returns the proxy address of the APN.
*
* @return proxy address.
*/
- public InetAddress getProxyAddress() {
+ public String getProxyAddressAsString() {
return mProxyAddress;
}
/**
- * Returns the proxy port of the APN.
+ * Returns the proxy address of the APN.
*
- * @return proxy port
+ * @return proxy address.
*/
public int getProxyPort() {
return mProxyPort;
@@ -380,11 +433,25 @@ public class ApnSetting implements Parcelable {
}
/**
+ * Gets the MMS proxy address configured for the APN. The MMS proxy address might be an IP
+ * address or hostname. This method returns {@code null} if system networking (typically DNS)
+ * isn’t available to resolve a hostname value—values set as IP addresses don’t have this
+ * restriction. This is a known problem and will be addressed in a future release.
+ *
+ * @return the MMS proxy address or {@code null} if DNS isn’t available to resolve a hostname
+ * @deprecated use {@link #getMmsProxyAddressAsString()} instead.
+ */
+ @Deprecated
+ public InetAddress getMmsProxyAddress() {
+ return inetAddressFromString(mMmsProxyAddress);
+ }
+
+ /**
* Returns the MMS proxy address of the APN.
*
* @return MMS proxy address.
*/
- public InetAddress getMmsProxyAddress() {
+ public String getMmsProxyAddressAsString() {
return mMmsProxyAddress;
}
@@ -550,25 +617,27 @@ public class ApnSetting implements Parcelable {
this.mMaxConnsTime = builder.mMaxConnsTime;
this.mMvnoType = builder.mMvnoType;
this.mMvnoMatchData = builder.mMvnoMatchData;
+ this.mApnSetId = builder.mApnSetId;
}
/** @hide */
public static ApnSetting makeApnSetting(int id, String operatorNumeric, String entryName,
- String apnName, InetAddress proxy, int port, Uri mmsc, InetAddress mmsProxy,
- int mmsPort, String user, String password, int authType, int mApnTypeBitmask,
- int protocol, int roamingProtocol, boolean carrierEnabled,
- int networkTypeBitmask, int profileId, boolean modemCognitive, int maxConns,
- int waitTime, int maxConnsTime, int mtu, int mvnoType, String mvnoMatchData) {
+ String apnName, String proxyAddress, int proxyPort, Uri mmsc,
+ String mmsProxyAddress, int mmsProxyPort, String user, String password,
+ int authType, int mApnTypeBitmask, int protocol, int roamingProtocol,
+ boolean carrierEnabled, int networkTypeBitmask, int profileId, boolean modemCognitive,
+ int maxConns, int waitTime, int maxConnsTime, int mtu, int mvnoType,
+ String mvnoMatchData, int apnSetId) {
return new Builder()
.setId(id)
.setOperatorNumeric(operatorNumeric)
.setEntryName(entryName)
.setApnName(apnName)
- .setProxyAddress(proxy)
- .setProxyPort(port)
+ .setProxyAddress(proxyAddress)
+ .setProxyPort(proxyPort)
.setMmsc(mmsc)
- .setMmsProxyAddress(mmsProxy)
- .setMmsProxyPort(mmsPort)
+ .setMmsProxyAddress(mmsProxyAddress)
+ .setMmsProxyPort(mmsProxyPort)
.setUser(user)
.setPassword(password)
.setAuthType(authType)
@@ -585,12 +654,28 @@ public class ApnSetting implements Parcelable {
.setMtu(mtu)
.setMvnoType(mvnoType)
.setMvnoMatchData(mvnoMatchData)
- .build();
+ .setApnSetId(apnSetId)
+ .buildWithoutCheck();
+ }
+
+ /** @hide */
+ public static ApnSetting makeApnSetting(int id, String operatorNumeric, String entryName,
+ String apnName, String proxyAddress, int proxyPort, Uri mmsc,
+ String mmsProxyAddress, int mmsProxyPort, String user, String password,
+ int authType, int mApnTypeBitmask, int protocol, int roamingProtocol,
+ boolean carrierEnabled, int networkTypeBitmask, int profileId, boolean modemCognitive,
+ int maxConns, int waitTime, int maxConnsTime, int mtu, int mvnoType,
+ String mvnoMatchData) {
+ return makeApnSetting(id, operatorNumeric, entryName, apnName, proxyAddress, proxyPort,
+ mmsc, mmsProxyAddress, mmsProxyPort, user, password, authType, mApnTypeBitmask,
+ protocol, roamingProtocol, carrierEnabled, networkTypeBitmask, profileId,
+ modemCognitive, maxConns, waitTime, maxConnsTime, mtu, mvnoType, mvnoMatchData,
+ Carriers.NO_SET_SET);
}
/** @hide */
public static ApnSetting makeApnSetting(Cursor cursor) {
- final int apnTypesBitmask = parseTypes(
+ final int apnTypesBitmask = getApnTypesBitmaskFromString(
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.TYPE)));
int networkTypeBitmask = cursor.getInt(
cursor.getColumnIndexOrThrow(Telephony.Carriers.NETWORK_TYPE_BITMASK));
@@ -606,25 +691,25 @@ public class ApnSetting implements Parcelable {
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NUMERIC)),
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.NAME)),
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN)),
- inetAddressFromString(cursor.getString(
- cursor.getColumnIndexOrThrow(Telephony.Carriers.PROXY))),
+ cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.PROXY)),
portFromString(cursor.getString(
cursor.getColumnIndexOrThrow(Telephony.Carriers.PORT))),
UriFromString(cursor.getString(
cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSC))),
- inetAddressFromString(cursor.getString(
- cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPROXY))),
+ cursor.getString(
+ cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPROXY)),
portFromString(cursor.getString(
cursor.getColumnIndexOrThrow(Telephony.Carriers.MMSPORT))),
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.USER)),
cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PASSWORD)),
cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.AUTH_TYPE)),
apnTypesBitmask,
- nullToNotInMapInt(PROTOCOL_STRING_MAP.get(
- cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL)))),
- nullToNotInMapInt(PROTOCOL_STRING_MAP.get(
+ getProtocolIntFromString(
+ cursor.getString(cursor.getColumnIndexOrThrow(Telephony.Carriers.PROTOCOL))),
+ getProtocolIntFromString(
cursor.getString(cursor.getColumnIndexOrThrow(
- Telephony.Carriers.ROAMING_PROTOCOL)))),
+ Telephony.Carriers.ROAMING_PROTOCOL))),
cursor.getInt(cursor.getColumnIndexOrThrow(
Telephony.Carriers.CARRIER_ENABLED)) == 1,
networkTypeBitmask,
@@ -636,41 +721,225 @@ public class ApnSetting implements Parcelable {
cursor.getInt(cursor.getColumnIndexOrThrow(
Telephony.Carriers.MAX_CONNS_TIME)),
cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.MTU)),
- nullToNotInMapInt(MVNO_TYPE_STRING_MAP.get(
+ getMvnoTypeIntFromString(
cursor.getString(cursor.getColumnIndexOrThrow(
- Telephony.Carriers.MVNO_TYPE)))),
+ Telephony.Carriers.MVNO_TYPE))),
cursor.getString(cursor.getColumnIndexOrThrow(
- Telephony.Carriers.MVNO_MATCH_DATA)));
+ Telephony.Carriers.MVNO_MATCH_DATA)),
+ cursor.getInt(cursor.getColumnIndexOrThrow(Telephony.Carriers.APN_SET_ID)));
}
/** @hide */
public static ApnSetting makeApnSetting(ApnSetting apn) {
return makeApnSetting(apn.mId, apn.mOperatorNumeric, apn.mEntryName, apn.mApnName,
- apn.mProxyAddress, apn.mProxyPort, apn.mMmsc, apn.mMmsProxyAddress, apn.mMmsProxyPort, apn.mUser,
- apn.mPassword, apn.mAuthType, apn.mApnTypeBitmask, apn.mProtocol, apn.mRoamingProtocol,
- apn.mCarrierEnabled, apn.mNetworkTypeBitmask, apn.mProfileId,
- apn.mModemCognitive, apn.mMaxConns, apn.mWaitTime, apn.mMaxConnsTime, apn.mMtu,
- apn.mMvnoType, apn.mMvnoMatchData);
+ apn.mProxyAddress, apn.mProxyPort, apn.mMmsc, apn.mMmsProxyAddress,
+ apn.mMmsProxyPort, apn.mUser, apn.mPassword, apn.mAuthType, apn.mApnTypeBitmask,
+ apn.mProtocol, apn.mRoamingProtocol, apn.mCarrierEnabled, apn.mNetworkTypeBitmask,
+ apn.mProfileId, apn.mModemCognitive, apn.mMaxConns, apn.mWaitTime,
+ apn.mMaxConnsTime, apn.mMtu, apn.mMvnoType, apn.mMvnoMatchData, apn.mApnSetId);
}
- /** @hide */
+ /**
+ * Creates an ApnSetting object from a string.
+ *
+ * @param data the string to read.
+ *
+ * The string must be in one of two formats (newlines added for clarity,
+ * spaces are optional):
+ *
+ * v1 format:
+ * <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
+ * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
+ * <type>[| <type>...],
+ *
+ * v2 format:
+ * [ApnSettingV2] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
+ * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
+ * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>,
+ *
+ * v3 format:
+ * [ApnSettingV3] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
+ * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
+ * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>,
+ * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>,
+ * <mvnoType>, <mvnoMatchData>
+ *
+ * v4 format:
+ * [ApnSettingV4] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
+ * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
+ * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>,
+ * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>,
+ * <mvnoType>, <mvnoMatchData>, <networkTypeBitmask>
+ *
+ * v5 format:
+ * [ApnSettingV5] <carrier>, <apn>, <proxy>, <port>, <user>, <password>, <server>,
+ * <mmsc>, <mmsproxy>, <mmsport>, <mcc>, <mnc>, <authtype>,
+ * <type>[| <type>...], <protocol>, <roaming_protocol>, <carrierEnabled>, <bearerBitmask>,
+ * <profileId>, <modemCognitive>, <maxConns>, <waitTime>, <maxConnsTime>, <mtu>,
+ * <mvnoType>, <mvnoMatchData>, <networkTypeBitmask>, <apnSetId>
+ *
+ * Note that the strings generated by {@link #toString()} do not contain the username
+ * and password and thus cannot be read by this method.
+ *
+ * This method may return {@code null} if the input string is invalid.
+ *
+ * @hide
+ */
+ public static ApnSetting fromString(String data) {
+ if (data == null) return null;
+
+ int version;
+ // matches() operates on the whole string, so append .* to the regex.
+ if (data.matches(V5_FORMAT_REGEX + ".*")) {
+ version = 5;
+ data = data.replaceFirst(V5_FORMAT_REGEX, "");
+ } else if (data.matches(V4_FORMAT_REGEX + ".*")) {
+ version = 4;
+ data = data.replaceFirst(V4_FORMAT_REGEX, "");
+ } else if (data.matches(V3_FORMAT_REGEX + ".*")) {
+ version = 3;
+ data = data.replaceFirst(V3_FORMAT_REGEX, "");
+ } else if (data.matches(V2_FORMAT_REGEX + ".*")) {
+ version = 2;
+ data = data.replaceFirst(V2_FORMAT_REGEX, "");
+ } else {
+ version = 1;
+ }
+
+ String[] a = data.split("\\s*,\\s*");
+ if (a.length < 14) {
+ return null;
+ }
+
+ int authType;
+ try {
+ authType = Integer.parseInt(a[12]);
+ } catch (NumberFormatException e) {
+ authType = 0;
+ }
+
+ String[] typeArray;
+ String protocol, roamingProtocol;
+ boolean carrierEnabled;
+ int bearerBitmask = 0;
+ int networkTypeBitmask = 0;
+ int profileId = 0;
+ boolean modemCognitive = false;
+ int maxConns = 0;
+ int waitTime = 0;
+ int maxConnsTime = 0;
+ int mtu = UNSET_MTU;
+ String mvnoType = "";
+ String mvnoMatchData = "";
+ int apnSetId = Carriers.NO_SET_SET;
+ if (version == 1) {
+ typeArray = new String[a.length - 13];
+ System.arraycopy(a, 13, typeArray, 0, a.length - 13);
+ protocol = PROTOCOL_INT_MAP.get(PROTOCOL_IP);
+ roamingProtocol = PROTOCOL_INT_MAP.get(PROTOCOL_IP);
+ carrierEnabled = true;
+ } else {
+ if (a.length < 18) {
+ return null;
+ }
+ typeArray = a[13].split("\\s*\\|\\s*");
+ protocol = a[14];
+ roamingProtocol = a[15];
+ carrierEnabled = Boolean.parseBoolean(a[16]);
+
+ bearerBitmask = ServiceState.getBitmaskFromString(a[17]);
+
+ if (a.length > 22) {
+ modemCognitive = Boolean.parseBoolean(a[19]);
+ try {
+ profileId = Integer.parseInt(a[18]);
+ maxConns = Integer.parseInt(a[20]);
+ waitTime = Integer.parseInt(a[21]);
+ maxConnsTime = Integer.parseInt(a[22]);
+ } catch (NumberFormatException e) {
+ }
+ }
+ if (a.length > 23) {
+ try {
+ mtu = Integer.parseInt(a[23]);
+ } catch (NumberFormatException e) {
+ }
+ }
+ if (a.length > 25) {
+ mvnoType = a[24];
+ mvnoMatchData = a[25];
+ }
+ if (a.length > 26) {
+ networkTypeBitmask = ServiceState.getBitmaskFromString(a[26]);
+ }
+ if (a.length > 27) {
+ apnSetId = Integer.parseInt(a[27]);
+ }
+ }
+
+ // If both bearerBitmask and networkTypeBitmask were specified, bearerBitmask would be
+ // ignored.
+ if (networkTypeBitmask == 0) {
+ networkTypeBitmask =
+ ServiceState.convertBearerBitmaskToNetworkTypeBitmask(bearerBitmask);
+ }
+ return makeApnSetting(-1, a[10] + a[11], a[0], a[1], a[2],
+ portFromString(a[3]), UriFromString(a[7]), a[8],
+ portFromString(a[9]), a[4], a[5], authType,
+ getApnTypesBitmaskFromString(TextUtils.join(",", typeArray)),
+ getProtocolIntFromString(protocol), getProtocolIntFromString(roamingProtocol),
+ carrierEnabled, networkTypeBitmask, profileId, modemCognitive, maxConns, waitTime,
+ maxConnsTime, mtu, getMvnoTypeIntFromString(mvnoType), mvnoMatchData, apnSetId);
+ }
+
+ /**
+ * Creates an array of ApnSetting objects from a string.
+ *
+ * @param data the string to read.
+ *
+ * Builds on top of the same format used by fromString, but allows for multiple entries
+ * separated by ";".
+ *
+ * @hide
+ */
+ public static List<ApnSetting> arrayFromString(String data) {
+ List<ApnSetting> retVal = new ArrayList<ApnSetting>();
+ if (TextUtils.isEmpty(data)) {
+ return retVal;
+ }
+ String[] apnStrings = data.split("\\s*;\\s*");
+ for (String apnString : apnStrings) {
+ ApnSetting apn = fromString(apnString);
+ if (apn != null) {
+ retVal.add(apn);
+ }
+ }
+ return retVal;
+ }
+
+ /**
+ * Returns the string representation of ApnSetting.
+ *
+ * This method prints null for unset elements. The output doesn't contain password or user.
+ * @hide
+ */
public String toString() {
StringBuilder sb = new StringBuilder();
- sb.append("[ApnSettingV4] ")
+ sb.append("[ApnSettingV5] ")
.append(mEntryName)
.append(", ").append(mId)
.append(", ").append(mOperatorNumeric)
.append(", ").append(mApnName)
- .append(", ").append(inetAddressToString(mProxyAddress))
+ .append(", ").append(mProxyAddress)
.append(", ").append(UriToString(mMmsc))
- .append(", ").append(inetAddressToString(mMmsProxyAddress))
+ .append(", ").append(mMmsProxyAddress)
.append(", ").append(portToString(mMmsProxyPort))
.append(", ").append(portToString(mProxyPort))
.append(", ").append(mAuthType).append(", ");
- final String[] types = deParseTypes(mApnTypeBitmask).split(",");
- sb.append(TextUtils.join(" | ", types)).append(", ");
- sb.append(", ").append(mProtocol);
- sb.append(", ").append(mRoamingProtocol);
+ final String[] types = getApnTypesStringFromBitmask(mApnTypeBitmask).split(",");
+ sb.append(TextUtils.join(" | ", types));
+ sb.append(", ").append(PROTOCOL_INT_MAP.get(mProtocol));
+ sb.append(", ").append(PROTOCOL_INT_MAP.get(mRoamingProtocol));
sb.append(", ").append(mCarrierEnabled);
sb.append(", ").append(mProfileId);
sb.append(", ").append(mModemCognitive);
@@ -678,10 +947,11 @@ public class ApnSetting implements Parcelable {
sb.append(", ").append(mWaitTime);
sb.append(", ").append(mMaxConnsTime);
sb.append(", ").append(mMtu);
- sb.append(", ").append(mMvnoType);
+ sb.append(", ").append(MVNO_TYPE_INT_MAP.get(mMvnoType));
sb.append(", ").append(mMvnoMatchData);
sb.append(", ").append(mPermanentFailed);
sb.append(", ").append(mNetworkTypeBitmask);
+ sb.append(", ").append(mApnSetId);
return sb.toString();
}
@@ -690,22 +960,34 @@ public class ApnSetting implements Parcelable {
* @hide
*/
public boolean hasMvnoParams() {
- return (mMvnoType != NOT_IN_MAP_INT) && !TextUtils.isEmpty(mMvnoMatchData);
+ return !TextUtils.isEmpty(getMvnoTypeStringFromInt(mMvnoType))
+ && !TextUtils.isEmpty(mMvnoMatchData);
+ }
+
+ private boolean hasApnType(int type) {
+ return (mApnTypeBitmask & type) == type;
}
/** @hide */
public boolean canHandleType(@ApnType int type) {
- return mCarrierEnabled && ((mApnTypeBitmask & type) == type);
+ if (!mCarrierEnabled) {
+ return false;
+ }
+ // DEFAULT can handle HIPRI.
+ if (hasApnType(type) || (type == TYPE_HIPRI && hasApnType(TYPE_DEFAULT))) {
+ return true;
+ }
+ return false;
}
- // check whether the types of two APN same (even only one type of each APN is same)
+ // Check whether the types of two APN same (even only one type of each APN is same).
private boolean typeSameAny(ApnSetting first, ApnSetting second) {
if (VDBG) {
StringBuilder apnType1 = new StringBuilder(first.mApnName + ": ");
- apnType1.append(deParseTypes(first.mApnTypeBitmask));
+ apnType1.append(getApnTypesStringFromBitmask(first.mApnTypeBitmask));
StringBuilder apnType2 = new StringBuilder(second.mApnName + ": ");
- apnType2.append(deParseTypes(second.mApnTypeBitmask));
+ apnType2.append(getApnTypesStringFromBitmask(second.mApnTypeBitmask));
Rlog.d(LOG_TAG, "APN1: is " + apnType1);
Rlog.d(LOG_TAG, "APN2: is " + apnType2);
@@ -725,7 +1007,7 @@ public class ApnSetting implements Parcelable {
}
// TODO - if we have this function we should also have hashCode.
- // Also should handle changes in type order and perhaps case-insensitivity
+ // Also should handle changes in type order and perhaps case-insensitivity.
/** @hide */
public boolean equals(Object o) {
if (o instanceof ApnSetting == false) {
@@ -758,7 +1040,8 @@ public class ApnSetting implements Parcelable {
&& Objects.equals(mMtu, other.mMtu)
&& Objects.equals(mMvnoType, other.mMvnoType)
&& Objects.equals(mMvnoMatchData, other.mMvnoMatchData)
- && Objects.equals(mNetworkTypeBitmask, other.mNetworkTypeBitmask);
+ && Objects.equals(mNetworkTypeBitmask, other.mNetworkTypeBitmask)
+ && Objects.equals(mApnSetId, other.mApnSetId);
}
/**
@@ -802,7 +1085,8 @@ public class ApnSetting implements Parcelable {
&& Objects.equals(mMaxConnsTime, other.mMaxConnsTime)
&& Objects.equals(mMtu, other.mMtu)
&& Objects.equals(mMvnoType, other.mMvnoType)
- && Objects.equals(mMvnoMatchData, other.mMvnoMatchData);
+ && Objects.equals(mMvnoMatchData, other.mMvnoMatchData)
+ && Objects.equals(mApnSetId, other.mApnSetId);
}
/**
@@ -818,7 +1102,7 @@ public class ApnSetting implements Parcelable {
&& Objects.equals(this.mApnName, other.mApnName)
&& !typeSameAny(this, other)
&& xorEquals(this.mProxyAddress, other.mProxyAddress)
- && xorEqualsPort(this.mProxyPort, other.mProxyPort)
+ && xorEqualsInt(this.mProxyPort, other.mProxyPort)
&& xorEquals(this.mProtocol, other.mProtocol)
&& xorEquals(this.mRoamingProtocol, other.mRoamingProtocol)
&& Objects.equals(this.mCarrierEnabled, other.mCarrierEnabled)
@@ -827,86 +1111,86 @@ public class ApnSetting implements Parcelable {
&& Objects.equals(this.mMvnoMatchData, other.mMvnoMatchData)
&& xorEquals(this.mMmsc, other.mMmsc)
&& xorEquals(this.mMmsProxyAddress, other.mMmsProxyAddress)
- && xorEqualsPort(this.mMmsProxyPort, other.mMmsProxyPort))
- && Objects.equals(this.mNetworkTypeBitmask, other.mNetworkTypeBitmask);
- }
-
- // Equal or one is not specified.
- private boolean xorEquals(String first, String second) {
- return (Objects.equals(first, second)
- || TextUtils.isEmpty(first)
- || TextUtils.isEmpty(second));
+ && xorEqualsInt(this.mMmsProxyPort, other.mMmsProxyPort))
+ && Objects.equals(this.mNetworkTypeBitmask, other.mNetworkTypeBitmask)
+ && Objects.equals(mApnSetId, other.mApnSetId);
}
- // Equal or one is not null.
+ // Equal or one is null.
private boolean xorEquals(Object first, Object second) {
return first == null || second == null || first.equals(second);
}
// Equal or one is not specified.
- private boolean xorEqualsPort(int first, int second) {
- return first == NO_PORT_SPECIFIED || second == NO_PORT_SPECIFIED
+ private boolean xorEqualsInt(int first, int second) {
+ return first == UNSPECIFIED_INT || second == UNSPECIFIED_INT
|| Objects.equals(first, second);
}
- private String deParseTypes(int apnTypeBitmask) {
- List<String> types = new ArrayList<>();
- for (Integer type : APN_TYPE_INT_MAP.keySet()) {
- if ((apnTypeBitmask & type) == type) {
- types.add(APN_TYPE_INT_MAP.get(type));
- }
- }
- return TextUtils.join(",", types);
- }
-
private String nullToEmpty(String stringValue) {
- return stringValue == null ? "" : stringValue;
+ return stringValue == null ? UNSPECIFIED_STRING : stringValue;
}
- /** @hide */
- // Called by DPM.
+ /**
+ * @hide
+ * Called by {@link android.app.admin.DevicePolicyManager} to convert this APN into
+ * ContentValue. If a field is not specified then we put "" instead of null.
+ */
public ContentValues toContentValues() {
ContentValues apnValue = new ContentValues();
apnValue.put(Telephony.Carriers.NUMERIC, nullToEmpty(mOperatorNumeric));
apnValue.put(Telephony.Carriers.NAME, nullToEmpty(mEntryName));
apnValue.put(Telephony.Carriers.APN, nullToEmpty(mApnName));
- apnValue.put(Telephony.Carriers.PROXY, mProxyAddress == null ? ""
- : inetAddressToString(mProxyAddress));
- apnValue.put(Telephony.Carriers.PORT, portToString(mProxyPort));
- apnValue.put(Telephony.Carriers.MMSC, mMmsc == null ? "" : UriToString(mMmsc));
- apnValue.put(Telephony.Carriers.MMSPORT, portToString(mMmsProxyPort));
- apnValue.put(Telephony.Carriers.MMSPROXY, mMmsProxyAddress == null
- ? "" : inetAddressToString(mMmsProxyAddress));
+ apnValue.put(Telephony.Carriers.PROXY, nullToEmpty(mProxyAddress));
+ apnValue.put(Telephony.Carriers.PORT, nullToEmpty(portToString(mProxyPort)));
+ apnValue.put(Telephony.Carriers.MMSC, nullToEmpty(UriToString(mMmsc)));
+ apnValue.put(Telephony.Carriers.MMSPORT, nullToEmpty(portToString(mMmsProxyPort)));
+ apnValue.put(Telephony.Carriers.MMSPROXY, nullToEmpty(
+ mMmsProxyAddress));
apnValue.put(Telephony.Carriers.USER, nullToEmpty(mUser));
apnValue.put(Telephony.Carriers.PASSWORD, nullToEmpty(mPassword));
apnValue.put(Telephony.Carriers.AUTH_TYPE, mAuthType);
- String apnType = deParseTypes(mApnTypeBitmask);
+ String apnType = getApnTypesStringFromBitmask(mApnTypeBitmask);
apnValue.put(Telephony.Carriers.TYPE, nullToEmpty(apnType));
apnValue.put(Telephony.Carriers.PROTOCOL,
- nullToEmpty(PROTOCOL_INT_MAP.get(mProtocol)));
+ getProtocolStringFromInt(mProtocol));
apnValue.put(Telephony.Carriers.ROAMING_PROTOCOL,
- nullToEmpty(PROTOCOL_INT_MAP.get(mRoamingProtocol)));
+ getProtocolStringFromInt(mRoamingProtocol));
apnValue.put(Telephony.Carriers.CARRIER_ENABLED, mCarrierEnabled);
- apnValue.put(Telephony.Carriers.MVNO_TYPE,
- nullToEmpty(MVNO_TYPE_INT_MAP.get(mMvnoType)));
+ apnValue.put(Telephony.Carriers.MVNO_TYPE, getMvnoTypeStringFromInt(mMvnoType));
apnValue.put(Telephony.Carriers.NETWORK_TYPE_BITMASK, mNetworkTypeBitmask);
return apnValue;
}
/**
- * @param types comma delimited list of APN types
- * @return bitmask of APN types
+ * @param apnTypeBitmask bitmask of APN types.
+ * @return comma delimited list of APN types.
* @hide
*/
- public static int parseTypes(String types) {
+ public static String getApnTypesStringFromBitmask(int apnTypeBitmask) {
+ List<String> types = new ArrayList<>();
+ for (Integer type : APN_TYPE_INT_MAP.keySet()) {
+ if ((apnTypeBitmask & type) == type) {
+ types.add(APN_TYPE_INT_MAP.get(type));
+ }
+ }
+ return TextUtils.join(",", types);
+ }
+
+ /**
+ * @param types comma delimited list of APN types.
+ * @return bitmask of APN types.
+ * @hide
+ */
+ public static int getApnTypesBitmaskFromString(String types) {
// If unset, set to ALL.
if (TextUtils.isEmpty(types)) {
- return TYPE_ALL_BUT_IA;
+ return TYPE_ALL;
} else {
int result = 0;
for (String str : types.split(",")) {
- Integer type = APN_TYPE_STRING_MAP.get(str);
+ Integer type = APN_TYPE_STRING_MAP.get(str.toLowerCase());
if (type != null) {
result |= type;
}
@@ -915,15 +1199,40 @@ public class ApnSetting implements Parcelable {
}
}
+ /** @hide */
+ public static int getMvnoTypeIntFromString(String mvnoType) {
+ Integer mvnoTypeInt = MVNO_TYPE_STRING_MAP.get(mvnoType);
+ return mvnoTypeInt == null ? UNSPECIFIED_INT : mvnoTypeInt;
+ }
+
+ /** @hide */
+ public static String getMvnoTypeStringFromInt(int mvnoType) {
+ String mvnoTypeString = MVNO_TYPE_INT_MAP.get(mvnoType);
+ return mvnoTypeString == null ? UNSPECIFIED_STRING : mvnoTypeString;
+ }
+
+ /** @hide */
+ public static int getProtocolIntFromString(String protocol) {
+ Integer protocolInt = PROTOCOL_STRING_MAP.get(protocol);
+ return protocolInt == null ? UNSPECIFIED_INT : protocolInt;
+ }
+
+ /** @hide */
+ public static String getProtocolStringFromInt(int protocol) {
+ String protocolString = PROTOCOL_INT_MAP.get(protocol);
+ return protocolString == null ? UNSPECIFIED_STRING : protocolString;
+ }
+
private static Uri UriFromString(String uri) {
return TextUtils.isEmpty(uri) ? null : Uri.parse(uri);
}
private static String UriToString(Uri uri) {
- return uri == null ? "" : uri.toString();
+ return uri == null ? null : uri.toString();
}
- private static InetAddress inetAddressFromString(String inetAddress) {
+ /** @hide */
+ public static InetAddress inetAddressFromString(String inetAddress) {
if (TextUtils.isEmpty(inetAddress)) {
return null;
}
@@ -935,7 +1244,8 @@ public class ApnSetting implements Parcelable {
}
}
- private static String inetAddressToString(InetAddress inetAddress) {
+ /** @hide */
+ public static String inetAddressToString(InetAddress inetAddress) {
if (inetAddress == null) {
return null;
}
@@ -952,7 +1262,7 @@ public class ApnSetting implements Parcelable {
}
private static int portFromString(String strPort) {
- int port = NO_PORT_SPECIFIED;
+ int port = UNSPECIFIED_INT;
if (!TextUtils.isEmpty(strPort)) {
try {
port = Integer.parseInt(strPort);
@@ -964,7 +1274,7 @@ public class ApnSetting implements Parcelable {
}
private static String portToString(int port) {
- return port == NO_PORT_SPECIFIED ? "" : Integer.toString(port);
+ return port == UNSPECIFIED_INT ? null : Integer.toString(port);
}
// Implement Parcelable.
@@ -981,10 +1291,10 @@ public class ApnSetting implements Parcelable {
dest.writeString(mOperatorNumeric);
dest.writeString(mEntryName);
dest.writeString(mApnName);
- dest.writeValue(mProxyAddress);
+ dest.writeString(mProxyAddress);
dest.writeInt(mProxyPort);
dest.writeValue(mMmsc);
- dest.writeValue(mMmsProxyAddress);
+ dest.writeString(mMmsProxyAddress);
dest.writeInt(mMmsProxyPort);
dest.writeString(mUser);
dest.writeString(mPassword);
@@ -992,7 +1302,7 @@ public class ApnSetting implements Parcelable {
dest.writeInt(mApnTypeBitmask);
dest.writeInt(mProtocol);
dest.writeInt(mRoamingProtocol);
- dest.writeInt(mCarrierEnabled ? 1: 0);
+ dest.writeBoolean(mCarrierEnabled);
dest.writeInt(mMvnoType);
dest.writeInt(mNetworkTypeBitmask);
}
@@ -1002,10 +1312,10 @@ public class ApnSetting implements Parcelable {
final String operatorNumeric = in.readString();
final String entryName = in.readString();
final String apnName = in.readString();
- final InetAddress proxy = (InetAddress)in.readValue(InetAddress.class.getClassLoader());
+ final String proxy = in.readString();
final int port = in.readInt();
final Uri mmsc = (Uri)in.readValue(Uri.class.getClassLoader());
- final InetAddress mmsProxy = (InetAddress)in.readValue(InetAddress.class.getClassLoader());
+ final String mmsProxy = in.readString();
final int mmsPort = in.readInt();
final String user = in.readString();
final String password = in.readString();
@@ -1013,7 +1323,7 @@ public class ApnSetting implements Parcelable {
final int apnTypesBitmask = in.readInt();
final int protocol = in.readInt();
final int roamingProtocol = in.readInt();
- final boolean carrierEnabled = in.readInt() > 0;
+ final boolean carrierEnabled = in.readBoolean();
final int mvnoType = in.readInt();
final int networkTypeBitmask = in.readInt();
@@ -1036,26 +1346,55 @@ public class ApnSetting implements Parcelable {
}
};
- private static int nullToNotInMapInt(Integer value) {
- return value == null ? NOT_IN_MAP_INT : value;
- }
-
+ /**
+ * Provides a convenient way to set the fields of a {@link ApnSetting} when creating a new
+ * instance. The following settings are required to build an {@code ApnSetting}:
+ *
+ * <ul><li>apnTypeBitmask</li>
+ * <li>apnName</li>
+ * <li>entryName</li></ul>
+ *
+ * <p>The example below shows how you might create a new {@code ApnSetting}:
+ *
+ * <pre><code>
+ * // Create an MMS proxy address with a hostname. A network might not be
+ * // available, so supply a dummy (0.0.0.0) IPv4 address to avoid DNS lookup.
+ * String host = "mms.example.com";
+ * byte[] ipAddress = new byte[4];
+ * InetAddress mmsProxy;
+ * try {
+ * mmsProxy = InetAddress.getByAddress(host, ipAddress);
+ * } catch (UnknownHostException e) {
+ * e.printStackTrace();
+ * return;
+ * }
+ *
+ * ApnSetting apn = new ApnSetting.Builder()
+ * .setApnTypeBitmask(ApnSetting.TYPE_DEFAULT | ApnSetting.TYPE_MMS)
+ * .setApnName("apn.example.com")
+ * .setEntryName("Example Carrier APN")
+ * .setMmsc(Uri.parse("http://mms.example.com:8002"))
+ * .setMmsProxyAddress(mmsProxy)
+ * .setMmsProxyPort(8799)
+ * .build();
+ * </code></pre>
+ */
public static class Builder{
private String mEntryName;
private String mApnName;
- private InetAddress mProxyAddress;
- private int mProxyPort = NO_PORT_SPECIFIED;
+ private String mProxyAddress;
+ private int mProxyPort = UNSPECIFIED_INT;
private Uri mMmsc;
- private InetAddress mMmsProxyAddress;
- private int mMmsProxyPort = NO_PORT_SPECIFIED;
+ private String mMmsProxyAddress;
+ private int mMmsProxyPort = UNSPECIFIED_INT;
private String mUser;
private String mPassword;
private int mAuthType;
private int mApnTypeBitmask;
private int mId;
private String mOperatorNumeric;
- private int mProtocol = NOT_IN_MAP_INT;
- private int mRoamingProtocol = NOT_IN_MAP_INT;
+ private int mProtocol = UNSPECIFIED_INT;
+ private int mRoamingProtocol = UNSPECIFIED_INT;
private int mMtu;
private int mNetworkTypeBitmask;
private boolean mCarrierEnabled;
@@ -1064,8 +1403,9 @@ public class ApnSetting implements Parcelable {
private int mMaxConns;
private int mWaitTime;
private int mMaxConnsTime;
- private int mMvnoType = NOT_IN_MAP_INT;
+ private int mMvnoType = UNSPECIFIED_INT;
private String mMvnoMatchData;
+ private int mApnSetId;
/**
* Default constructor for Builder.
@@ -1160,7 +1500,18 @@ public class ApnSetting implements Parcelable {
}
/**
- * Sets the entry name of the APN.
+ * Sets the APN set id for the APN.
+ *
+ * @param apnSetId the set id for the APN
+ * @hide
+ */
+ public Builder setApnSetId(int apnSetId) {
+ this.mApnSetId = apnSetId;
+ return this;
+ }
+
+ /**
+ * Sets a human-readable name that describes the APN.
*
* @param entryName the entry name to set for the APN
*/
@@ -1180,11 +1531,31 @@ public class ApnSetting implements Parcelable {
}
/**
- * Sets the proxy address of the APN.
+ * Sets the address of an HTTP proxy for the APN. The proxy address can be an IP address or
+ * hostname. If {@code proxy} contains both an IP address and hostname, this method ignores
+ * the IP address.
+ *
+ * <p>The {@link java.net.InetAddress} methods
+ * {@link java.net.InetAddress#getAllByName getAllByName()} require DNS for hostname
+ * resolution. To avoid this requirement when setting a hostname, call
+ * {@link java.net.InetAddress#getByAddress(java.lang.String, byte[])} with both the
+ * hostname and a dummy IP address. See {@link ApnSetting.Builder above} for an example.
*
* @param proxy the proxy address to set for the APN
+ * @deprecated use {@link #setProxyAddress(String)} instead.
*/
+ @Deprecated
public Builder setProxyAddress(InetAddress proxy) {
+ this.mProxyAddress = inetAddressToString(proxy);
+ return this;
+ }
+
+ /**
+ * Sets the proxy address of the APN.
+ *
+ * @param proxy the proxy address to set for the APN
+ */
+ public Builder setProxyAddress(String proxy) {
this.mProxyAddress = proxy;
return this;
}
@@ -1210,11 +1581,32 @@ public class ApnSetting implements Parcelable {
}
/**
- * Sets the MMS proxy address of the APN.
+ * Sets the address of an MMS proxy for the APN. The MMS proxy address can be an IP address
+ * or hostname. If {@code mmsProxy} contains both an IP address and hostname, this method
+ * ignores the IP address.
+ *
+ * <p>The {@link java.net.InetAddress} methods
+ * {@link java.net.InetAddress#getByName getByName()} and
+ * {@link java.net.InetAddress#getAllByName getAllByName()} require DNS for hostname
+ * resolution. To avoid this requirement when setting a hostname, call
+ * {@link java.net.InetAddress#getByAddress(java.lang.String, byte[])} with both the
+ * hostname and a dummy IP address. See {@link ApnSetting.Builder above} for an example.
*
* @param mmsProxy the MMS proxy address to set for the APN
+ * @deprecated use {@link #setMmsProxyAddress(String)} instead.
*/
+ @Deprecated
public Builder setMmsProxyAddress(InetAddress mmsProxy) {
+ this.mMmsProxyAddress = inetAddressToString(mmsProxy);
+ return this;
+ }
+
+ /**
+ * Sets the MMS proxy address of the APN.
+ *
+ * @param mmsProxy the MMS proxy address to set for the APN
+ */
+ public Builder setMmsProxyAddress(String mmsProxy) {
this.mMmsProxyAddress = mmsProxy;
return this;
}
@@ -1356,6 +1748,15 @@ public class ApnSetting implements Parcelable {
}
return new ApnSetting(this);
}
+
+ /**
+ * Builds {@link ApnSetting} from this builder. This function doesn't check if
+ * {@link #setApnName(String)} or {@link #setEntryName(String)}, or
+ * {@link #setApnTypeBitmask(int)} is empty.
+ * @hide
+ */
+ public ApnSetting buildWithoutCheck() {
+ return new ApnSetting(this);
+ }
}
}
-
diff --git a/telephony/java/com/android/internal/telephony/CarrierAppUtils.java b/telephony/java/com/android/internal/telephony/CarrierAppUtils.java
index 676684cdfbbd..bcad554b579f 100644
--- a/telephony/java/com/android/internal/telephony/CarrierAppUtils.java
+++ b/telephony/java/com/android/internal/telephony/CarrierAppUtils.java
@@ -152,14 +152,9 @@ public final class CarrierAppUtils {
&& (ai.enabledSetting ==
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
|| ai.enabledSetting ==
- PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
- || (ai.flags & ApplicationInfo.FLAG_INSTALLED) == 0)) {
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED)) {
Slog.i(TAG, "Update state(" + packageName + "): ENABLED for user "
+ userId);
- packageManager.setSystemAppInstallState(
- packageName,
- true /*installed*/,
- userId);
packageManager.setApplicationEnabledSetting(
packageName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
@@ -175,14 +170,9 @@ public final class CarrierAppUtils {
if (associatedApp.enabledSetting ==
PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
|| associatedApp.enabledSetting ==
- PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED
- || (ai.flags & ApplicationInfo.FLAG_INSTALLED) == 0) {
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED) {
Slog.i(TAG, "Update associated state(" + associatedApp.packageName
+ "): ENABLED for user " + userId);
- packageManager.setSystemAppInstallState(
- associatedApp.packageName,
- true /*installed*/,
- userId);
packageManager.setApplicationEnabledSetting(
associatedApp.packageName,
PackageManager.COMPONENT_ENABLED_STATE_ENABLED,
@@ -200,14 +190,15 @@ public final class CarrierAppUtils {
// updated we shouldn't touch it.
if (!ai.isUpdatedSystemApp()
&& ai.enabledSetting ==
- PackageManager.COMPONENT_ENABLED_STATE_DEFAULT
- && (ai.flags & ApplicationInfo.FLAG_INSTALLED) != 0) {
+ PackageManager.COMPONENT_ENABLED_STATE_DEFAULT) {
Slog.i(TAG, "Update state(" + packageName
+ "): DISABLED_UNTIL_USED for user " + userId);
- packageManager.setSystemAppInstallState(
+ packageManager.setApplicationEnabledSetting(
packageName,
- false /*installed*/,
- userId);
+ PackageManager.COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED,
+ 0,
+ userId,
+ callingPackage);
}
// Also disable any associated apps for this carrier app if this is the first
@@ -222,10 +213,13 @@ public final class CarrierAppUtils {
Slog.i(TAG,
"Update associated state(" + associatedApp.packageName
+ "): DISABLED_UNTIL_USED for user " + userId);
- packageManager.setSystemAppInstallState(
+ packageManager.setApplicationEnabledSetting(
associatedApp.packageName,
- false /*installed*/,
- userId);
+ PackageManager
+ .COMPONENT_ENABLED_STATE_DISABLED_UNTIL_USED,
+ 0,
+ userId,
+ callingPackage);
}
}
}
@@ -363,8 +357,7 @@ public final class CarrierAppUtils {
String packageName) {
try {
ApplicationInfo ai = packageManager.getApplicationInfo(packageName,
- PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS
- | PackageManager.MATCH_HIDDEN_UNTIL_INSTALLED_COMPONENTS, userId);
+ PackageManager.MATCH_DISABLED_UNTIL_USED_COMPONENTS, userId);
if (ai != null && ai.isSystemApp()) {
return ai;
}
diff --git a/telephony/java/com/android/internal/telephony/uicc/IccUtils.java b/telephony/java/com/android/internal/telephony/uicc/IccUtils.java
index c0954385a0a3..4790b75d9630 100644
--- a/telephony/java/com/android/internal/telephony/uicc/IccUtils.java
+++ b/telephony/java/com/android/internal/telephony/uicc/IccUtils.java
@@ -105,7 +105,7 @@ public class IccUtils {
/**
* PLMN (MCC/MNC) is encoded as per 24.008 10.5.1.3
* Returns a concatenated string of MCC+MNC, stripping
- * all invalid character 'f'
+ * all invalid character 'F'
*/
public static String bcdPlmnToString(byte[] data, int offset) {
if (offset + 3 > data.length) {
@@ -117,9 +117,9 @@ public class IccUtils {
trans[2] = (byte) ((data[2 + offset] & 0xF0) | ((data[1 + offset] >> 4) & 0xF));
String ret = bytesToHexString(trans);
- // For a valid plmn we trim all character 'f'
- if (ret.contains("f")) {
- ret = ret.replaceAll("f", "");
+ // For a valid plmn we trim all character 'F'
+ if (ret.contains("F")) {
+ ret = ret.replaceAll("F", "");
}
return ret;
}
diff --git a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
index 1ae318a96a50..653282d0d365 100644
--- a/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
+++ b/tests/MemoryUsage/src/com/android/tests/memoryusage/MemoryUsageTest.java
@@ -18,7 +18,9 @@ package com.android.tests.memoryusage;
import android.app.ActivityManager;
import android.app.ActivityManager.ProcessErrorStateInfo;
import android.app.ActivityManager.RunningAppProcessInfo;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
+import android.app.IActivityTaskManager;
import android.app.UiAutomation;
import android.content.Context;
import android.content.Intent;
@@ -66,6 +68,7 @@ public class MemoryUsageTest extends InstrumentationTestCase {
private Map<String, String> mNameToResultKey;
private Set<String> mPersistentProcesses;
private IActivityManager mAm;
+ private IActivityTaskManager mAtm;
@Override
protected void setUp() throws Exception {
@@ -84,6 +87,7 @@ public class MemoryUsageTest extends InstrumentationTestCase {
(MemoryUsageInstrumentation) getInstrumentation();
Bundle args = instrumentation.getBundle();
mAm = ActivityManager.getService();
+ mAtm = ActivityTaskManager.getService();
createMappings();
parseArgs(args);
@@ -316,7 +320,7 @@ public class MemoryUsageTest extends InstrumentationTestCase {
UserHandle.USER_CURRENT);
}
- mAm.startActivityAndWait(null, null, mLaunchIntent, mimeType,
+ mAtm.startActivityAndWait(null, null, mLaunchIntent, mimeType,
null, null, 0, mLaunchIntent.getFlags(), null, null,
UserHandle.USER_CURRENT_OR_SELF);
} catch (RemoteException e) {
diff --git a/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java b/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
index e573d3586653..102cb7c77055 100644
--- a/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
+++ b/tests/net/java/com/android/server/IpSecServiceParameterizedTest.java
@@ -50,6 +50,7 @@ import java.util.Arrays;
import java.util.Collection;
import org.junit.Before;
+import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
@@ -592,6 +593,7 @@ public class IpSecServiceParameterizedTest {
}
}
+ @Ignore
@Test
public void testAddTunnelFailsForBadPackageName() throws Exception {
try {
diff --git a/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java b/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java
index 89bd8d8f1dd4..548a0c22c569 100644
--- a/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java
+++ b/tests/permission/src/com/android/framework/permission/tests/ActivityManagerPermissionTests.java
@@ -17,6 +17,7 @@
package com.android.framework.permission.tests;
import android.app.ActivityManager;
+import android.app.ActivityTaskManager;
import android.app.IActivityManager;
import android.content.res.Configuration;
import android.os.RemoteException;
@@ -47,22 +48,12 @@ public class ActivityManagerPermissionTests extends TestCase {
} catch (RemoteException e) {
fail("Unexpected remote exception");
}
-
- try {
- mAm.moveTaskBackwards(-1);
- fail("IActivityManager.moveTaskToFront did not throw SecurityException as"
- + " expected");
- } catch (SecurityException e) {
- // expected
- } catch (RemoteException e) {
- fail("Unexpected remote exception");
- }
}
@SmallTest
public void testCHANGE_CONFIGURATION() {
try {
- mAm.updateConfiguration(new Configuration());
+ ActivityTaskManager.getService().updateConfiguration(new Configuration());
fail("IActivityManager.updateConfiguration did not throw SecurityException as"
+ " expected");
} catch (SecurityException e) {
diff --git a/tools/aapt2/ResourceParser.cpp b/tools/aapt2/ResourceParser.cpp
index 089c9e284570..ef5912bfad92 100644
--- a/tools/aapt2/ResourceParser.cpp
+++ b/tools/aapt2/ResourceParser.cpp
@@ -777,7 +777,8 @@ std::unique_ptr<Item> ResourceParser::ParseXml(xml::XmlPullParser* parser,
if (allow_raw_value) {
// We can't parse this so return a RawString if we are allowed.
return util::make_unique<RawString>(
- table_->string_pool.MakeRef(raw_value, StringPool::Context(config_)));
+ table_->string_pool.MakeRef(util::TrimWhitespace(raw_value),
+ StringPool::Context(config_)));
}
return {};
}
diff --git a/tools/aapt2/ResourceParser_test.cpp b/tools/aapt2/ResourceParser_test.cpp
index 41b4041efb7a..5711dc35d423 100644
--- a/tools/aapt2/ResourceParser_test.cpp
+++ b/tools/aapt2/ResourceParser_test.cpp
@@ -497,6 +497,24 @@ TEST_F(ResourceParserTest, ParseStyleWithPackageAliasedItems) {
EXPECT_THAT(style->entries[0].key.name, Eq(make_value(test::ParseNameOrDie("android:attr/bar"))));
}
+TEST_F(ResourceParserTest, ParseStyleWithRawStringItem) {
+ std::string input = R"(
+ <style name="foo">
+ <item name="bar">
+ com.helloworld.AppClass
+ </item>
+ </style>)";
+ ASSERT_TRUE(TestParse(input));
+
+ Style* style = test::GetValue<Style>(&table_, "style/foo");
+ ASSERT_THAT(style, NotNull());
+ EXPECT_THAT(style->entries[0].value, NotNull());
+ RawString* value = ValueCast<RawString>(style->entries[0].value.get());
+ EXPECT_THAT(value, NotNull());
+ EXPECT_THAT(*value->value, StrEq(R"(com.helloworld.AppClass)"));
+}
+
+
TEST_F(ResourceParserTest, ParseStyleWithInferredParent) {
ASSERT_TRUE(TestParse(R"(<style name="foo.bar"/>)"));
diff --git a/tools/aapt2/java/ProguardRules.cpp b/tools/aapt2/java/ProguardRules.cpp
index 2857d5a2d90e..d03cdb3d8518 100644
--- a/tools/aapt2/java/ProguardRules.cpp
+++ b/tools/aapt2/java/ProguardRules.cpp
@@ -79,8 +79,10 @@ class BaseVisitor : public xml::Visitor {
keep_set_->AddConditionalClass({file_.name, file_.source.WithLine(line_number)}, class_name);
}
- void AddMethod(size_t line_number, const std::string& method_name) {
- keep_set_->AddMethod({file_.name, file_.source.WithLine(line_number)}, method_name);
+ void AddMethod(size_t line_number, const std::string& method_name,
+ const std::string& method_signature) {
+ keep_set_->AddMethod({file_.name, file_.source.WithLine(line_number)},
+ {method_name, method_signature});
}
void AddReference(size_t line_number, Reference* ref) {
@@ -125,7 +127,7 @@ class LayoutVisitor : public BaseVisitor {
AddClass(node->line_number, attr.value);
} else if (attr.namespace_uri == xml::kSchemaAndroid &&
attr.name == "onClick") {
- AddMethod(node->line_number, attr.value);
+ AddMethod(node->line_number, attr.value, "android.view.View");
}
}
@@ -149,7 +151,7 @@ class MenuVisitor : public BaseVisitor {
util::IsJavaClassName(attr.value)) {
AddClass(node->line_number, attr.value);
} else if (attr.name == "onClick") {
- AddMethod(node->line_number, attr.value);
+ AddMethod(node->line_number, attr.value, "android.view.MenuItem");
}
}
}
@@ -365,7 +367,7 @@ void WriteKeepSet(const KeepSet& keep_set, OutputStream* out) {
for (const UsageLocation& location : entry.second) {
printer.Print("# Referenced at ").Println(location.source.to_string());
}
- printer.Print("-keep class ").Print(entry.first).Println(" { <init>(...); }");
+ printer.Print("-keep class ").Print(entry.first).Println(" { <init>(); }");
}
for (const auto& entry : keep_set.conditional_class_set_) {
@@ -396,7 +398,8 @@ void WriteKeepSet(const KeepSet& keep_set, OutputStream* out) {
for (const UsageLocation& location : entry.second) {
printer.Print("# Referenced at ").Println(location.source.to_string());
}
- printer.Print("-keepclassmembers class * { *** ").Print(entry.first).Println("(...); }");
+ printer.Print("-keepclassmembers class * { *** ").Print(entry.first.name)
+ .Print("(").Print(entry.first.signature).Println("); }");
printer.Println();
}
}
diff --git a/tools/aapt2/java/ProguardRules.h b/tools/aapt2/java/ProguardRules.h
index 343272e4362a..acaceac41237 100644
--- a/tools/aapt2/java/ProguardRules.h
+++ b/tools/aapt2/java/ProguardRules.h
@@ -40,6 +40,11 @@ struct UsageLocation {
Source source;
};
+struct NameAndSignature {
+ std::string name;
+ std::string signature;
+};
+
class KeepSet {
public:
KeepSet() = default;
@@ -55,8 +60,8 @@ class KeepSet {
conditional_class_set_[class_name].insert(file);
}
- inline void AddMethod(const UsageLocation& file, const std::string& method_name) {
- method_set_[method_name].insert(file);
+ inline void AddMethod(const UsageLocation& file, const NameAndSignature& name_and_signature) {
+ method_set_[name_and_signature].insert(file);
}
inline void AddReference(const UsageLocation& file, const ResourceName& resource_name) {
@@ -71,7 +76,7 @@ class KeepSet {
bool conditional_keep_rules_ = false;
std::map<std::string, std::set<UsageLocation>> manifest_class_set_;
- std::map<std::string, std::set<UsageLocation>> method_set_;
+ std::map<NameAndSignature, std::set<UsageLocation>> method_set_;
std::map<std::string, std::set<UsageLocation>> conditional_class_set_;
std::map<ResourceName, std::set<UsageLocation>> reference_set_;
};
@@ -100,6 +105,20 @@ inline int operator<(const UsageLocation& lhs, const UsageLocation& rhs) {
return lhs.name.compare(rhs.name);
}
+//
+// NameAndSignature implementation.
+//
+
+inline bool operator<(const NameAndSignature& lhs, const NameAndSignature& rhs) {
+ if (lhs.name < rhs.name) {
+ return true;
+ }
+ if (lhs.name == rhs.name) {
+ return lhs.signature < rhs.signature;
+ }
+ return false;
+}
+
} // namespace proguard
} // namespace aapt
diff --git a/tools/aapt2/java/ProguardRules_test.cpp b/tools/aapt2/java/ProguardRules_test.cpp
index 876c7a76d3f5..b5e27e0cb952 100644
--- a/tools/aapt2/java/ProguardRules_test.cpp
+++ b/tools/aapt2/java/ProguardRules_test.cpp
@@ -34,6 +34,31 @@ std::string GetKeepSetString(const proguard::KeepSet& set) {
return out;
}
+TEST(ProguardRulesTest, ManifestRuleDefaultConstructorOnly) {
+ std::unique_ptr<xml::XmlResource> manifest = test::BuildXmlDom(R"(
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android">
+ <application android:backupAgent="com.foo.BarBackupAgent">
+ <activity android:name="com.foo.BarActivity"/>
+ <service android:name="com.foo.BarService"/>
+ <receiver android:name="com.foo.BarReceiver"/>
+ <provider android:name="com.foo.BarProvider"/>
+ </application>
+ <instrumentation android:name="com.foo.BarInstrumentation"/>
+ </manifest>)");
+
+ proguard::KeepSet set;
+ ASSERT_TRUE(proguard::CollectProguardRulesForManifest(manifest.get(), &set, false));
+
+ std::string actual = GetKeepSetString(set);
+
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarBackupAgent { <init>(); }"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarActivity { <init>(); }"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarService { <init>(); }"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarReceiver { <init>(); }"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarProvider { <init>(); }"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.BarInstrumentation { <init>(); }"));
+}
+
TEST(ProguardRulesTest, FragmentNameRuleIsEmitted) {
std::unique_ptr<IAaptContext> context = test::ContextBuilder().Build();
std::unique_ptr<xml::XmlResource> layout = test::BuildXmlDom(R"(
@@ -46,7 +71,7 @@ TEST(ProguardRulesTest, FragmentNameRuleIsEmitted) {
std::string actual = GetKeepSetString(set);
- EXPECT_THAT(actual, HasSubstr("com.foo.Bar"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.Bar { <init>(...); }"));
}
TEST(ProguardRulesTest, FragmentClassRuleIsEmitted) {
@@ -60,7 +85,7 @@ TEST(ProguardRulesTest, FragmentClassRuleIsEmitted) {
std::string actual = GetKeepSetString(set);
- EXPECT_THAT(actual, HasSubstr("com.foo.Bar"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.Bar { <init>(...); }"));
}
TEST(ProguardRulesTest, FragmentNameAndClassRulesAreEmitted) {
@@ -76,8 +101,8 @@ TEST(ProguardRulesTest, FragmentNameAndClassRulesAreEmitted) {
std::string actual = GetKeepSetString(set);
- EXPECT_THAT(actual, HasSubstr("com.foo.Bar"));
- EXPECT_THAT(actual, HasSubstr("com.foo.Baz"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.Bar { <init>(...); }"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.Baz { <init>(...); }"));
}
TEST(ProguardRulesTest, NavigationFragmentNameAndClassRulesAreEmitted) {
@@ -103,9 +128,9 @@ TEST(ProguardRulesTest, NavigationFragmentNameAndClassRulesAreEmitted) {
ASSERT_TRUE(proguard::CollectProguardRules(context.get(), navigation.get(), &set));
std::string actual = GetKeepSetString(set);
- EXPECT_THAT(actual, HasSubstr("com.package.Foo"));
- EXPECT_THAT(actual, HasSubstr("com.package.Bar"));
- EXPECT_THAT(actual, HasSubstr("com.base.Nested"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.package.Foo { <init>(...); }"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.package.Bar { <init>(...); }"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.base.Nested { <init>(...); }"));
}
TEST(ProguardRulesTest, CustomViewRulesAreEmitted) {
@@ -121,7 +146,7 @@ TEST(ProguardRulesTest, CustomViewRulesAreEmitted) {
std::string actual = GetKeepSetString(set);
- EXPECT_THAT(actual, HasSubstr("com.foo.Bar"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.Bar { <init>(...); }"));
}
TEST(ProguardRulesTest, IncludedLayoutRulesAreConditional) {
@@ -162,7 +187,6 @@ TEST(ProguardRulesTest, IncludedLayoutRulesAreConditional) {
EXPECT_THAT(actual, HasSubstr("-keep class com.foo.Bar { <init>(...); }"));
EXPECT_THAT(actual, HasSubstr("int foo"));
EXPECT_THAT(actual, HasSubstr("int bar"));
- EXPECT_THAT(actual, HasSubstr("com.foo.Bar"));
}
TEST(ProguardRulesTest, AliasedLayoutRulesAreConditional) {
@@ -183,7 +207,6 @@ TEST(ProguardRulesTest, AliasedLayoutRulesAreConditional) {
EXPECT_THAT(actual, HasSubstr("-if class **.R$layout"));
EXPECT_THAT(actual, HasSubstr("int foo"));
EXPECT_THAT(actual, HasSubstr("int bar"));
- EXPECT_THAT(actual, HasSubstr("com.foo.Bar"));
}
TEST(ProguardRulesTest, NonLayoutReferencesAreUnconditional) {
@@ -216,7 +239,8 @@ TEST(ProguardRulesTest, ViewOnClickRuleIsEmitted) {
std::string actual = GetKeepSetString(set);
- EXPECT_THAT(actual, HasSubstr("bar_method"));
+ EXPECT_THAT(actual, HasSubstr(
+ "-keepclassmembers class * { *** bar_method(android.view.View); }"));
}
TEST(ProguardRulesTest, MenuRulesAreEmitted) {
@@ -235,10 +259,43 @@ TEST(ProguardRulesTest, MenuRulesAreEmitted) {
std::string actual = GetKeepSetString(set);
- EXPECT_THAT(actual, HasSubstr("on_click"));
- EXPECT_THAT(actual, HasSubstr("com.foo.Bar"));
- EXPECT_THAT(actual, HasSubstr("com.foo.Baz"));
+ EXPECT_THAT(actual, HasSubstr(
+ "-keepclassmembers class * { *** on_click(android.view.MenuItem); }"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.Bar { <init>(...); }"));
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.Baz { <init>(...); }"));
EXPECT_THAT(actual, Not(HasSubstr("com.foo.Bat")));
}
+TEST(ProguardRulesTest, TransitionPathMotionRulesAreEmitted) {
+ std::unique_ptr<IAaptContext> context = test::ContextBuilder().Build();
+ std::unique_ptr<xml::XmlResource> transition = test::BuildXmlDom(R"(
+ <changeBounds>
+ <pathMotion class="com.foo.Bar"/>
+ </changeBounds>)");
+ transition->file.name = test::ParseNameOrDie("transition/foo");
+
+ proguard::KeepSet set;
+ ASSERT_TRUE(proguard::CollectProguardRules(context.get(), transition.get(), &set));
+
+ std::string actual = GetKeepSetString(set);
+
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.Bar { <init>(...); }"));
+}
+
+TEST(ProguardRulesTest, TransitionRulesAreEmitted) {
+ std::unique_ptr<IAaptContext> context = test::ContextBuilder().Build();
+ std::unique_ptr<xml::XmlResource> transitionSet = test::BuildXmlDom(R"(
+ <transitionSet>
+ <transition class="com.foo.Bar"/>
+ </transitionSet>)");
+ transitionSet->file.name = test::ParseNameOrDie("transition/foo");
+
+ proguard::KeepSet set;
+ ASSERT_TRUE(proguard::CollectProguardRules(context.get(), transitionSet.get(), &set));
+
+ std::string actual = GetKeepSetString(set);
+
+ EXPECT_THAT(actual, HasSubstr("-keep class com.foo.Bar { <init>(...); }"));
+}
+
} // namespace aapt
diff --git a/tools/apilint/apilint.py b/tools/apilint/apilint.py
index 70a47cf42755..9db3f0271598 100644
--- a/tools/apilint/apilint.py
+++ b/tools/apilint/apilint.py
@@ -1334,18 +1334,25 @@ def verify_clone(clazz):
error(clazz, m, None, "Provide an explicit copy constructor instead of implementing clone()")
+def is_interesting(clazz):
+ """Test if given class is interesting from an Android PoV."""
+
+ if clazz.pkg.name.startswith("java"): return False
+ if clazz.pkg.name.startswith("junit"): return False
+ if clazz.pkg.name.startswith("org.apache"): return False
+ if clazz.pkg.name.startswith("org.xml"): return False
+ if clazz.pkg.name.startswith("org.json"): return False
+ if clazz.pkg.name.startswith("org.w3c"): return False
+ if clazz.pkg.name.startswith("android.icu."): return False
+ return True
+
+
def examine_clazz(clazz):
"""Find all style issues in the given class."""
notice(clazz)
- if clazz.pkg.name.startswith("java"): return
- if clazz.pkg.name.startswith("junit"): return
- if clazz.pkg.name.startswith("org.apache"): return
- if clazz.pkg.name.startswith("org.xml"): return
- if clazz.pkg.name.startswith("org.json"): return
- if clazz.pkg.name.startswith("org.w3c"): return
- if clazz.pkg.name.startswith("android.icu."): return
+ if not is_interesting(clazz): return
verify_constants(clazz)
verify_enums(clazz)
@@ -1479,6 +1486,7 @@ def show_deprecations_at_birth(cur, prev):
# Remove all existing things so we're left with new
for prev_clazz in prev.values():
cur_clazz = cur[prev_clazz.fullname]
+ if not is_interesting(cur_clazz): continue
sigs = { i.ident: i for i in prev_clazz.ctors }
cur_clazz.ctors = [ i for i in cur_clazz.ctors if i.ident not in sigs ]
@@ -1506,6 +1514,38 @@ def show_deprecations_at_birth(cur, prev):
print
+def show_stats(cur, prev):
+ """Show API stats."""
+
+ stats = collections.defaultdict(int)
+ for cur_clazz in cur.values():
+ if not is_interesting(cur_clazz): continue
+
+ if cur_clazz.fullname not in prev:
+ stats['new_classes'] += 1
+ stats['new_ctors'] += len(cur_clazz.ctors)
+ stats['new_methods'] += len(cur_clazz.methods)
+ stats['new_fields'] += len(cur_clazz.fields)
+ else:
+ prev_clazz = prev[cur_clazz.fullname]
+
+ sigs = { i.ident: i for i in prev_clazz.ctors }
+ ctors = len([ i for i in cur_clazz.ctors if i.ident not in sigs ])
+ sigs = { i.ident: i for i in prev_clazz.methods }
+ methods = len([ i for i in cur_clazz.methods if i.ident not in sigs ])
+ sigs = { i.ident: i for i in prev_clazz.fields }
+ fields = len([ i for i in cur_clazz.fields if i.ident not in sigs ])
+
+ if ctors + methods + fields > 0:
+ stats['extend_classes'] += 1
+ stats['extend_ctors'] += ctors
+ stats['extend_methods'] += methods
+ stats['extend_fields'] += fields
+
+ print "#", "".join([ k.ljust(20) for k in sorted(stats.keys()) ])
+ print " ", "".join([ str(stats[k]).ljust(20) for k in sorted(stats.keys()) ])
+
+
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Enforces common Android public API design \
patterns. It ignores lint messages from a previous API level, if provided.")
@@ -1520,6 +1560,8 @@ if __name__ == "__main__":
help="Show API changes noticed")
parser.add_argument("--show-deprecations-at-birth", action='store_const', const=True,
help="Show API deprecations at birth")
+ parser.add_argument("--show-stats", action='store_const', const=True,
+ help="Show API stats")
args = vars(parser.parse_args())
if args['no_color']:
@@ -1539,6 +1581,14 @@ if __name__ == "__main__":
show_deprecations_at_birth(cur, prev)
sys.exit()
+ if args['show_stats']:
+ with current_file as f:
+ cur = _parse_stream(f)
+ with previous_file as f:
+ prev = _parse_stream(f)
+ show_stats(cur, prev)
+ sys.exit()
+
with current_file as f:
cur_fail, cur_noticed = examine_stream(f)
if not previous_file is None:
diff --git a/tools/apilint/apilint_stats.sh b/tools/apilint/apilint_stats.sh
new file mode 100755
index 000000000000..052d9a5265fe
--- /dev/null
+++ b/tools/apilint/apilint_stats.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+API=28
+while [ $API -gt 14 ]; do
+ echo "# Changes in API $((API))"
+ python tools/apilint/apilint.py --show-stats ../../prebuilts/sdk/$((API))/public/api/android.txt ../../prebuilts/sdk/$((API-1))/public/api/android.txt
+ let API=API-1
+done
diff --git a/tools/stats_log_api_gen/Android.bp b/tools/stats_log_api_gen/Android.bp
index 280afadebc0f..703a67b791be 100644
--- a/tools/stats_log_api_gen/Android.bp
+++ b/tools/stats_log_api_gen/Android.bp
@@ -106,6 +106,7 @@ cc_library_shared {
shared_libs: [
"liblog",
"libutils",
+ "libcutils",
],
static_libs: ["libstatssocket"],
}
diff --git a/tools/stats_log_api_gen/main.cpp b/tools/stats_log_api_gen/main.cpp
index 1f13cc274efa..e519909aa026 100644
--- a/tools/stats_log_api_gen/main.cpp
+++ b/tools/stats_log_api_gen/main.cpp
@@ -104,6 +104,7 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms,
fprintf(out, "#include <mutex>\n");
fprintf(out, "#include <chrono>\n");
fprintf(out, "#include <thread>\n");
+ fprintf(out, "#include <cutils/properties.h>\n");
fprintf(out, "#include <stats_event_list.h>\n");
fprintf(out, "#include <log/log.h>\n");
fprintf(out, "#include <statslog.h>\n");
@@ -114,6 +115,7 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms,
fprintf(out, "namespace util {\n");
fprintf(out, "// the single event tag id for all stats logs\n");
fprintf(out, "const static int kStatsEventTag = 1937006964;\n");
+ fprintf(out, "const static bool kStatsdEnabled = property_get_bool(\"ro.statsd.enable\", true);\n");
std::set<string> kTruncatingAtomNames = {"mobile_radio_power_state_changed",
"audio_state_changed",
@@ -242,6 +244,7 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms,
fprintf(out, "{\n");
argIndex = 1;
+ fprintf(out, " if (kStatsdEnabled) {\n");
fprintf(out, " stats_event_list event(kStatsEventTag);\n");
fprintf(out, " event << android::elapsedRealtimeNano();\n\n");
fprintf(out, " event << code;\n\n");
@@ -286,6 +289,9 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms,
}
fprintf(out, " return event.write(LOG_ID_STATS);\n");
+ fprintf(out, " } else {\n");
+ fprintf(out, " return 1;\n");
+ fprintf(out, " }\n");
fprintf(out, "}\n");
fprintf(out, "\n");
}
@@ -375,6 +381,7 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms,
fprintf(out, "{\n");
argIndex = 1;
+ fprintf(out, " if (kStatsdEnabled) {\n");
fprintf(out, " stats_event_list event(kStatsEventTag);\n");
fprintf(out, " event << android::elapsedRealtimeNano();\n\n");
fprintf(out, " event << code;\n\n");
@@ -398,6 +405,9 @@ static int write_stats_log_cpp(FILE *out, const Atoms &atoms,
}
fprintf(out, " return event.write(LOG_ID_STATS);\n");
+ fprintf(out, " } else {\n");
+ fprintf(out, " return 1;\n");
+ fprintf(out, " }\n");
fprintf(out, "}\n");
fprintf(out, "\n");
}
@@ -1261,4 +1271,4 @@ main(int argc, char const*const* argv)
GOOGLE_PROTOBUF_VERIFY_VERSION;
return android::stats_log_api_gen::run(argc, argv);
-} \ No newline at end of file
+}