517 Commits

Author SHA1 Message Date
Austin Borger
45081ab6a0 Merge changes from topics "b124224342", "change_procstate_flag" into tm-dev
* changes:
  Add new onUidProcAdjChanged callback to be consumed by the camera service.
  Modify UidRecord.CHANGE_PROCSTATE such that it behaves like a bit mask.
2022-03-29 21:52:36 +00:00
Austin Borger
db9165baf2 Add new onUidProcAdjChanged callback to be consumed by the camera
service.

The camera service needs to know when individual process oom adj scores
are changed in order to address bug #124224342. When two separate
processes are displayed in split screen and focus is switched between
them, both proc states will remain the same while their oom scores
change. This is a problem if both have access to the camera - we want
only one owner of the camera stream at any given time and for the app
in focus to be the one to own it.

This patch adds a new IUidObserver registration level for individual
process oom score changes. In addition a new callback has been added to
IUidObserver to track these changes.

Change-Id: I68d964f474d20f819f54b614a4e314ce00aac8fb
Bug: 124224342
Test: -- ActivityManagerServiceTest
      -- ActivityManagerProcessStateTest
      -- ActivityManagerFgsBgStartTest
      -- UidObserverControllerTest
      -- NetworkPolicyManagerServiceTest
      -- ShortcutManagerTest2
      -- HintManagerServiceTest
      -- VibrationSettingsTest
      -- CameraEvictionTest#testCamera2AccessCallbackInSplitMode (x100)
2022-03-28 19:46:45 -07:00
Sudheer Shanka
9ef2c906e8 Add "clear-last-used-timestamps" command to usagestats service.
Bug: 206518483
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: Ieeedb17182ea93e162e2d7fb2d53169f2cc70e3a
2022-03-23 18:46:50 +00:00
Sudheer Shanka
4b61ecc716 Merge "Add ACCESS_BROADCAST_RESPONSE_STATS permission." into tm-dev 2022-03-19 05:14:21 +00:00
Sudheer Shanka
be82be6e88 Add ACCESS_BROADCAST_RESPONSE_STATS permission.
Instead of re-using PACKAGE_USAGE_STATS permission,
we are creating a new permission to guard access to
broadcast response stats.

For now, we check both permissions until the clients
migrate to using the new permission.

Bug: 225039700
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: I65965b647da5994f434167693df999bc939807e2
2022-03-16 18:05:04 -07:00
Sudheer Shanka
4bf375b8dc Add a hidden API to query appstandby constants.
This will allow the tests to query the value for
appstandby constants that are last known to
the AppStandbyController.

Bug: 221176951
Test: atest ./tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: I8175c9f0acbc44b25606b477c6db8b0edf85991d
2022-03-09 14:31:06 -08:00
Kweku Adams
386362eb1b Merge "Let settings query an app's minimum bucket." into tm-dev 2022-03-02 17:55:45 +00:00
Kweku Adams
9d999938df Let settings query an app's minimum bucket.
Bug: 156509848
Test: manual
Change-Id: Ife3869524f93b3341fa6eb1379619142ede5ca73
2022-02-28 20:47:47 +00:00
Sudheer Shanka
1ce3e3fa31 Add some recent broadcast and notification events to the dumpsys.
Bug: 197654954
Test: manual
Change-Id: I5a67894c38253711d1eac98ee7bdb32545f5908c
2022-02-25 17:57:40 -08:00
Sudheer Shanka
d807ffe41f Add an API to bulk query broadcast response stats for all pkgs.
Bug: 217567456
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: I12853fdfb8a7b70eac935cf6aab23a388d2b7005
2022-02-15 15:45:17 -08:00
Sudheer Shanka
768522945d Add a missing return statement.
Bug: 206518114
Test: manual
Change-Id: Iadb13f6b64e19fef84310aeefd39c5e4d71d1882
2022-02-02 14:03:47 -08:00
Sudheer Shanka
918d724386 Make broadcast response fg threshold state configurable.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: Ic28b25393b8ff7d50164535722567d1a4e34f102
2022-01-31 10:40:16 -08:00
Sudheer Shanka
d1e5fabaa9 Track broadcast dispatched event only when the app is in the bg.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: Ic017fff35d800a1ea9b4288421e021859f443b30
2022-01-28 16:27:57 -08:00
Sudheer Shanka
cc59c25bd1 Make broadcast response window duration configurable.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: Ifc6792e969304967af7019483fdd1ec242bd2a83
2022-01-28 07:22:30 +00:00
Sudheer Shanka
ea2378808e Add some debug logging to UsageStatsService.
Bug: 197654954
Test: manual
Change-Id: If693714280998c7d057b1649f6d99c57c664b1ce
2022-01-27 19:24:21 +00:00
Sudheer Shanka
7ce974c2b2 Add APIs for querying broadcast response stats.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
CTS-Coverage-Bug: 206518114
Change-Id: Idcefc143215a372a7bd786fcb2208a7c26f2f7e2
2022-01-26 08:10:56 +00:00
Sudheer Shanka
5373a2e698 Merge changes Idde09e4c,I0337b400
* changes:
  Inform UsageStatsManager about notification related events.
  Allow reporting certain events to UsageStatsManager.
2022-01-24 22:13:30 +00:00
Sudheer Shanka
4e50889197 Allow reporting certain events to UsageStatsManager.
Add methods to allow reporting broadcast-dispatched,
notification-posted, notification-updated,
notification-removed events to UsageStatsManager.

Bug: 206518114
Test: atest --test-mapping apex/jobscheduler/service/java/com/android/server/usage/TEST_MAPPING
Change-Id: I0337b4004505930d21f4ef669e79ba4512b9792b
2022-01-24 09:22:43 -08:00
Neharika Jali
f29cf7bbb5 Makes constants related to cache configurable via DeviceConfig API
Bug: 214343564
Test: atest installd_cache_test, atest StorageManagerBaseTest, atest
StorageManagerTest#testComputeStorageCacheBytes

Change-Id: Ie977b8798e7169471c407621535ca1ca8feb6fec
2022-01-20 10:42:36 +00:00
Neharika Jali
967094148d Merge "In low storage, recalculate cache quotas if 2% change in total space" 2021-12-16 08:14:52 +00:00
Neharika Jali
d5af2ead56 In low storage, recalculate cache quotas if 2% change in total space
Bug: 203651230
Test: manual
Change-Id: Ie5df873f41e0bd0beca430b8e8ec51d5305bb844
2021-12-08 05:33:39 +00:00
Kweku Adams
e566f33a82 Add SystemApi to change app launch time estimates.
An SystemApis that allow a prediction app to update app launch time
estimates.

Bug: 194532703
Test: atest CtsPermissionTestCases:AppIdleStatePermissionTest
Test: atest CtsPermission2TestCases
Change-Id: I0fde220fa038f7f1f4d543a8906e92ca625bf097
2021-12-01 12:40:40 -08:00
Varun Shah
c755331c56 Merge "Update deletion conditions for a package's UsageStats." 2021-11-10 16:51:41 +00:00
Neharika Jali
044731c451 recalculate cache quotas when an app is uninstalled
Bug: 203651114
Test: manual
Change-Id: I81081a1efc6272b41babc64288592765c55ff9ac
2021-11-10 12:32:44 +00:00
Varun Shah
9af940970d Update deletion conditions for a package's UsageStats.
If a profile owner is defined for a specific user, do not delete usage
stats for a package on package deletion.

Bug: 197399948
Test: atest UserUsageStatsServiceTest
Test: atest UsageStatsTest [all]
Change-Id: I94a8e3dfca8ef4c7616f77944d61726e06043b85
2021-11-08 17:55:31 -08:00
Neharika Jali
eb406946e4 Merge "Recalculating cache quotas every 10 hours" 2021-11-08 12:10:28 +00:00
Neharika Jali
945ec1e647 Recalculating cache quotas every 10 hours
Bug: 203651640
Test: manual
Change-Id: I7d8065fcfa619b66d89e70f71f3ea726032f1995
2021-11-07 12:55:36 +00:00
Kweku Adams
4d0d1dd6e8 Revert "Revert "Add basic launch time prediction.""
This reverts commit 3785977ca6f5e4fd34c1dd26a53841144e063a3e.

Reason for revert: Fixing

Change-Id: I31425d8086e3f1d1d806b84e9339d0acd3f420d4
2021-11-04 21:07:05 +00:00
Jakub Pawlowski
3785977ca6 Revert "Add basic launch time prediction."
This reverts commit cc590ac913b5ea11e5338714076fa5f2083cd7ee.

Reason for revert: breakage of errorprone build

Change-Id: I0a896a2637521b36df2a132b8209f4fab23946ad
2021-11-04 16:02:21 +00:00
Kweku Adams
cc590ac913 Add basic launch time prediction.
We estimate the next app launch time by looking at the past 7 days of
usage history and assuming that the user opens the app like clockwork.
If there is at least 24 hours of usage events, then we take the earliest
ACTIVITY_RESUMED event and estimate that the app will be launched
exactly 7 days after that event. If there is less than 24 hours of
history (which would be the case for a new app), then we take the
earliest ACTIVITY_RESUMED and add 24 hours. If we don't see any launch
event in the past 7 days, then we just say the app should be launched
within a year. If we have a long estimate for an app and it is launched,
then we re-evaluate our estimate because we can now estimate a launch
within the next 7 days.

Bug: 194532703
Test: atest FrameworksMockingServicesTests:PrefetchControllerTest
Test: manually launch apps and check dumpsys for expected launch time changes
Change-Id: I9ef5fc3e3df3c2d029243b1fb8949a4bf21900db
2021-11-02 16:18:14 -07:00
Kweku Adams
72754e5847 Address small inefficiencies.
1. Don't hold the lock for validation checks that don't need it.
2. Put early returns ahead of other work when possible.

Bug: 203811598
Test: atest frameworks/base/services/tests/servicestests/src/com/android/server/usage
Test: atest frameworks/base/services/tests/mockingservicestests/src/com/android/server/usage
Change-Id: Ic923db1534e27e0932e594b8259fe482772b8a6a
2021-10-21 14:09:07 -07:00
Varun Shah
53ba8ca01c Update mUserUnlockedStates locking and docs.
Bug: n/a
Change-Id: If210e0012ebc838183c3ca6b82ded9aae21f62b2
Test: atest UsageStatsTest
2021-10-07 22:29:24 +00:00
TreeHugger Robot
118ebd79ac Merge "Fix to obtain current updated value of available bytes" 2021-09-27 11:01:18 +00:00
Kweku Adams
4d16dcbca5 Remove redundant method.
UsageEvents.getAppStandbyBucket() and .getStandbyBucket() are the exact
same (except for the name). Remove the hidden one.

Bug: 135214188
Test: Android builds
Change-Id: I1c42228fe31e9d978df1cb5feda04a2c0a542904
2021-09-24 10:10:13 -07:00
Neharika Jali
2f882be37c Fix to obtain current updated value of available bytes
Bug: 199378831
Test: manual
Change-Id: Ibe9dc762dd1740e4fa1a34b5a7d5b23d73b25282
2021-09-10 12:31:42 +00:00
Jonathan Nguyen
85a22d00e9 Replace class with empty string for AppUsageEventOccurred Atom
Bug: 196052707
Test: atest CtsStatsdAtomHostTestCases:UidAtomTests#testAppForegroundBackground
Change-Id: Ib916c6698024070000975031c0ba401f7b41ad4c
2021-08-19 15:00:11 -07:00
TreeHugger Robot
3624ed78fd Merge "Enforce permissions check in getLastTimeAnyComponentUsed" into sc-dev am: dbdd7012bc am: 29f69e43bb
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/15084728

Change-Id: Ib176042519dd83be639f7fb5ee87c83297123c0f
2021-06-24 06:51:19 +00:00
Zhen Zhang
bdac90593f Enforce permissions check in getLastTimeAnyComponentUsed
Enforce the permission check for both INTERACT_ACROSS_USERS and
PACKAGE_USAGE_STATS permissions.

Bug: 191382775
Test: atest CtsUsageStatsTestCases:UsageStatsTest
Change-Id: I1371070478306005b2b4a59a1bc794bc368ae0c4
2021-06-23 16:34:50 -07:00
Treehugger Robot
394caebaa4 Merge "Add OWNERS for StorageStats related code." am: 1050f27b56 am: fc716dbc8b am: 4c2e19766f am: d0b6abbfa8
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1716368

Change-Id: Iecda649c7f940cd21123b9e4963364cc36ee80a2
2021-05-26 00:20:37 +00:00
Treehugger Robot
4c2e19766f Merge "Add OWNERS for StorageStats related code." am: 1050f27b56 am: fc716dbc8b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/1716368

Change-Id: Ib34358f3baae6a233475f83f2db3770d91c849e4
2021-05-25 23:39:02 +00:00
Sudheer Shanka
2910735d59 Add OWNERS for StorageStats related code.
Test: n/a
Change-Id: Idc16f09a5aa3b56af232c12f267614eaad94d9e4
2021-05-25 00:14:23 +00:00
Alexander Dorokhine
91ff2270dc Merge "Unhide the storage attribution API with system visibility." into sc-dev am: 48df6c6055
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14414648

Change-Id: I996a30abfa6a51d5e732e1a8849af3fae532578a
2021-05-11 18:11:01 +00:00
Alexander Dorokhine
610afe52c4 Unhide the storage attribution API with system visibility.
Bug: 179160886
Test: StorageStatsManagerLocalTest
Change-Id: I3a8994e215baff123df65d89d2d71b9e12de2af5
2021-05-10 15:59:31 -07:00
TreeHugger Robot
970d36e647 Merge "Handle STOPPED to PAUSED Usage events" into sc-dev am: 80bd76c77a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14256468

Change-Id: I67a56cded5421384f5abb83f9f50825a7c58ff32
2021-04-29 23:02:47 +00:00
TreeHugger Robot
80bd76c77a Merge "Handle STOPPED to PAUSED Usage events" into sc-dev 2021-04-29 23:02:08 +00:00
Varun Shah
e106890957 Merge "Use direct-callback alarms in AppTimeLimitController." into sc-dev am: 3cb4aa35a9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14140806

Change-Id: I0e59aff3ced22cc4367ac9709cc32a8da911ec95
2021-04-22 19:37:55 +00:00
Varun Shah
3288a170f7 Use direct-callback alarms in AppTimeLimitController.
Update SessionUsageGroups to use direct-callback alarms.

Bug: 181983817
Test: atest AppTimeLimitControllerTests
Change-Id: I73a755cb9a893952cef33c0d7cc1b2c0bf2a1318
2021-04-21 16:36:04 -07:00
Michael Wachenschwanz
289f167929 Handle STOPPED to PAUSED Usage events
UsageStatsService wrongly assumed a ACTIVITY_PAUSED event must be
preceded by a ACTIVITY_RESUMED event, but there are some scenarios where
it is possibly to go directly from STOPPED to PAUSED.

Fixes: 182007710
Test: manual (start a pip activity, turn off the screen, and turn it
back on. UsageStats logs should not report unexpected events.)
Test: atest android.app.usage.cts.UsageStatsTest

Change-Id: I609ecb574d8401ab597aa61ba7c3b9d1f4e66827
2021-04-20 16:31:15 -07:00
Suprabh Shukla
1698c0705e Merge "Suspend dialog improvememts" into sc-dev am: 9da117df72
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/14150368

Change-Id: Icda2d764a05d9ec22cf7622a731cd94040e559c0
2021-04-14 00:08:56 +00:00
Suprabh Shukla
9da117df72 Merge "Suspend dialog improvememts" into sc-dev 2021-04-13 23:57:38 +00:00