Tweaking the returned result from the boundary condition in
closestIndexOnOrAfter to be conceptually similar to
closestIndexOnOrBefore. This should also make it simpler to use by
callers.
Also exposing the class more broadly by moving it to android.util
Test: atest FrameworksCoreTests:TimeSparseArrayTest
Bug: 195684213
Change-Id: I44a06db8792d590be0eea4de39bc81387f2baac8
Make sure mUsageEventListeners is always accessed while holding an
appropriate lock.
Bug: 247635314
Test: Android builds
Change-Id: Ia649f1724836f09020ae438bbdcfbe45c71b6784
The ArrayEquals, ArrayHashCode, ArrayToString, and
ArraysAsListPrimitiveArray errorprone findings were
demoted from errors to warnings. Fix existing
occurrences of them so they can be made errors again.
Bug: 242630963
Test: RUN_ERROR_PRONE=true m javac-check
Change-Id: Ia6f216cc36ad0a5758f39fd9b34962cd4adf9d8e
Some classes of devices will not have auto power save modes enabled. On
those devices, we should skip tests that require the modes be enabled.
Bug: 240108412
Bug: 240630396
Test: Manually go through CTS-V "Ignore Battery Optimizations Test"
Test: atest CtsUsageStatsTestCases:UsageStatsTest
Change-Id: Icc64fbe75213386a1f41fae258e50c4032920b0a
An instant app should be able to get its own standby bucket.
Fix: 237446222
Test: atest CtsUsageStatsTestCases
Test: atest CtsUsageStatsTestCases --module-parameter instant_app
Change-Id: I00ec091f3d6d51283d3a230f3bcfe2185763ac9d
When apps are restored, set their standby bucket to RARE if
they have been used within the past 90 days, based on the
restored UsageStats data.
Bug: 214580000
Test: atest UsageStatsDatabaseTest
Change-Id: I9d63032ef84fef97734b51323f41b797caa4f554
(cherry picked from commit 89f69113ad)
When apps are restored, set their standby bucket to RARE if
they have been used within the past 90 days, based on the
restored UsageStats data.
Bug: 214580000
Test: atest UsageStatsDatabaseTest
Change-Id: I9d63032ef84fef97734b51323f41b797caa4f554
If a pre-created user is removed before it becomes a full user, the
ACTION_USER_REMOVED intent is never sent, so UsageStatsService is never
notified that the user's pending events should be discarded. It will
eventually try to persist the events. As the first step, it tries to
create /data/system_de/$userId/usagestats and the parent directory
/data/system_de/$userId if it doesn't already exist.
However, due to https://r.android.com/2078213 the SELinux policy no
longer allows system_server to create /data/system_de/$userId. The
failure to create this directory is causing UsageStatsService to throw
an IllegalStateException which crashes system_server.
(Before the sepolicy change, system_server could create
/data/system_de/$userId, so the crash wouldn't have happened. But
problems still might have occurred if the user ID was reused.)
The underlying user state tracking bug still needs to be fixed. For
now, just avoid crashing system_server unnecessarily, and avoid an
SELinux denial by using mkdir() instead of mkdirs().
Test: pm create-user --pre-create-only
pm remove-user 10
# Wait 20 minutes and check logcat.
Bug: 234059731
Change-Id: Ic5efc19cda6b820a2c07f77b4f316d501acb9e80
For the purposes of tracking whether there is a response event
from an app after receiving a broadcast, treat all broadcasts
received by the app immediately after each other into a single
session and when there is a response event, then treat as if
the app received only one broadcast and there is one response
event corresponding to that.
Bug: 206518114
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: I4c495d07026a4d6ab445ce463bd1b07e9a89bd06
When we added the new ACCESS_BROADCAST_RESPONSE_STATS
permission, we updated the new broadcast response
related APIs to check both PACKAGE_USAGE_STATS and
ACCESS_BROADCAST_RESPONSE_STATS permissions until clients
are udpated to use the new permission. We can now remove
the logic for checking PACKAGE_USAGE_STATS permission and
only consider ACCESS_BROADCAST_RESPONSE_STATS.
Bug: 225039700
Test: atest tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Change-Id: I5b8e8565b936b26463110ce1f0368122c322e632
/data/system_de is only for per-user data; it *must* only contain
per-user encrypted directories. Only vold should ever create anything
directly in this directory. In preparation for removing system_server's
write access to this directory (https://r.android.com/2078213), make
UsageStatsService store its globalcomponentusage file at
/data/system/usagestats/globalcomponentusage instead of
/data/system_de/usagestats/globalcomponentusage.
Migration happens lazily, except that the old file and directory aren't
ever deleted since the SELinux policy will no longer allow system_server
to do that; the old file just stops being used. vold will need to
handle the cleanup instead, or we could just leave the file around.
Note that before Android 11, UsageStatsService stored per-user stats in
/data/system/usagestats/$userId. These per-user stats are *not* the
same thing as globalcomponentusage, which was added in Android 12.
UsageStatsService contains code to migrate the per-user stats to
/data/system_ce/$userId/usagestats. This is fine, and is the right
thing to do, since the per-user stats are potentially sensitive per-user
data. This does mean that UsageStatsService now implements two types of
migrations, and that the source directory for one migration is the
target directory for the other, which is a bit unfortunate. However,
since different files are involved in each one, it all works out.
Bug: 156305599
Change-Id: I53c16640e8ed8b7eac111990f1cdb3f59579e051
Since we restrict access to instant app data in usage stats (by
replacing instant app's package name with a placeholder name), we
should also filter out this data when getting standby bucket with
a given package name. This gives the callers a way to tell if the
instant app exists or not.
Bug: 217561828
Bug: 217740016
Test: atest CtsUsageStatsTestCases
Test: manually using the PoC in the buganizer to ensure the symptom
no longer exists.
Change-Id: I091e65c01d184b9df02fda29c64ac61787077fdb
Track pending estimated launch time changes in a single Set so that we
avoid sending repeat notifications for a single package.
Bug: 227796747
Test: atest CtsUsageStatsTestCases:UsageStatsTest
Test: atest FrameworksCoreTests:android.util.SparseSetArrayTest
Test: atest FrameworksMockingServicesTests:PrefetchControllerTest
Test: atest FrameworksMockingServicesTests:UserUsageStatsServiceTest
Change-Id: I671c97e4e4110d0a1c76a8f6400dfe8c1e5055dc
Cache the results from getEarliestEventsForPackage() so we don't have to
go down to the raw database as often.
Bug: 227796747
Test: atest CtsUsageStatsTestCases:UsageStatsTest
Test: atest FrameworksMockingServicesTests:PrefetchControllerTest
Test: atest FrameworksMockingServicesTests:UserUsageStatsServiceTest
Change-Id: I2e3cf6650ed36b4915e4fcab16e9519cc8800f65
* changes:
Add new onUidProcAdjChanged callback to be consumed by the camera service.
Modify UidRecord.CHANGE_PROCSTATE such that it behaves like a bit mask.
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)
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
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