Commit Graph

10774 Commits

Author SHA1 Message Date
Felipe Leme
e6a2c970bd Merge "New @SystemApi: UserManager.getVisibleUsers()" 2022-08-24 20:06:21 +00:00
Oli Lan
aa94860466 Merge "Check for null application context in UserManager." into tm-qpr-dev am: 109ae7874c am: fb1ae8298a
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19459093

Change-Id: If2a1808a49d9025c83d11088f2a3d43781f8660a
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-24 04:51:06 +00:00
Oli Lan
fb1ae8298a Merge "Check for null application context in UserManager." into tm-qpr-dev am: 109ae7874c
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/19459093

Change-Id: I1007c9bffb74335d73ca36e34de9ac7939baa3b0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-23 20:30:29 +00:00
Felipe Leme
4fcb05c5eb New @SystemApi: UserManager.getVisibleUsers()
Test: atest CtsMultiUserTestCases:android.multiuser.cts.UserManagerTest
Test: m update-api

Fixes: 242801948

Change-Id: I5ca52e6705662b7e3939101890bb81345a5a831e
2022-08-23 20:29:03 +00:00
Dmitri Plotnikov
23d6326b82 Merge "Revert "Breaking history writing out of BatteryStatsImpl"" 2022-08-23 16:44:21 +00:00
Anna Bauza
5dca121419 Merge "Add Android Multiuser Atom which will contain number of supported users." 2022-08-23 06:54:34 +00:00
Andrew Chant
a7ee33e7a7 Revert "Breaking history writing out of BatteryStatsImpl"
This reverts commit 62242bdca3.

Reason for revert: ramdumps on ToT related to battersystats parcel parsing
Bug: 243434675

Change-Id: I18522929f5a1499f56a0cc19606c28a2ed9fc26d
2022-08-22 21:54:00 +00:00
Austin Borger
57b6c21a33 Merge "Revert "Add pids to AttributionSource."" 2022-08-22 17:22:01 +00:00
Austin Borger
7a8d805c63 Revert "Add pids to AttributionSource."
This reverts commit 20bcb3c4b8.

Reason for revert: Broken test (bug 243187237)

Change-Id: I2eb033ed06e2c0c56155e4848de1b399b69ffc6d
2022-08-22 00:56:14 +00:00
Adam Bookatz
3a39c41c8a Merge "Introduce UserProperties class" 2022-08-20 00:32:02 +00:00
Dmitri Plotnikov
df4a00579f Merge "Breaking history writing out of BatteryStatsImpl" 2022-08-20 00:28:27 +00:00
Dan Shi
f7a0e1f95d Merge "Revert "Freeze package cgroup before killing"" 2022-08-19 23:36:19 +00:00
Austin Borger
caa20c20e6 Merge "Add pids to AttributionSource." 2022-08-19 20:32:17 +00:00
Dan Shi
c9eec603c9 Revert "Freeze package cgroup before killing"
Revert submission 19436294-freeze_kill

Reason for revert: b/243096961
Reverted Changes:
I06aaa5a08:Freeze package cgroup before killing
I45e34244f:libprocessgroup: Add support for SetUserProfiles

Bug: 243096961
Change-Id: Ia8fd20e2cac3dc48c7489ea28cce1c7a16518254
2022-08-19 18:40:14 +00:00
Adam Bookatz
51f3320ac8 Introduce UserProperties class
Introduces a UserProperties class, which holds (potentially dynamic)
information about each user, where the (default) values depend on the
user type.
This can usually be used instead of
isManagedProfile() calls, giving fine-grained information, rather than
course-grained queries about the user type.

The system copies this object before delivering it to any callers,
filtering the properties by the permissions held by the caller.

The object can be parsed from XML, which is used for both persisting a
user's properties to disk, as well as for reading in the default
properties for each user type.

Bug: 235065648
Bug: 237399048
Bug: 170249807
Bug: 234439331

Test: atest UserManagerServiceUserPropertiesTest
Test: atest android.multiuser.cts.UserManagerTest
Test: atest com.android.server.pm.UserManagerTest
Test: atest UserManagerServiceUserTypeTest

Change-Id: If37480abafa784ce197b482103b6537a60fe2653
2022-08-19 10:59:30 -07:00
Philip Junker
10a0a4a61b Merge "Remove BatteryStats user activity types and use PowerManager ones instead." 2022-08-19 11:50:50 +00:00
Felipe Leme
e5b4ecaf97 Merge "Improvements on "start bg user on secondary display":" 2022-08-18 22:34:26 +00:00
T.J. Mercier
6dae283c55 Freeze package cgroup before killing
Apps are able to prevent their death by forking multiple processes
under different services and monitoring for the death of any of these.
When a child death is detected, the remaining process restarts the
terminating/terminated service before it's able to be killed itself.
This is now prevented by freezing the entire cgroup of the package to be
killed before killing the individual processes. After the kills are
completed synchronously, the cgroup can be unfrozen to allow for
restarts. Before freezing the cgroup, the binder interfaces of the
processes about to be frozen are also frozen to prevent indefinite
blocking by synchronous Binder callers.

Bug: 236708592
Test: raven:/ $ monkey -p com.haok.nirvana 1
Test: bash arg: -p
Test: bash arg: com.haok.nirvana
Test: bash arg: 1
Test: args: [-p, com.haok.nirvana, 1]
Test: arg: "-p"
Test: arg: "com.haok.nirvana"
Test: arg: "1"
Test: data="com.haok.nirvana"
Test: Events injected: 1
Test: ## Network stats: elapsed time=14ms (0ms mobile, 0ms wifi, 14ms not connected)
Test: raven:/ $ ps -eo pid,uid,ppid,name|grep 10266
Test: 2499 10266   823 com.haok.nirvana
Test: 2577 10266   823 com.haok.nirvana:resident
Test: 2584 10266   823 android.media
Test: 2669 10266     1 app_d
Test: 2672 10266     1 app_d
Test: raven:/ $ am force-stop com.haok.nirvana
Test: raven:/ $ ps -eo pid,uid,ppid,name|grep 10266
Test: 1|raven:/ $

Change-Id: I06aaa5a082f7b4923c6d9d1055bcf326e5eae67e
2022-08-17 17:18:00 +00:00
Anna Bauza
c3249a8704 Add Android Multiuser Atom which will contain number of supported users.
Metric [Design Doc approved](https://eldar.corp.google.com/assessments/860295929/revisions/1?jsmode=du&mods=eldarui_search#sections/999001).

Bug: 240582354
Test: statsd_testdrive 10160
Change-Id: I3cfbd2f79e71df6b2952d73d5a2bd20268708129
2022-08-17 06:47:14 +00:00
Austin Borger
20bcb3c4b8 Add pids to AttributionSource.
The cameraserver has a need for attributing connect calls to particular
processes. This patch introduces pids as a property of an
AttributionSource.

Test: Smoke test on cuttlefish
Bug: 190657833
Bug: 199526514
Change-Id: I6cdffed62447bbb741290dd9c2e5937254d02e3c
2022-08-15 16:59:53 -07:00
Dmitri Plotnikov
62242bdca3 Breaking history writing out of BatteryStatsImpl
Bug: 242230266
Test: atest FrameworksServicesTests:BatteryStatsTests
NoNonSdkCheck: BatteryStats.getHistoryBaseTime was only used locally within BatteryStats itself.  It was assigned to an unused variable, so removing this method is a no-op
Change-Id: Ib132f3e0a13d639c02e51188358fb4525b00ca9c
2022-08-12 16:28:34 -07:00
Felipe Leme
cf9d95ffe0 Improvements on "start bg user on secondary display":
- Adds hidden API on ActivityManager
- Checks if feature is supported
- Adds shell command to check if user is visible
- Includes (visible) on 'cmd user list -v'

Test: atest CtsMultiUserTestCases:android.multiuser.cts.UserManagerTest#testIsUserVisible_backgroundUserOnSecondaryDisplay
Test: m update-api
Test: adb shell cmd user is-user-visible --display 0 cur

Bug: 239982558

Change-Id: Ie7fe8c832ef2a3ffe4869a67fd35a0da363d0039
2022-08-12 16:45:57 +00:00
Tetiana Meronyk
b9b5ce87ea Merge "Fix adding new guest when maximum users are created." 2022-08-12 09:43:45 +00:00
Tetiana Meronyk
c2cc42f2c5 Add toString() for NewUserResponse.
Bug: 232106405
Test: atest NewUserResponseTest
Change-Id: I11a48bb619058f7f563e96bff98fbcb9c9ba4421
2022-08-11 16:02:41 +00:00
Tetiana Meronyk
2a26921ac0 Fix adding new guest when maximum users are created.
When maximum non-guest users were created, button to create guest user disappeared. Button appearance conditions are now updated to fix this issue.

Bug: 232077675
Test: atest UserManagerTest
Change-Id: I3e90c5faac9b63e100f7b3f121d5b78170dd48b3
2022-08-11 13:42:29 +00:00
TreeHugger Robot
84bc7ac16c Merge "Added a guard for some noisy UserManager log statements." 2022-08-11 00:39:44 +00:00
Michael Wachenschwanz
0575637c2f Merge "Add Power Model info to the BatteryUsageStats atom" 2022-08-10 23:10:52 +00:00
Felipe Leme
a912ece4d9 Added a guard for some noisy UserManager log statements.
Test: adb shell setprop persist.log.tag.UserManager VERBOSE && adb locat UserManager *:s
Bug: 226643927

Change-Id: I3275dcb0c30fd2502a089a8793ea7f147fad9acd
2022-08-10 14:26:06 +00:00
Felipe Leme
36e74d4db8 Initial implementation of UserManager.isUserVisible().
This API will be used to determine if the user is interacting with
the device and hence is able to do stuff like launching activities.

This initial version only returns true for the current foreground
user, but it will be expanded to also return true for:

- Background users associated with secondary displays
- (Running) profile of other visible users

Test: atest CtsMultiUserTestCases:android.multiuser.cts.UserManagerTest#testIsUserVisible_currentUser
Test: manual verification with Automotive's KitchenSink
Test: m update-api
Bug: 239824814

Change-Id: Ie8da07f69898d2b376bcf60d1da4221aed03ee3b
2022-08-09 02:42:37 +00:00
TreeHugger Robot
646dd4f125 Merge "Added UserManager.isUsersOnSecondaryDisplaysSupported()" 2022-08-08 21:54:32 +00:00
Felipe Leme
0fc2d3299a Added UserManager.isUsersOnSecondaryDisplaysSupported()
By default it reads the value from
config_multiuserUsersOnSecondaryDisplays
overridden by the system property for development purposes.

Test: adb shell setprop fw.users_on_secondary_displays true && \
      adb shell dumpsys user | grep -i "secondary display"

Fixes: 240613396

Change-Id: I1428a117a683e99fcaef71492be297c844d520e2
2022-08-08 09:14:08 -07:00
Philip Junker
bf794e4585 Remove BatteryStats user activity types and use PowerManager ones instead.
Add millisSinceLastUserActivity and lastUserActivityEvent to PowerGroup log when dozing.
Add timeout to PMS log when dozing.

Bug: 234530184
Test: atest BatteryStatsTests
Test: atest PowerManagerServiceTest
Test: manually observe logs using logcat / adb bugreport
NoNonSdkCheck: USER_ACTIVITY_TYPES is only accessed indirectly by apps through dumpLocked() method.
Change-Id: I835992a08bd4a07350e36ef671c6273c8fee43a0
2022-08-08 10:40:12 +00:00
Michael Wachenschwanz
cb02f0d95a Add Power Model info to the BatteryUsageStats atom
Test: atest BatteryUsageStatsPulledTest
Fixes: 241575236
Change-Id: I8dc3df7ed70914db99581cb8a2f616bb2cd9ea8e
2022-08-05 17:26:16 -07:00
Hani Kazmi
a0d9fc3b28 BaseBundle.java:: Clear underlying parcel when no longer referernced.
Follow up to ag/18795008.
Lazy Bundles, (aosp/1787847), introduced a change in behavior where a Parcel
created as part of initializing a Bundle is dependent on the next ART GCrun to be
recycled, causing a short term memory-leak. We previously force recycled
the parcel when bundle.clear() was called.

This commit takes it a step further and adds  reference counting for the number of
lazy values in mMap. When this reaches 0, we can safely eager recycle the
underlying parcel.

This still does not work when parcel references have been shared outside
the owning bundle (i.e, when mOwnsLazyValues is false.) We have two
options here:

1. Allow the GC to eventually claim the parcel (current behaviour).
2. Track lazy values refs globally across bundles. High complexity cost,
   and likely high performance impact.

We can not unmwrap the lazy values before copying, in case the
originating classloader can not instantiate the given class type. See
go/lazy-bundle

In initializeFromParcelLocked(), renamed boolean parameter recycleParcel to ownsParcel since the method no longer recycles in all cases. Also, only create lazy values if ownsParcel = true so that we don't have lazy values referencing the passed in parcel in case the caller doesn't own the parcel (which means the parcel could be recycled out of our control).

Bug: 233216232
Test: Reproduced linked bug on-device
Test: atest android.os.cts.ParcelTest android.os.cts.BundleTest
android.os.BundleTest android.os.ParcelTest android.os.BundleRecylingTest

Change-Id: I8a878a6d0055b04b2611909b4b17977ba5677a4f
2022-08-05 12:25:39 +00:00
Steven Moreland
67c02504a9 Merge "Reword ambiguous documentation in Parcel" am: c2bd9f481f am: 231c243d45 am: 4783db4155 am: 487f6885e5 am: a64ec98da3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2171073

Change-Id: Iaca7afc901e4325e66de172df5b59f64f9b161ad
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-02 22:26:39 +00:00
Steven Moreland
a64ec98da3 Merge "Reword ambiguous documentation in Parcel" am: c2bd9f481f am: 231c243d45 am: 4783db4155 am: 487f6885e5
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2171073

Change-Id: I70350af88cba7c17ac010b0eaa89169f42a000cd
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-02 21:26:55 +00:00
Steven Moreland
4783db4155 Merge "Reword ambiguous documentation in Parcel" am: c2bd9f481f am: 231c243d45
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2171073

Change-Id: I1a75c9e770366cd12c11358a89bda0d594f2e9d0
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-02 20:56:38 +00:00
Steven Moreland
231c243d45 Merge "Reword ambiguous documentation in Parcel" am: c2bd9f481f
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2171073

Change-Id: I645b073414031d43a90b097fc9454476b77ec0c3
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-08-02 20:39:26 +00:00
TreeHugger Robot
a7d85cabf3 Merge "Support test skipping when power save modes aren't enabled." 2022-08-02 20:20:14 +00:00
Kweku Adams
ba3b5d7e53 Support test skipping when power save modes aren't enabled.
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
2022-08-02 14:57:16 +00:00
danielzhang130
c63f3f259c Reword ambiguous documentation in Parcel
- original documentation for Parcel.unmarshall could be understood
  both ways: Parcel written with bytes of data, data written with
  bytes of Parcel

Test: Not applicable
Signed-off-by: danielzhang130 <danielzhang130@gmail.com>
Change-Id: I9afd3ae66ca03f391b272ac0524593395ffe53fa
2022-08-01 23:47:47 +00:00
Oli Lan
37471ba1ce Check for null application context in UserManager.
UserManager currently always uses getApplicationContext for its
internal context object, but that method can return null under certain
circumstances. This CL adds a null check, so that the original context
is used if the app context is null.

Bug: 232179155
Bug: 233915566
Test: atest UserManagerTest
Test: install Apex Launcher and App Hider on device with work profile
Change-Id: I26bcf693da8f5bc53126f79f9e6ffb17bd87fc84
2022-07-28 17:15:05 +01:00
Matt Gilbride
bf5d6f3e9c Merge "@EnforcePermission migrations - services.core" 2022-07-27 15:46:03 +00:00
Guojing Yuan
6707d97eae Merge "Remove OutcomeReceiver.noResult NonNull annotation" 2022-07-25 16:57:36 +00:00
TreeHugger Robot
31d259d371 Merge "Remove BatteryStats parcelability and some unused code" 2022-07-21 20:53:12 +00:00
Guojing Yuan
5fb0d9aa51 Remove OutcomeReceiver.noResult NonNull annotation
Bug: 239455439

Test: make
Change-Id: I3b783a01f6decd646223af884da4b066d9e087fd
2022-07-21 19:50:34 +00:00
Dmitri Plotnikov
d9fd8fc27b Remove BatteryStats parcelability and some unused code
Bug: 235635119
Test: presubmit
Change-Id: I9fa4b27e2e5e3679924c64a3747f9e6e560df465
2022-07-20 17:19:31 -07:00
Victor Chang
2bb34d954c Merge "Deprecate Debug.enableEmulatorTraceOutput()" am: 3f007c4dea am: b0bbe9b5f3 am: fd818a3610 am: 27f8e8943b am: d3fb6ef1a4
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2154934

Change-Id: I5506aeea08ce347d6201dc22fd9a3bfa86a17867
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 11:56:26 +00:00
Victor Chang
d3fb6ef1a4 Merge "Deprecate Debug.enableEmulatorTraceOutput()" am: 3f007c4dea am: b0bbe9b5f3 am: fd818a3610 am: 27f8e8943b
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2154934

Change-Id: Ie3ce9234b41dc9b32a2f97a70298f6cf6dd8e744
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 11:39:04 +00:00
Victor Chang
fd818a3610 Merge "Deprecate Debug.enableEmulatorTraceOutput()" am: 3f007c4dea am: b0bbe9b5f3
Original change: https://android-review.googlesource.com/c/platform/frameworks/base/+/2154934

Change-Id: I73022c7c3840483af31390c297ded5d904de51fa
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2022-07-20 10:41:35 +00:00