This will prevent us from unnecessarily redoing calculation work
by loading the last caches on boot and shoving them down to
installd.
Bug: 33965858
Test: Framework services tests
Change-Id: Ie94e269aa72bceb1ebe87911eaa42e2d826c1123
This simplifies the QA process significantly more than
I originally expected.
Bug: 34400961
Test: Manual
Change-Id: I5d26526e7ea9a7f16a00b7c2281c5b460f6bbbff
Decoupled the app idle book-keeping from usage stats lock, by
introducing an mAppIdleLock. This is used for all state related
to app idle. In some cases, the locks will be nested, with
mLock being acquired first and then mAppIdleLock.
This should fix the situation where a rollover, which writes to
disk and could take several seconds when the system is swamped,
like when the device just came out of idle and the screen was
turned on (like this run-on sentence), causes calls from other
services for app-idle status to be blocked. This was resulting
in a long time to turn on the screen.
Also fixed a dump indentation issue.
Bug: 34627115
Bug: 34961340
Test: Manual, force into idle, increased rollover frequency,
and tested screen on time.
Change-Id: Ie8b44e6f07f82d8a31f1b733a403dd9b6dc310f6
This allows manual QA folks to change the datetime to test events
which depend on a large gap between uses of an app.
Currently, if the system detects a drift of more than 2 seconds,
it will automatically correct the usage stats. This means that manual
time changes will cause the usage stats to update to match, making it
impossible to test manually.
Bug: 34400961
Test: Manual
Change-Id: Iffb92c929872d841d22f089ec71922bf120cc544
This gives developers a way to collect package-level stats, even if
it means we have to use manual calculation for sharedUserId apps.
Also round size of storage devices to nice power-of-two values so we
do a better job of matching retail packaging.
Test: builds, boots
Bug: 35294241
Change-Id: I24946c443bb9dc4b0411a8149a0656702ac1fd24
Fleshes out remainder of allocation implementation, where we offer
to clear cached data to satisfy the allocation request. To prevent
abuse, we never let apps allocate into either the minimum cache space
or low storage space.
Clean up quota APIs to require the caller to pass in the path they're
interested in, and we resolve the underlying filesystem for them.
Defines settings that can be used to tweak the minimum cache space.
Test: builds, boots
Bug: 34690590
Change-Id: I85bc07399f91ee4aa568a8a54c615646bf748ad4
This currently integrates with installd, but not with
any framework API to expose this information to apps.
The first pass, as per the design doc, adds a service
which polls for large changes in the file system free space.
If enough spaces changes, it begins a recalculation of the
cache quotas and pipes the information down to installd.
This calculation is done in the updateable ExtServices.
Further enhancements in later patches include integrating this
to listen to package install and removal events, caching the
last computed quota values into an XML file on disk to load
on boot, and exposing the information to apps.
Bug: 33965858
Test: ExtServices unit test
Change-Id: Ie39f228b73532cb6ce2f98529f7c5df0839202ae
Add APIs for apps to query their cache usage compared to their
currently allocated quota. Since an app's private storage may live
on a different storage volume than the primary shared/external
storage, offer APIs to retrieve those values separately.
Add APIs to control two new cache purging behaviors:
-- setCacheBehaviorAtomic() which causes a marked directory and its
contents to be treated as an atomic unit.
-- setCacheBehaviorTombstone() which causes the OS to truncate
files instead of deleting them.
Test: builds, boots
Bug: 33811826, 33965858, 27948817
Change-Id: I45de165623775c359f78b4ee544c2b5831b8d483
Current prebuilt kernel can result in the framework banging its head
against the wall writing the first duplicate update; it does this by
returning 0 for write().
We can revert this or flip the flag once an updated kernel lands.
Test: builds, boots
Bug: 33755020
Change-Id: Idb3e5ad40e2e6681848b47ce2b29dff9db3d4f6f
New procfs file written by the system_server to communicate fg/bg
state of UIDs to switch the statistics counter sets used.
Test: builds, boots, counter sets updated
Bug: 34360629
Change-Id: I3339a93bce6aec65779a4a4aee52f5328896bb29
Without this, the Installer never connects to the underlying
installd service, which results in NPEs when the service is used.
Bug: 34261458
Test: builds and runs w/o crashing
Change-Id: I9222c26cf6e411710e07a74f29b019f7c5754316
The MODE_DEFAULT enforcePermission behavior fell through to
the switch default case, even if the calling permission was
granted.
Bug: 34258237
Test: Manual
Change-Id: I823fb4dc3657c15eb1fa3d12d4f4c7e1e9e21cd5
Now that installd has the implementation details we need, we can wire
up the public APIs to use them.
Shuffle APIs around a bit so that StorageStats can be reused for both
UID and UserHandle results, and rename StorageSummary to
ExternalStorageStats. Provide getTotalBytes() and getFreeBytes() as
first-class methods so we can answer those questions quickly without
paying the cost of measuring external storage details.
Current costs on a typical device with a test account after flushing
dentry caches:
queryStatsForUid() manual: 6922ms
queryStatsForUid() quota: 525ms
queryStatsForUser() manual: 1686ms
queryStatsForUser() quota: 113ms
queryExternalStatsForUser() manual: 42ms
queryExternalStatsForUser() quota: 2ms
For verification purposes, a new "fw.verify_storage" system property
can be set to compute both manual and quota statistics, and log any
discrepancies.
Test: builds, boots
Bug: 27948817, 32206268
Change-Id: I4ea3df3372a7379aa8cf4c20c44120c8f0702c15
This API is designed to provide both UID-level stats and overall
summary data for a given storage device, as identified by UUID.
The use of UID-level granularity might appear a bit clunky, but it
matches other usage statistics (such as network and battery), and it
allows us to implement it using an extremely fast quota kernel
feature.
A future CL will wire up the implementation to installd.
Test: builds, boots
Bug: 32206268
Change-Id: I7b51877682d0370c2402c19346f57809f0e7ac53
This CL is for Android O Smart-Sharing (b/30982298). By this CL, sharing
counts are logged with UsageStatsManager.
Bug: 30982298
Test: manual - shared images in Camera and texts in Chrome using a mobile device.
Change-Id: I0b4aa0506f99b3083d140a48f7b4bdd5b1c5afb6
Introduce a new internal flag MATCH_ANY_USER for genuine uses
of searching through all apps on the device.
Some temporary accommodations for Launchers that reach across
to the work profile until we have a new LauncherApps API to do
that officially.
Bug: 31000380
Test: CTS tests added
Change-Id: I2e43dc49d6c2e11814a8f8d1eb07ef557f31af34
Don't use the parole state to deal with the plugged-in trigger.
Otherwise standby apps will only be paroled for a few minutes
after plugging in to charge and not the entire duration.
Use a different intent for charging state, since the CHARGING
intent takes several seconds to be received.
A refactor some time ago changed the charging state behavior
that caused this regression.
Bug: 31399882
Change-Id: Ic036de5e136b3151b225473d0c3f440adb3b48e7
Stop writing to disk every time the display goes off. Only write to
disk periodically.
Consequences
Previously, if the device rebooted after the screen duration was written
to disk, apps would appear more stale than they actually were.
Now apps will always look fresher, which is a better scenario.
Bug:30807864
Change-Id: Ia69a2e51fc9e397789215b449fae56fa3e29c74a
Modifies the PackageManagerService.updatePackagesIfNeeded to filter
out packages which are considered idle by the UsageStatsManager.
Bug: 27902702
Change-Id: I8847dfc283e0246265009effb6394bb774848eb3
On a package being added or removed, remove
app idle state for the app.
Bug: 27570398
Bug: 26182816
Change-Id: I14bdc1f951bbd99bda8111bea56f8c9dda04148d
Apps making calls into the system server may end up persisting
internal state or making security decisions based on the perceived
success or failure of a call, or the default values returned.
The reality is that if the system process just died, init will be
along shortly to kill all running apps, so we should have no problem
rethrowing the RemoteException as a RuntimeException.
Bug: 27364859
Change-Id: Ife0bcb079636c88d54c44d17eb580409fd79028b
Calling into TelephonyManager each of hundreds of apps to check
if the app is carrier privileged was very expensive, especially
when there aren't even any carrier access rules specified. This
change fetches all the carrier privileged apps in one call,
reducing the number of IPC calls to the radio process and checks
the package names locally.
If the carrier rules change or packages are modified, the list
will be computed and fetched again.
Other optimizations in Telephony help speed up the individual calls
to check if a package is privileged, as well.
Bug: 27271861
Change-Id: I5a77b6da4f2cdc603d2a73bd8569c5c38f06b42d
Synchronize only the methods that need to be, so that
the lock is not held for a few hundred milliseconds, blocking
other usagestats operations.
Bug: 27208519
Change-Id: I43bda0791dd8b2576a8af506bcdc67a09a5830f2
Don't continue to check idle states for removed / stopped users.
No need to check for uninstalled packages for all users.
Bug: 27208519
Change-Id: I9a3a3bbec560dd380ce90df9fef102d7f62769ca
Don't mix up with usage stats. Keep a separate db and history
based on elapsed time and screen on time.
Unit tests for AppIdleHistory class.
Bug: 26989006
Change-Id: If343785b46da1db67f7c1c1263854c2732a232c6
Fixed a bug which caused a null pointer exception on restore
in deleteDirectoryContents() method.
Also made other cosmetic changes.
Change-Id: I75712ec585fdfdbca462c468acf2229a47331b59
If we try scheduling a pass before the system is ready, record a
pending event and dispatch once we're actually ready.
Bug: 26863668
Change-Id: I028285383c8bbe8b653aeaa7544eefe3d41277bc
Screen on time should be measured in elapsed realtime, not wallclock.
Cause a checkIdleStates to occur when reloading stats
(on rollover and on time change).
When time changes occur in the negative direction, the new stats file
we create can overlap the previous one with regards to its end timestamp.
Use the begin timestamp to determine which of the latest stats to merge.
(b/22716352)
Bug: 26488100
Change-Id: If31b29bbbee9e98401205b5e26bce86e181286e7
Backing up UsageStatistics using a new API in
UsageStatsService like the Notifications backup.
The backup logic is in the same package as UsageStatsDatabase
while the BackupAgentHelper resides in the android package
alongside SystemBackupAgent.
Bug: 26179323
Change-Id: I022d85fbcd4abb763230bec6eea50a7e723b5152
And ensure that the listeners are informed of app standby transitions
that might occur during time changes.
Fix for apps that sometimes don't have network access until reboot.
Bug: 26488100
Change-Id: Ic342c188a6cd19faee88f50b2c6a342a6968cb23
Ignores the old, re-appropriated key "idle_duration" which is now
set to a high value in order to force disable app idle on devices
with bug b/26355386
Bug:26355386
Change-Id: Iff9de843ad6e547d29c1583687fc7f7ce7e15090