Add @GuardedBy for simple functions that require a single lock
and are named XYZLocked.
Derived by errorprone.
Bug: 73000847
Test: m
Test: m javac-check-framework RUN_ERROR_PRONE=true
Change-Id: Id1d9fbe5018250e3b9d1466fc5f670d5ad902fa3
Relax the permission requirement for UsageStats
API querying inactive state of apps across users.
Bug: 72953020
Fixes: 72942083
Test: Manual -- create a secondary user
Change-Id: I9c5e12f718d9f424c99aa72dd70470c4b083c13f
After an OTA, all system apps were being
pushed into EXEMPTED for 4 hours because
of a race with the boot phase resulting in
it appearing as if app standby was disabled.
Another bug in updating the state out of EXEMPTED
was preventing checkIdleStates() from fixing
the issue soon after.
Bug: 72835804
Test: Manual:
Manually delete /data/system/usagestats/version
Reboot
Verify that correct apps are EXEMPTED
Automated:
atest FrameworksServicesTests:AppStandbyControllerTests
Change-Id: Ib53f0c45e5c2e2456442f6782ad5ca9b9d0c3d72
Push standby bucket changes into UsageStats as events.
Don't use the event for aggregation.
Bug: 63527785
Test: atest CtsUsageStatsTestCases:UsageStatsTest
Change-Id: Icd152b21935e3ef73aaa1a62f09574e51ce921bd
JobScheduler can store the last job run time
for an app and use it later to help with
throttling.
Also, allow reporting a usage for a temporary
period. This will put the app in ACTIVE for a
minimum specified period during which timeouts
and predictions will not be able to reduce the
bucket level.
Bug: 71536897
Test: atest AppIdleHistoryTests
atest AppStandbyControllerTests
Change-Id: I2985f7f3766671f15ea641972346c69875f17946
This is how we tell CTS if the device has reserved blocks set aside
for system critical services.
Test: builds, boots
Bug: 62024591
Change-Id: Ib970554235b49346f9e9df7d3d1646beb168cd92
Mirrors the design of TimeUnit and ChronoUnit which many developers
are already familiar with, making it easy to pick up and use.
Yes, this is an enum.
Bug: 70915728
Test: bit FrameworksCoreTests:android.util.DataUnitTest
Change-Id: Id0cfdac5c81ed89c3c9ece23c964acba4a4f8471
For JobScheduler, DeviceIdle and AppStandby constants, allow
using a more compact format than milliseconds,
which are a PITA to calculate.
So instead of 18640000000... whatever, you can
use PT2H (for 2 hours), or P2D (for 2 days), etc.
Uses Duration.parse() to do the parsing. See Duration
for format.
Test: adb shell settings put global app_standby_constants
screen_thresholds=0/PT2H/PT12H/P2D
Fixes: 71554131
Change-Id: I5141854ec7df6de266725a67f1f3e2a6e0b4c1c1
DUMP OF SERVICE Usagestats was empty in bugreports
because an unexpected -a argument was being passed.
adb shell pm dump <package> had a similar issue with --packages
Change-Id: Ic67c723b8edc74ec7c9c48582b08896ca3430a4a
Fix: 70777338
Test: adb shell pm dump <package> and bugreports now contain usage stats
Disable app standby features if app_standby_enabled
is set to 0. This allows for UI and experiments to
control the feature.
Bug: 70655630
Test: adb shell settings put global app_standby_enabled 0
adb shell dumpsys usagestats
adb shell am get-standby-bucket <packagename>
Change-Id: Id6c62b078e52040767100f2997832cc586bb0806
Don't allow EXEMPT to be overridden
Differentiate between shell and other callers who set
buckets.
Don't allow forced to be modified by bucketeer.
Don't allow bucketeer to modify NEVER bucket.
Fix a locking issue in listeners list. Don't use
the primary lock when calling out to listeners.
Fixes: 70622791
Fixes: 70622338
Test: atest FrameworksServicesTests:AppIdleHistoryTests
atest FrameworksServicesTests:AppStandbyControllerTests
atest CtsAppUsageHostTestCases
Change-Id: I22309478b947d6461235f5a77e08c7be86309e4b
This is different from SDK_INT, which can change due to OTA
software updates.
Test: cts-tradefed run commandAndExit cts-dev -m CtsOsTestCases -t android.os.cts.BuildTest
Bug: 69270887
Change-Id: Ic3f4b22b25dc08f3fbdbdf7622c953323447ea01
SystemApi to pass a map of packagename to bucket mapping.
Reduces the number of IPC calls to be made by bucketing
ML app.
Bug: 63527785
Test: atest CtsAppUsageHostTestCases
Change-Id: I4172fd30cc310092a1f182ae26267de9148009b7
Ignore predicted bucket if it's been too long since the
last update, and use internal timeout logic to set
standby buckets.
Keep track of last predicted time and persist it.
Bug: 70219058
Test: atest FrameworksServicesTests:AppStandbyControllerTests
Change-Id: Ib2992201d204b92fdd4a0a00754d81e7bbfc292f
See build/soong/README.md for more information.
Test: m checkbuild
Exempt-From-Owner-Approval: trivial conversion
Change-Id: I417409281c928ea667d937090d2a0d9d72a449a2
Instrumentation package should be immediately marked as active so
that the jobs aren't throttled.
Also, make sure special apps' buckets are correctly initialized.
Fixes: 68900608
Fixes: 69799327
Fixes: 69793822
Fixes: 69788489
Test: atest CtsNetSecPolicyUsesCleartextTrafficTrueTestCases
atest FrameworksServicesTests:AppIdleHistoryTests
atest FrameworksServicesTests:AppStandbyControllerTests
atest CtsNetSecPolicyUsesCleartextTrafficUnspecifiedTestCases
atest CtsNetSecConfigDownloadManagerTestCases
atest CtsNetSecPolicyUsesCleartextTrafficFalseTestCases
cts-tradefed run cts-dev -m CtsAppUsageHostTestCases
cts-tradefed run cts-dev -m CtsHostsideNetworkTests
gts-tradefed run gts-dev -m GtsUsageStatsTestCases
Change-Id: Ic880b6f5ed1fdb7912613e882ccf7b2d4e388159
Only check for INTERACT_ACROSS_USERS in getAppStandbyBucket()
Bug: 70126098
Test: gts-tradefed run gts-dev -m GtsUsageStatsTestCases
Change-Id: I6c3f69ff56d8513f84c7d91162567d17c06980c3
Allow apps to query their own standby bucket.
Allow privileged apps with PACKAGE_USAGE_STATS permission to
query apps.
Allow privileged apps with CHANGE_APP_IDLE_STATE to set the
standby state for apps, but not for themselves.
Removed AppStandby class and moved constants into UsageStatsManager.
Bug: 63527785
Test: cts-tradefed run cts-dev -m CtsAppUsageHostTestCases
Change-Id: I3c1c20f6ecb6d54e248233696039286b243d663c
We need over 8 days of UsageEvents in order to capture weekly
patterns in our app usage models
Change-Id: I8e1149b82cfbaedae4d19bbbfaeffa989bfd54e7
Fix: 69244223
Test: It builds
Switch to using the new bucket thresholds and
remove the previous idle thresholds.
Bug: 63527785
Test: atest AppStandbyControllerTests
atest AppIdleHistoryTests
Change-Id: Ica3fd10fe172faa5b4e712b08273b77357fdae14
Start off with slightly more aggressive timeouts to
switch between buckets. 12Hrs, 24Hrs and 48Hrs.
Bug: 63527785
Test: atest AppStandbyControllerTests
Change-Id: I4aa0cc38ef91538192eda0f48dd3840217aa49c4
On a notification becoming visible, NOTIFICATION_SEEN event is
dispatched. This will only bump up the app's bucket to WORKING_SET and
no higher. Same goes for sync adapters associated with a content
provider. Only move them to WORKING_SET.
Updated NotificationManagerService to report event to usagestats on
visibility changes.
Bug: 63527785
Test: runtest -x
frameworks/base/services/tests/servicestests/src/com/android/server/usage/AppStandbyControllerTests.java
atest NotificationManagerServiceTest
Change-Id: I5b132e1fc1f70e2126473b43b9b1979fbc523b85
And inform listeners when the bucket changes, not just when
going in and out of RARE bucket.
Avoid redundant callbacks when informing listeners.
Bug: 63527785
Test: runtest -x
frameworks/base/services/tests/servicestests/src/com/android/server/usage/AppStandbyControllerTests.java
Change-Id: Icd98d59f597147fbf8ea4bf44edf4b3b3d5c8e14
Everything is now moved out of the pm command except for
the various install commands. I am going to hold of on
those since they require doing some resolution with the
current implementations in the package manager to make
sure they match and behave identically to the implementations
currently in the pm command. But other than that, everything
in pm is now just redirecting over to "cmd package".
Also fix up some of the dumpsys output of a few other sevices
when asking to print the data for a particular package, so
the "pm dump" command gives a little more sane result.
Test: manual
Change-Id: I139e06e560203b72243d7eea9543c2240db0f8f8
Manage the standby bucket in AppStandbyController
Default implementation of bucketing based on simple timeout:
ACTIVE, if recently used
12 hrs to move to WORKING_SET
2 days to move to FREQUENT
7 days to move to RARE
(subject to change)
RARE bucket equates to the old "idle" or "inactive" state for
an app.
Bug: 63527785
Test: AppStandbyControllerTests.java
Change-Id: I970d7afcdf47c31a9413da8fd4852066a13676a2
Move the App Standby code out of UsageStatsService into
an AppStandbyController class. This doesn't change any
behavior. Also, it doesn't change the entry points, which
are still in UsageStatsManager. The binder APIs are still
in UsageStatsService and are forwarded to
AppStandbyController.
This change is in preparation for switching to app standby
buckets instead of a boolean state.
Bug: 63527785
Test: adb shell dumpsys usagestats
adb shell am set-inactive <packagename> true
// Ensure state changes are persisted
Change-Id: Ic94357bdc891d1defae37bb29d533b6153a09967
This is becoming a common pattern (keeping track of which processes
are cached and not allowing them to do stuff in that state), so I
am turning this in to a general mechanism for monitoring this state
through the activity manager's IUidObserver. Now we can just have
AudoService implement its own IUidObserver to get this state and
update which uids it is blocking.
This required making some changes to uid change reports so that
the integer is now a bit mask instead of an enumerations, but that
is what it was already turning in to anyway. (This gets rid of
the crazy GONE_IDLE constant that we'd needed to add before because
it wasn't a bit mask).
Eventually the power manager should be changed to be told about
these changes to cached state instead of listening to every proc
state change, but we'll do that later, it is more disruption than
I want to take for now. However, while working on this, I noticed
that the power manager had regressed in the cached uids it would
actually block, because the activity manager was no longer telling
it about all uids that are idle. (I think this happened when I had
to change the default idle state of UidRecord to true.) So I am
adding a bit of new code to keep track of what idle state we last
reported to observers, to make sure we tell it about newly created
uids that are idle but have never actually become active.
Test: runtest -c com.android.server.am.ActivityManagerServiceTest frameworks-services
Change-Id: I7bfd46bacadd4cab2a69f40e6e52afb4e67b456a
New quota APIs are much faster than trying to measure manually, and
removing this last user of calculateDirectorySize() means we can
remove it once and for all.
Bug: 36056324
Test: builds, boots
Change-Id: Ibdf1ee4e8885680e106df6a9269b6309ddc61af8
We normally prevent apps from allocating into the "reserved" cache
space, but this change makes an exception for an active camera app,
since the user is probably trying to capture an important memory.
This change only lets the active camera app clear up to half of the
reserved space, since we don't want to completely destroy the
experience of all other apps.
Test: manual app before/during/after active camera session
Bug: 38267830
Change-Id: Ie9e63884fb2638ca881e10b894629eea84601648
When answering the question "how much space is free", use the same
logic for Settings UI and StorageManager.getAllocatableBytes(). That
is, the reported free space is usable bytes plus any cached data the
system is willing to delete automatically.
This does *not* include any reserved cache space, since we don't want
abusive apps to penalize other well-behaved apps that are storing
their data in cache locations. Callers freeing cached data need to
now explicitly request defiance of the reserved cache space. (Most
callers are already doing this by using FLAG_ALLOCATE_AGGRESSIVE.)
Rewrite the core logic of DeviceStorageMonitorService to understand
this new "reserved" cache space, and to be easier to understand. It
also now handles cached data on adopted storage volumes, which had
been ignored until now. Also fix bug where we had skipped "low"
broadcasts when the device skipped directly from/to "full" state.
Bug: 38008706
Test: cts-tradefed run commandAndExit cts-dev -m CtsJobSchedulerTestCases -t android.jobscheduler.cts.StorageConstraintTest
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.StorageHostTest
Change-Id: Icbdcf3b52775f7ada1ceaeff2f96094c8d8052f9
Change-Id: I97f791b61f9b4f7ed33305345bf3d92394b40ae4
Fixes: 38202759
Test: cts-tradefed run commandAndExit cts-dev -m CtsAppSecurityHostTestCases -t android.appsecurity.cts.EphemeralTest
Test: Manual. Create sample app that replaces the launcher to test ability to see ephemeral apps.
- Events are obfuscated based on whether the app was instant or not at
the time each event was logged.
- UsageStats are obfuscated based on whether each app is instant or
not at the moment.
Bug 38202133
Test: Manual test using UsageStatsTest and instant apps
Change-Id: I3c74309196b88d010d317cb0dd6749bf4624e876
For volumes where the OS manages cached data, use the "free space" as
reported by StorageStatsManager, which is the same value shown in
the Settings app and other UI elements.
Also, when the storage space changes significantly, invalidate anyone
who was holding a cached "free space" value.
Test: builds, boots
Bug: 38146029
Change-Id: I4b3a484a8bf32cd137a83f1ea441beca6dc6719a