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
Finishing the suspend dialog when the package for which it was shown
gets unsuspended for any reason.
Also, attributing any interaction with this dialog to the suspending
package, as the system is showing the dialog on its behalf.
Test: Manual, from an unrooted shell:
adb shell pm suspend com.android.chrome
Tap to start chrome and wait for the dialog to appear. Then:
adb shell pm unsuspend com.android.chrome
The dialog should disappear. Further,
adb shell dumpsys usagestats
should show USER_INTERACTION for com.android.shell.
Bug: 169137795
Fixes: 180336589
Change-Id: I70b6f23e2994d8802335e35932ed09209754697c
Create a user-agnostic package-level last time used usage stats for app
hibernation. Usage is updated when USER_INTERACTION or
APP_COMPONENT_USED event reported. Also moved checkAndGetTimeLocked and
convertToSystemTimeLocked methods up to UsageStatsService class and
refactored usages.
Bug: 183142974
Test: atest CtsUsageStatsTestCases:UsageStatsTest
Test: atest UsageStatsServiceTest
Test: atest UserUsageStatsServiceTest
Change-Id: I93d8653bb92b98af8f6b57156eb1139fbd7e562a
Created a new metrics called mLastTimeComponentUsed in UsageStats.
It is persisted and loaded as other metrics.
Bug: 175829712
Test: core/tests/coretests/src/android/app/usage/UsageStatsTest
Test: cts/UsageStatsTest
Test: UsageStatsDatabaseTest
Test: UsageStatsServiceTest
Test: UsageStatsPersistenceTest
Change-Id: I10cf5c40cf5955246a6a04e96ac0352b4ed29acd
* changes:
SysUI changes for setSuppressBubble
Track locusId visibility in ShellTaskOrganizer
Add locus id to ActivityRecord / TaskInfo
Bubble API: suppress bubble
1) We need a way to listen for locusId, this is done via
a new listener on ShellTaskOrganizer that is informed
for all task info changes.
2) When locusId for focused activity changes, check for
a bubble in data that has a matching locusId & has
API set
3) Add suppress/unsuppress in the state change flow and
update the views
TODO in later CL:
- animate the view being hidden / shown; handle flyout
Test: atest ShellTaskOrganizerTests BubbleDataTest BubbleXmlHelperTest (also CTS CL)
Bug: 170267239
Change-Id: I5c9bd15fa8b5b326e146efdc40916454ca1c73f6
Add a new usage event to UsageStats when a component in a package is
used (content provider binding, explicit broadcast, activity resume)
and it is considered to be important usage.
The follow-up CL will handle the service binding case as it is a little
complicated due to job bindings.
Bug: 175829712
Test: adb shell dumpsys usagestats <package-name>
Test: atest UserUsageStatsServiceTest
Change-Id: I1f2967dcf5999a8f0affea94bce4c0873a04e022
Allow queryUsageStats to take in the context's userId. This
allows apps like Settings to query usage stats across
profiles.
Bug: 146921442
Test: atest CtsUsageStatsTestCases:UsageStatsTests
Change-Id: Ia6c90c1a31887efa8d5446c1b1b11e75cb9ab83e
Various ActivityManager actions require calls to
UsageStatsService.reportEventOrAddToQueue(), but that function can
block for hundreds of milliseconds while UsageStatsService is
initialized during post-unlock. However, the only important part of
reportEventOrAddToQueue is the check to see if a user has been
unlocked, at which point the action is enqueued on a Handler.
Move mUserUnlockedStates to a CopyOnWriteArraySet, which should be
updated very infrequently, and allow the common case of "the user is
unlocked and an event should be added to the queue" to run
concurrently with other UsageStatsService operations.
Test: atest android.app.usage.cts.UsageStatsTest
Test: atest android.app.usage.UsageStatsTest
Test: atest UsageStatsDatabaseTest
Bug: 161866124
Change-Id: I11743d78f20db5e5a9471544ae5a1c0ab492202d
Test: atest StorageHostTest and also manually using StorageTestApp
to use the API and display the cache size.
Bug: 175016452
Change-Id: Iff0503c1643ee5fc501037e413aa4b5461ca3388
When there are parsing errors while deobfuscating usage stats, it can
produce a lot of error logs. Condense and reduce the logging to a
minimal amount.
Also, keep track of the recently removed package tokens and dump them
to help debug these parsing errors.
Bug: 177610601
Test: adb shell dumpsys usagestats mappings 0
Change-Id: I860ee4b24d2ff2df88e536edca81920256257198
Currently, usagestats file may be currupted when writing
fails. Because AtomicFile#failWrite(fos) is always called
with argument null. Modify argument of this method so that
it is not null when writing fails.
Bug: 177501256
Change-Id: I1bb64a9af7941ab80abe3f98ad5b8ecf6d1b46d6
It is possible for UsageStats to recieve activity resume and stop events
for the same activity, that have different task roots. Change UsageStats
to report usage start/stop to AppTimeLimitController using only the
package name on Activity pause.
Fixes: 169970833
Test: atest android.app.usage.cts.UsageStatsTest
Change-Id: Ie0ff4a18bf2001f72f637cc1687b7bd0a5afa85e
We've been writing many new framework-specific Error Prone checkers
to help detect obscure platform bugs, and this change starts enabling
those checkers for more packages across the platform.
Bug: 155703208
Test: manual
Exempt-From-Owner-Approval: trivial blueprint changes
Change-Id: I1db3412b0be40f6f78c68331ae01756887192071
Do not use USES_POLICY_PROFILE_OWNER / USES_POLICY_DEVICE_OWNER.
Instead, use explicit methods for checking if the caller is
the Device Owner or Profile Owner.
USES_POLICY_PROFILE_OWNER is confusing since internally in the
DevicePolicyManagerService, it implied a Device Owner is also a
Profile Owner, which is not always what the caller expected.
This is the first phase of the refactoring, removing external calles'
dependency on these constants. The next phase will remove them
internally completely in favour of an implementation that
accesses mOwners directly.
There are no functional changes in this CL.
Bug: 163028934
Test: atest FrameworksServicesTests:DevicePolicyManagerTest
Change-Id: I57c8465d190a3b4b130d57fd622cc93eaeb9c717
Revert "Snap for 6792834 from 5b681187dce32555f398c1b823b82be3a4..."
Revert "Snap for 6792834 from ff268453a3067874ebba3646e8e9fdbc04..."
Revert "Snap for 6792834 from 035f3eaa19b160a5f89cf5ba1328de6e34..."
Revert "Snap for 6792834 from 38626f86b924625d27d752950ce04045e6..."
Revert "Snap for 6792834 from a2cb05379b86f00033bd19912e1d6031f6..."
Revert "Snap for 6792834 from f1e69b45bde30a055d37260012df8e951b..."
Revert "Snap for 6792834 from 9215e252c9daaad53a18582afe5478eb6c..."
Revert "Snap for 6792834 from c9d246d88c86368fddcaa9f58d6eec740f..."
Revert "Snap for 6792834 from f0ebc39aedd8f83938f5053e87b1f42331..."
Revert "Snap for 6792834 from d6d5105b22925ff168be784af9fb044fdd..."
Revert "Snap for 6792834 from e8dc6bf8735df45be9eb7867921243d83d..."
Revert "Snap for 6792834 from de2e193ad770855a0cdc7b96d91a13929b..."
Revert "Snap for 6792834 from 5e0116a4a17307df9c303b1ea4f8857dc7..."
Revert "Snap for 6792834 from 1529174442dc31e0036c58fba7a90184ee..."
Revert "Snap for 6792834 from 14f7794f2150fc246f5c5003dc4d953019..."
Revert "Snap for 6792834 from 1a8f386df1be8e4692c00dda348f4addfb..."
Revert "Snap for 6792834 from d5d749da0ba5e53684535fae5eb76c085f..."
Revert "Snap for 6792834 from bc7dc6f5c75789d25879762854a071bd1b..."
Revert "Snap for 6792834 from d5031fd6172a4ee4a774ca7ad3df331300..."
Revert "Snap for 6792834 from bdbd076341f75ed0416f4cda0a98fc6f54..."
Revert "Snap for 6792834 from 201eaa68fcc0781df6f7713901fd5a0862..."
Revert "Snap for 6792834 from 7fcd3459496d859d2d03dcd23d9d5db563..."
Revert "Snap for 6792834 from 82eecc9b3c895d356fca70f4b8def94600..."
Revert "Snap for 6792834 from 95c6fcdbcd91cf6e409f8e50f8d33be247..."
Revert "Snap for 6792834 from 4b73f247850059a4312525662991d73359..."
Revert submission 12462888-release-request-aa3875fd-ef4c-4f66-9a1c-b0b05058d091-for-git_main-busytown-release-6792834
Reason for revert: Bad snap due to branch misconfig.
Reverted Changes:
I950c3960b:Snap for 6792834 from de2e193ad770855a0cdc7b96d91a...
Ie6452b91a:Snap for 6792834 from c9d246d88c86368fddcaa9f58d6e...
I6b98cb766:Snap for 6792834 from 7fcd3459496d859d2d03dcd23d9d...
Ie5e19aaef:Snap for 6792834 from edbf3411d2c91f38a1a5d93b9e5b...
I35385da96:Snap for 6792834 from 4b73f247850059a4312525662991...
I1a59949e5:Snap for 6792834 from d5031fd6172a4ee4a774ca7ad3df...
I2c40ffbc2:Snap for 6792834 from f0ebc39aedd8f83938f5053e87b1...
I24c147f50:Snap for 6792834 from ff268453a3067874ebba3646e8e9...
Iabb2fe4c1:Snap for 6792834 from 5e0116a4a17307df9c303b1ea4f8...
I92bfbb5d5:Snap for 6792834 from 0ad493cce4f8f187dc37671b45d5...
I2e92b2d5d:Snap for 6792834 from f1e69b45bde30a055d37260012df...
I0fdb356fa:Snap for 6792834 from a2cb05379b86f00033bd19912e1d...
I9b19f9bdc:Snap for 6792834 from 95c6fcdbcd91cf6e409f8e50f8d3...
Ie88e387a6:Snap for 6792834 from 9215e252c9daaad53a18582afe54...
Idc1ae35dd:Snap for 6792834 from 201eaa68fcc0781df6f7713901fd...
Ib16deadd9:Snap for 6792834 from 1a8f386df1be8e4692c00dda348f...
I744f889d3:Snap for 6792834 from d5d749da0ba5e53684535fae5eb7...
Ib6e060e44:Snap for 6792834 from bdbd076341f75ed0416f4cda0a98...
Iab587ff78:Snap for 6792834 from e8dc6bf8735df45be9eb78679212...
Ia1f4ef82f:Snap for 6792834 from 14f7794f2150fc246f5c5003dc4d...
Ief930c2b5:Snap for 6792834 from 5b681187dce32555f398c1b823b8...
Ia71445b6a:Snap for 6792834 from 38626f86b924625d27d752950ce0...
Ia95c82cfc:Snap for 6792834 from 1529174442dc31e0036c58fba7a9...
If1e1b5e35:Snap for 6792834 from bc7dc6f5c75789d25879762854a0...
I98959e228:Snap for 6792834 from 1e7f83c953b7571dceabd5d7f6a2...
I321c4cb8b:Snap for 6792834 from d6d5105b22925ff168be784af9fb...
I3ed2d46ee:Snap for 6792834 from 035f3eaa19b160a5f89cf5ba1328...
Id4a7f102c:Snap for 6792834 from 82eecc9b3c895d356fca70f4b8de...
Change-Id: I4b944b89f3c581fbd67f5952d9ec413d02756abc
This method was added to operate as an internal variant of the
public getPackageUid method since pmInternal#getPackageUid already
exist. However, pmInternal#getPackageUid method just called to the
public interface, and enforcing permissions and visibility checks.
Since we don't expect any UID/permission checks in a local service,
any callers to this method requiring permission checks should be
migrated onto the PackageManager public method. Remove the original
pmInternal#getPackageUid and rename #getPackageUidInternal to take
its place.
Bug: 148235092
Test: Build pass and boot
Change-Id: Iebf51ab7f35710dea2b9c34c64138277c44cf30a
UserController calls SystemServiceManager on some stages of the user
switch lifecycle, and SystemServiceManager calls the respective
callbacks in the SystemService objects it manage.
Prior to Android 11, these callbacks would take a @UserIdInt userid,
but now they take a TargetUser (which in turns contains a Userinfo).
So, currently, UserController calls SystemServiceManager passing the
userid, and SystemServiceManager gets the UserInfo from
UserManagerService. That works fine most of the time, but there might
be some race conditions when a user is removed that can crash the
system when such user is stopped (because UserManagerService doesn't
have its UserInfo anymore).
This CL fixes this issue by refactoring the user switch workflow so:
- TargetUser doesn't hold a reference to the UserInfo anymore, but
offer the methods needed by SystemService implementations.
- SystemServiceManager keeps track of the TargetUser objects used in
the callbacks.
Test: manual verification
Fixes: 159831354
Change-Id: If68ab1b5e247c7389c8cac16432d8b8809507e86
This is just a plain refactoring: the removed methods in the changed
classes were called by default by the new methods in the superclass
(SystemService).
Test: m
Test: atest NotificationManagerServiceTest BackupManagerServiceRoboTest
Fixes: 161943081
Exempt-From-Owner-Approval: refactoring without side-effects
Change-Id: Ifd8df592eb4494cc0922b7e0b2ff20187b8a8b3e
Move AppStandbyController's handler to use the JS mainline module's
background thread looper to decouple it from the rest of the system and
from BackgroundThread.
Bug: 160873128
Test: atest CtsUsageStatsTestCases:UsageStatsTest
Test: atest FrameworksServicesTests:AppIdleHistoryTests
Test: atest FrameworksServicesTests:AppStandbyControllerTes
Change-Id: Ic64ccf6b4437060cb4ea83b1c5c6053421081ef8
Relocated MOVE_TO_FOREGROUND so that it will get logged for Activity
Paused to Activity Resumed transitions.
Also moved some calls into PackageManager outside of the UsageStats lock
Bug: 159165822
Test: builds and flashes
Change-Id: I8e9e96ae1fc3b77535514df2422ce3b7935d850f
Do not update package mappings for the system user when the user is
first unlocked. Instead, schedule a job to be executed after 24 to 48
hours from when the system user is unlocked. This makes the service
initialization phase for the system user a little quicker since their
data is not likely to be stale. Additionally, this also ensures that
restored data is not pruned by mistake if there is a device restart
before restore is completed. The updating of the mappings occurs
normally for other users, on user service initialization.
Bug: 155209652
Test: manually ensure job is skipped for system user
Test: atest android.app.usage.cts.UsageStatsTest
Change-Id: I2c03a1a05246d6b454569c4569813e90bede3693
In the case that the DevicePolicyManagerInternal Local service does not
exist on device, the permission check for
(un)registerAppUsageLimitObserver should not be skipped.
Test: atest android.app.usage.cts.UsageStatsTest (must be on a device
with <unavailable-feature name="android.software.device_admin" /> in
it's features xml)
Fixes: 155360727
Change-Id: I8a88e03a7636956d27f531cf989bda1a32799f07
Currently, we are only using UsageStatsProto for backup and restore
purposes but to ensure it is in sync with UsageStatsProtoV2, adding the
recently added LOCUS_ID event. This enables us to easily fall back to
the earlier proto version if there are issues with V2. This also allows
us to backup all events data if we decide to do that in the future
before updating the B&R restore logic to use V2.
Bug: 155935953
Test: atest UsageStatsDatabaseTest
Change-Id: I792f20a0b44d13f1ed17c4dbebe5555044afa165