1. Send FOREGROUND_SERVICE_START event when foreground service starts.
Send FOREGROUND_SERVICE_STOP event when foreground service stops.
2. One app can multiple foreground services and multiple services can be
started. Because this, in UsageStats, change mLastForegroundEvent to
className to event map, do this for both activity and foreground
service. Change UsageStatsProto and UsageStatsXmlV1 to support this
change.
3. Add more test cases in UsageStatsTest.java.
Test: start music player which is foreground service, observce these
two events when start play and pause play.
Change-Id: I3dc14f5b73cc114a53b8c51f90d3011d9ace35ac
Bug: 112002260
Test: atest UsageStatsTest#testForegroundService
atest frameworks/base/services/tests/servicestests/src/com/android/server/usage/UsageStatsDatabaseTest.java
atest frameworks/base/core/tests/coretests/src/android/app/usage/UsageStatsTest.java
Also some minor touch up
Test: atest FrameworksServicesTests:AppTimeLimitControllerTests
Change-Id: Ibcecb483bc28ba6b1dcd0158e946137abb0e54e4
Fixes: 119371427
Currently, if AppStandbyController is enabled after some listeners have
already registered, the listeners will be told that the system is in a
state of parole even though AppStandbyController thinks it's not in
parole. This change informs AppIdleStateChangeListeners when
AppStandbyController's enabled state changes as well so that they can be
in the correct state.
I also removed the call to setAppIdleEnabled() in onBootPhase() since
updateSettings() is called right afterwards and that also calls
setAppIdleEnabled().
Bug: 112329453
Test: atest AppStandbyControllerTests
also check logs to confirm that NetworkPolicyManagerService and
JobSchedulerService's listeners switch from ON to OFF when the system is
ready.
Change-Id: I88bc293c70b459f54f75f92126ad306d6ab8d9b7
Test: Remove first_sdk_check from StorageHostTest#testVerify, log
Build.IS_CONTAINER inside isReservedSupported function, run on sailfish.
It shows that Build.IS_CONTAINER=false and the test still passes (i.e.,
isReservedSupported is correctly true).
Also checked that Build.IS_CONTAINER in isReservedSupported is true in
ARC++.
Bug: 111287848
Change-Id: I9af1f6cce5bab75ef941989bf279cf40c52e62b0
Introducing the concept of Usage Session Observers to UsageStats. A
session observer monitors usage within individual "continuous" sessions
(brief gaps of non usage may be allowed in a session and still be
considered continuous)
The new session observer in AppTimeLimitController are both similar and
different enough from the current app usage observer to warrant
refactoring TimeLimitGroup into an OOP friendly abstract base class.
Added some Observer App handling to avoid clash between registered
observers from multiple apps.
Reworded packages to observed and usage entities to accomodate future
changes, where usage may come from more than just app usage.
Reworded moveToForeground/Background to generic usage and allow multiple
usage entities to be active at the same time to accomodate future
changes, where more than just the foreground app can be considered used.
Test: atest FrameworksServicesTests:AppTimeLimitControllerTests
Bug: 111465038
Change-Id: I63aebf8b0aa5516111bd6d5e142525d0bee6ef58
* changes:
Add ProtoInputStream and UsageStatsProto to art profiles
Upgrade UsageStatsDatabase to version 4 (attempt 2)
Move UsageStatsDatabase upgrade backup to seperate folder
Apps trying to set the standby bucket for a package that was uninstalled
will now be blocked to prevent uninstalled package entries from
appearing in the App Standby DB.
Bug: 116190365
Test: atest com.android.server.usage.AppIdleHistoryTests
Test: atest com.android.server.usage.AppStandbyControllerTests
Test: atest cts/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Test: atest vendor/xts/gts-tests/tests/usagestats/src/com/google/android/usagestats/gts/UsageStatsTests.java
Change-Id: If421c46f3459eced78ae260e88749022ed5cf7a2
If version 4 causes any regression, this CL should be reverted.
The other UsageStatsDatabase changes are not safe to revert.
Bug: 111422946
Test: atest UsageStatsDatabase
Change-Id: I8af08a25c596397ec319d457bfa5c51b73beb4df
During a UsageStatsDatabase version upgrade, move backup files to a
seperate folder to reduce the chance of accidentally picking up the
backup file.
Change-Id: I0052cb25388703c328cd7160f523d8542cf424d7
Fixes: 117224541
Test: atest UsageStatsDatabaseTest
Write the package and class names at the top of the proto file and
replace each instance of those strings in the rest of the protobuf with
the index of said string.
Some rough number on the impact of this change plus the previous proto
change:
File size on disk reduces to ~13% of XML file size!!!
File read time reduces to ~32-45% of XML read time!
File write time clock at around ~102-107% of XML write time.
Bug: 111422946
Fixes: 111449191
Test: atest UsageStatsDatabaseTest
Change-Id: I6bcce54a2431a964bda2c03bd3be1f3d4b4156e1
Add the relevant methods to read from ProtoInputStream to
various classes.
Also add some framework to handle version changes in
UsageStatsDatabase. There is some risk of users losing all their current
UsageStats data, if something goes horribly wrong. The debug flag and a
keep backup files flag are temporarily set in UsageStatsDatabase with
this change. They will both be unset in the future before the Q release.
Some rough number on the impact of this change:
Proto file size on disk reduces to ~47% of XML file size :)
Proto file read time reduces to ~55% of XML file read :)
Proto file write time increases ~17% over the XML file write :(
There will be a follow up CL to address the file write time regression
Bug: 111422946
Fixes: 111449927
Test: atest UsageStatsDatabaseTest
Change-Id: I084aea796ed2163c42947d52396a36cc7c5562a2
Add @GuardedBy for simple functions that require locks and have a name in
one of the frameworks naming styles for locks ("^.*(Locked|LPw|LPr|L[a-zA-Z]|UL|AL|NL)$").
Derived by errorprone.
Bug: 73000847
Test: m
Change-Id: If70bb03313388af34d547efca20fb5115de95bf1
So the time shown will be how long ago the last parole happened.
This is easier to read than when the last parole happened, in
time since epoch.
... mChargingStable=false mLastAppIdleParoledTime=+15s666ms
Bug: 112880101
Test: adb shell dumpsys usagestats
Change-Id: Ieddf752e811a95a95e63d621e9cd9f26957b51a8
Detecting if a storage device has quota or resgid support isn't
sensitive, so we're okay letting anyone ask about it.
Bug: 112175169
Test: atest android.appsecurity.cts.StorageHostTest#testFullDisk
Change-Id: I1e45eeade0d0d8ea242afca274b45a68972e6b57
MATCH_ANY_USER, which was locked down recently, is not
really needed in this context, so removed it.
Bug: 111145886
Test: cts CtsAppUsageHostTestCases
Change-Id: I1bb9df0c7370015365bea414599b2b83084a1846
- Fix the issue where when a sync starts when the user is locked, the sync
is enqueued and waits for the 10 minute timeout, which drains the battery.
Now, in this case, we finished the job right away, and if it's a non-periodic
sync, we ask the job scheduler to reschedule.
- Clean up all the mess and unnecessary code.
Fixes: 79433653
Test: manual: Add an account, remove it, make sure all the sync operations are
gone from dumpsys content.
Test: manual: Use the requestsync command while the user is locked and
make sure the sync won't stuck.
Change-Id: I8cfd6a80715336ebea3793b2ed10b59d90cd8e52
In UsageStatsService, the calling uid is considered
from the system regardeless of the curret user id
Change-Id: I5c33db37c585ac918a09ad9014bb819b1e24d7f8
Fixes: 110527624
Test: manual
A suite of simple performance test for UsageStatsDatabase. They measure
the time it take to write and read UsageEvents to and from a file.
Bug: 110428559
Test: atest UsageStatsPerfTests
Change-Id: If1558515e1da9e22fb56bc13f8e89c10c51a1625
Caught by test UsageStatsTest due to stricter checks for
MATCH_ANY_USER.
Change-Id: Ie884c7007a8588a222773fba8d7967bcdf2a528a
Fixes: 109700742
Test: atest CtsUsageStatsTestCases:UsageStatsTest
For multipackage requests, caller must be system uid or hold
interact_across_users if not requesting fate for the same user.
For single package requests, caller must be system uid or the
same package and hold interact_across_users if not requesting data
for the current user.
In both cases the caller must have the usagestats permission.
Test: couldn't find automated tests for this file; manual
Bug: 79142791
Change-Id: I8d650f8e875e0e4578cb48c9ba42e821342852a0
Exemption given to a sync request made by a foreground app (including
PROCESS_STATE_IMPORTANT_FOREGROUND).
At the schedule time, we promote the sync adapter app for a higher bucket:
- If the device is not dozing (so the sync will start right away)
promote to ACTIVE for 1 hour.
- If the device is dozing (so the sync *won't* start right away),
promote to WORKING_SET for 4 hours, so it'll get a higher chance to be started once the
device comes out of doze.
- When the sync actually starts, we promote the sync adapter app to ACTIVE for 10 minutes,
so it can schedule and start more syncs without getting throttled, even when the first
operation was canceled and now we're retrying.
Test: atest cts/tests/tests/syncmanager/
Test: Manual test with "requestsync -f" and "am set-standby-bucket", while checking
"dumpsys usagestats"
Test: settings put global app_idle_constants \
exempted_sync_scheduled_nd_duration=1,exempted_sync_scheduled_d_duration=2,exempted_sync_start_duration=3
and check "dumpsys usagestats" and make sure the constants are properly updated.
Fixes: 72443754
Change-Id: I233d8e4be85769150830bac798abc04810f4cc7b
This is needed for manual testing the fix for b/72443754.
Test: atest cts/tests/tests/app.usage/src/android/app/usage/cts/UsageStatsTest.java
Test: atest cts/tests/tests/batterysaving
Bug: 72443754
Change-Id: I13ac03917c0a5a08859c44930406e7a82ebf1a07
For multipackage requests, caller must be system uid or hold
interact_across_users if not requesting fate for the same user.
For single package requests, caller must be system uid or the
same package and hold interact_across_users if not requesting data
for the current user.
In both cases the caller must have the usagestats permission.
Test: couldn't find automated tests for this file; manual
Bug: 79142791
Change-Id: I8d650f8e875e0e4578cb48c9ba42e821342852a0
The only way to know the runtime state was check dumpsys usagestats, and
parse through a lot of output.
This makes it easier to retreive the state.
Test: adb shell settings put global app_standby_enabled 0
adb shell dumpsys usagestats is-app-standby-enabled
Bug: 74336662
Change-Id: Ibe80d27bdf940682b9e4c3c14f93b4871f9f1746
Added a minimum time limit for App Time Limit Observers and a maximum
number of observers an app can register to AppTimeLimitController
Also fix small bug with mDpmInternal initialization
Change-Id: I8c0861d79711149f3ecd92ba4660f7b207e9b921
Fixes: 78890515
Fixes: 79230583
Test: atest AppTimeLimitController
Test: atest cts/hostsidetests/devicepolicy/src/com/android/cts/devicepolicy/ProfileOwnerTest.java#testAppUsageObserver
Delay parole when charging to ensure the device has some time to charge
and avoid a spike is activity on plug in.
Change-Id: If85f097249aeed6b64f43a22f4d25ff0a070febb
Fixes: 78040839
Test: atest AppStandbyControllerTests